root/OpenSceneGraph/trunk/CMakeLists.txt @ 11817

Revision 11817, 37.7 kB (checked in by robert, 3 years ago)

Copied libutil and libtess implementations in form Mesa 7.9/src/glu into the src/osg/glu,
changed extensions from .c to .cpp and got compiling as C files as part of the osg core library.

Updated and cleaned up the rest of the OSG to use the new internal GLU.

  • Property svn:eol-style set to native
Line 
1set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
2
3IF(WIN32)
4    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
5ELSE(WIN32)
6    IF(APPLE)
7        CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
8    ELSE(APPLE)
9        CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
10    ENDIF(APPLE)
11ENDIF(WIN32)
12
13if(COMMAND cmake_policy)
14    # Works around warnings libraries linked against that don't
15    # have absolute paths (e.g. -lpthreads)
16    cmake_policy(SET CMP0003 NEW)
17
18    # Works around warnings about escaped quotes in ADD_DEFINITIONS
19    # statements.
20    cmake_policy(SET CMP0005 NEW)
21
22    # cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
23    # quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
24    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
25        cmake_policy(SET CMP0008 OLD)
26    endif()
27endif()
28
29PROJECT(OpenSceneGraph)
30
31SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
32SET(OPENSCENEGRAPH_MINOR_VERSION 9)
33SET(OPENSCENEGRAPH_PATCH_VERSION 10)
34SET(OPENSCENEGRAPH_SOVERSION 67)
35
36# set to 0 when not a release candidate, non zero means that any generated
37# svn tags will be treated as release candidates of given number
38SET(OPENSCENEGRAPH_RELEASE_CANDIDATE 0)
39
40SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
41
42SET(OSG_PLUGINS osgPlugins-${OPENSCENEGRAPH_VERSION})
43
44SET(OSG_PLUGIN_PREFIX "")
45
46IF (CYGWIN)
47    SET(OSG_PLUGIN_PREFIX "cygwin_")
48ENDIF()
49
50IF(MINGW)
51    SET(OSG_PLUGIN_PREFIX "mingw_")
52ENDIF()
53
54
55# We want to build SONAMES shared librariess
56SET(OPENSCENEGRAPH_SONAMES TRUE)
57SET(OPENTHREADS_SONAMES TRUE)
58
59SET(OpenThreads_SOURCE_DIR ${OpenSceneGraph_SOURCE_DIR})
60
61# We have some custom .cmake scripts not in the official distribution.
62# Maybe this can be used override existing behavior if needed?
63SET(CMAKE_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
64
65
66# Okay, here's the problem: On some platforms, linking against OpenThreads
67# is not enough and explicit linking to the underlying thread library
68# is also required (e.g. FreeBSD). But OpenThreads may be built with different
69# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
70# thread library is because some platforms support multiple backends (e.g.
71# IRIX supports Sproc and Pthreads). Linking all libraries won't work
72# because the libraries may be incompatible.
73# So the current solution is to attempt best guess linking and exempt certain
74# cases. With IRIX, we're going to hope explicit linking to the underlying
75# library is not necessary. We currently don't case for pthreads on Windows
76# which might be an issue on things like Cygwin. This may need to be fixed.
77FIND_PACKAGE(Threads)
78IF(CMAKE_SYSTEM MATCHES IRIX)
79    # Erase CMAKE_THREAD_LIBS_INIT and hope it works
80    SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
81ENDIF()
82
83OPTION(OSG_MAINTAINER "Enable OpenSceneGraph maintainer build methods, such as making svn branches, tags, updating ChangeLog." OFF)
84IF (OSG_MAINTAINER)
85
86    SET(OPENSCENEGRAPH_SVN "trunk")
87    #SET(OPENSCENEGRAPH_SVN "branches")
88    SET(OPENSCENEGRAPH_BRANCH OpenSceneGraph-${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION})
89
90    #
91    # Provide target for tagging a release
92    #
93    SET(SVNCOMMAND svn)
94    SET(SVNTRUNKDIR     http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk)
95    SET(SVNTAGDIR       http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags)
96    SET(SVNBRANCHDIR    http://www.openscenegraph.org/svn/osg/OpenSceneGraph/branches)
97
98    IF   (OPENSCENEGRAPH_SVN STREQUAL "trunk")
99        SET(SVNSOURCEDIR ${SVNTRUNKDIR})
100    ELSE()
101        SET(SVNSOURCEDIR ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH})
102    ENDIF()
103
104
105    IF   (OPENSCENEGRAPH_RELEASE_CANDIDATE EQUAL 0)
106        SET(RELEASE_NAME OpenSceneGraph-${OPENSCENEGRAPH_VERSION})
107    ELSE()
108        SET(RELEASE_NAME OpenSceneGraph-${OPENSCENEGRAPH_VERSION}-rc${OPENSCENEGRAPH_RELEASE_CANDIDATE})
109    ENDIF()
110
111
112    ADD_CUSTOM_TARGET(tag-test
113        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
114    )
115
116    ADD_CUSTOM_TARGET(tag-run
117        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
118    )
119
120    ADD_CUSTOM_TARGET(branch-test
121        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH} -m "Branch ${OPENSCENEGRAPH_BRANCH}"
122    )
123
124    ADD_CUSTOM_TARGET(branch-run
125        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH} -m "Branch ${OPENSCENEGRAPH_BRANCH}"
126    )
127
128    #
129    # Provide target for generating ChangeLog
130    #
131    SET(GENERATELOGS svn2cl)
132
133    ADD_CUSTOM_TARGET(ChangeLog
134        COMMAND ${SVNCOMMAND} update
135        COMMAND ${GENERATELOGS} ${SVNSOURCEDIR}
136    )
137   
138ENDIF(OSG_MAINTAINER)
139
140
141# Find OpenGL
142FIND_PACKAGE(OpenGL)
143
144IF(APPLE)
145    FIND_LIBRARY(CARBON_LIBRARY Carbon)
146    FIND_LIBRARY(COCOA_LIBRARY Cocoa)
147    OPTION(OSG_COMPILE_FRAMEWORKS "compile frameworks instead of dylibs (experimental)" OFF)
148    SET(OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install name dir for compiled frameworks")
149ENDIF()
150
151IF(UNIX)
152    # Not sure what this will do on Cygwin and Msys
153    # Also, remember OS X X11 is a user installed option so it may not exist.
154    FIND_PACKAGE(X11)
155    # Some Unicies need explicit linkage to the Math library or the build fails.
156    FIND_LIBRARY(MATH_LIBRARY m)
157
158    FIND_LIBRARY(DL_LIBRARY dl)
159    IF(NOT DL_LIBRARY)
160        SET(DL_LIBRARY "") # change from NOTFOUND to empty when passed to linker
161    ENDIF()
162
163    IF( CMAKE_SYSTEM MATCHES "Linux" )
164        FIND_LIBRARY( RT_LIBRARY rt )
165    ENDIF( CMAKE_SYSTEM MATCHES "Linux" )
166
167ENDIF()
168
169INCLUDE_DIRECTORIES(
170    ${OpenSceneGraph_SOURCE_DIR}/include
171    ${OPENGL_INCLUDE_DIR}
172)
173
174# Make the headers visible to everything
175IF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
176   INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
177ENDIF()
178
179# Common global definitions
180#ADD_DEFINITIONS(-D)
181# Platform specific definitions
182
183
184IF(WIN32)
185
186    IF(MSVC)
187        # This option is to enable the /MP switch for Visual Studio 2005 and above compilers
188        OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
189        MARK_AS_ADVANCED(WIN32_USE_MP)
190        IF(WIN32_USE_MP)
191            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
192        ENDIF(WIN32_USE_MP)
193
194        # turn off various warnings
195        # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
196        #     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}")
197        # endforeach(warning)
198
199        # This option is to enable the /DYNAMICBASE switch
200        # It is used to workaround a bug in Windows 7 when linking in release, which results in corrupt
201        # binaries. See this page for details: http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/01/24/the-case-of-the-corrupt-pe-binaries.aspx
202        OPTION(WIN32_USE_DYNAMICBASE "Set to ON to build OpenSceneGraph with the /DYNAMICBASE option to work around a bug when linking release executables on Windows 7." OFF)
203        MARK_AS_ADVANCED(WIN32_USE_DYNAMICBASE)
204        IF(WIN32_USE_DYNAMICBASE)
205            SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DYNAMICBASE")
206        ENDIF(WIN32_USE_DYNAMICBASE)
207
208        # More MSVC specific compilation flags
209        ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
210        ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
211
212        OPTION(MSVC_DISABLE_CHECKED_ITERATORS "Set to ON to disable Visual C++ checked iterators. If you do this you must ensure that every other project in your solution and all dependencies are compiled with _SECURE_SCL=0." OFF)
213        MARK_AS_ADVANCED(MSVC_DISABLE_CHECKED_ITERATORS)
214        IF(MSVC_DISABLE_CHECKED_ITERATORS)
215            ADD_DEFINITIONS(-D_SECURE_SCL=0)
216        ENDIF(MSVC_DISABLE_CHECKED_ITERATORS)
217
218        OPTION(MSVC_USE_DEFAULT_STACK_SIZE "Set to ON to use the default Visual C++ stack size. CMake forces a high stack size by default, which can cause problems for applications with large number of threads." OFF)
219        MARK_AS_ADVANCED(MSVC_USE_DEFAULT_STACK_SIZE)
220        IF(MSVC_USE_DEFAULT_STACK_SIZE)
221            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
222            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
223            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
224        ENDIF(MSVC_USE_DEFAULT_STACK_SIZE)
225
226    ENDIF()
227
228    #needed for net plugin
229    SET (OSG_SOCKET_LIBS wsock32)
230    # Both Cygwin and Msys need -DNOMINMAX ???
231    IF(UNIX)
232        ADD_DEFINITIONS(-DNOMINMAX)
233    ENDIF()
234
235########################################################################################################
236# the following options are MSVC specific,
237# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
238# fron bin folder without requiring installation step.
239# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
240# it also use a hack to get rid of Debug and Release folder in MSVC projects
241# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
242#
243# the second option disable incremental linking in debug build , that is enabled by default by CMake
244##########################################################################################################
245
246    IF(MSVC)
247        IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
248            MESSAGE("Warning:  disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7")
249            SET(OSG_MSVC_VERSIONED_DLL OFF)
250            SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
251        ELSE()
252            OPTION(OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" ON)
253            MARK_AS_ADVANCED(OSG_MSVC_VERSIONED_DLL)
254            OPTION(OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON)
255            MARK_AS_ADVANCED(OSG_MSVC_DEBUG_INCREMENTAL_LINK)
256            IF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
257                SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
258                SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
259                SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
260            ENDIF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
261        ENDIF()
262    ENDIF(MSVC)
263ENDIF(WIN32)
264
265########################################################################################################
266##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
267########################################################################################################
268#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
269#luigi#SET(CMAKE_SKIP_RPATH TRUE)
270#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
271#luigi#IF(UNIX)
272#luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
273#luigi#    IF (contains)
274#luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  CMAKE_CXX_COMPILER to g++")
275#luigi#        SET(CMAKE_CXX_COMPILER "g++")
276#luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
277#luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
278#luigi#    ENDIF (contains)
279#luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
280#luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
281#luigi#ENDIF(UNIX)
282########################################################################################################
283
284OPTION(OSG_NOTIFY_DISABLED "Set to ON to build OpenSceneGraph with the notify() disabled." OFF)
285
286OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." OFF)
287MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX)
288
289OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." OFF)
290MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE)
291
292OPTION(OSG_USE_FLOAT_BOUNDINGSPHERE "Set to ON to build OpenSceneGraph with float BoundingSphere instead of double." ON)
293MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
294
295OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
296MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
297
298OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF)
299MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME)
300
301OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC warnings generated by OSG headers." ON)
302MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
303
304OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
305
306OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON)
307OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON)
308OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF)
309OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF)
310OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF)
311OPTION(OSG_GL_LIBRARY_STATIC "Set to ON to statically link with OpenGL/GLES library." OFF)
312
313SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
314
315# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
316# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
317# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
318# SET(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
319# SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE})
320
321OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
322OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
323OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
324OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
325OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
326
327OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
328
329################################################################################
330# Set Config file
331
332SET(OPENSCENEGRAPH_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/osg/Config")
333CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Config.in"
334               "${OPENSCENEGRAPH_CONFIG_HEADER}")
335
336SET(OPENSCENEGRAPH_VERSION_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/osg/Version")
337CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Version.in"
338               "${OPENSCENEGRAPH_VERSION_HEADER}")
339
340# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
341
342
343################################################################################
344# Set Version Info resource file
345
346IF(MSVC)
347    SET(OPENSCENEGRAPH_VERSIONINFO_RC "${PROJECT_BINARY_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc")
348    CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc.in"
349                   "${OPENSCENEGRAPH_VERSIONINFO_RC}")
350ENDIF()
351
352################################################################################
353# Optional build components
354
355# OSG Applications
356OPTION(BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" ON)
357
358# OSG Examples
359OPTION(BUILD_OSG_EXAMPLES "Enable to build OSG Examples" OFF)
360
361################################################################################
362# 3rd Party Dependency Stuff
363IF(WIN32)
364    INCLUDE(Find3rdPartyDependencies)
365ENDIF()
366
367# Common to all platforms:
368FIND_PACKAGE(FreeType)
369FIND_PACKAGE(Inventor)
370FIND_PACKAGE(Jasper)
371FIND_PACKAGE(OpenEXR)
372FIND_PACKAGE(COLLADA)
373FIND_PACKAGE(FBX)
374FIND_PACKAGE(ZLIB)
375FIND_PACKAGE(Xine)
376FIND_PACKAGE(OpenVRML)
377FIND_PACKAGE(Performer)
378FIND_PACKAGE(GDAL)
379FIND_PACKAGE(CURL)
380FIND_PACKAGE(ITK)
381FIND_PACKAGE(LibVNCServer)
382FIND_PACKAGE(OurDCMTK)
383FIND_PACKAGE(OpenAL)
384FIND_PACKAGE(XUL)
385FIND_PACKAGE(FFmpeg)
386FIND_PACKAGE(DirectShow)
387FIND_PACKAGE(SDL)
388
389# To select a specific version of QT define DESIRED_QT_VERSION
390# via cmake -DDESIRED_QT_VERSION=4
391IF  (DESIRED_QT_VERSION)
392
393    IF  (DESIRED_QT_VERSION MATCHES 4)
394      FIND_PACKAGE(Qt4)
395    ELSE()
396      FIND_PACKAGE(Qt3)
397    ENDIF()
398
399ELSE()
400
401    FIND_PACKAGE(Qt4)
402
403    IF  (NOT QT4_FOUND)
404        FIND_PACKAGE(Qt3)
405    ENDIF()
406
407ENDIF()
408
409#use pkg-config to find various modues
410INCLUDE(FindPkgConfig OPTIONAL)
411
412IF(PKG_CONFIG_FOUND)
413
414    INCLUDE(FindPkgConfig)
415
416    PKG_CHECK_MODULES(GTK gtk+-2.0)
417
418    IF(WIN32)
419        PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0)
420    ELSE()
421        PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0)
422    ENDIF()
423
424    PKG_CHECK_MODULES(RSVG librsvg-2.0)
425    PKG_CHECK_MODULES(CAIRO cairo)
426    PKG_CHECK_MODULES(POPPLER poppler-glib)
427
428ENDIF()
429
430
431#optional example related dependencies
432IF   (BUILD_OSG_EXAMPLES)
433
434
435    FIND_PACKAGE(FLTK)
436    FIND_PACKAGE(GLUT)
437    FIND_PACKAGE(FOX)
438
439    SET(wxWidgets_USE_LIBS base core gl net)
440    FIND_PACKAGE(wxWidgets)
441
442ENDIF(BUILD_OSG_EXAMPLES)
443
444
445# Platform specific:
446# (We can approach this one of two ways. We can try to FIND everything
447# and simply check if we found the packages before actually building
448# or we can hardcode the cases. The advantage of the former is that
449# packages that are installed on platforms that don't require them
450# will still get built (presuming no compatibility issues). But this
451# also means modules that are redundant may get built. For example,
452# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
453# Also, it will clutter the CMake menu with "NOT_FOUND".
454# The downside to the latter is that it is harder to build those
455# potentially redundant modules.)
456
457# Image readers/writers depend on 3rd party libraries except for OS X which
458# can use Quicktime.
459IF(NOT APPLE)
460    FIND_PACKAGE(GIFLIB)
461    FIND_PACKAGE(JPEG)
462    FIND_PACKAGE(PNG)
463    FIND_PACKAGE(TIFF)
464
465    # QuickTime is required for OS X, but optional for Windows.
466    IF(WIN32)
467        FIND_PACKAGE(QuickTime)
468    ENDIF()
469
470ELSE()
471    FIND_PACKAGE(QuickTime)
472    FIND_PACKAGE(QTKit)
473    FIND_PACKAGE(CoreVideo)
474ENDIF()
475
476################################################################################
477# Create bin and lib directories if required
478
479IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
480   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib ${CMAKE_BINARY_DIR}/lib/${OSG_PLUGINS})
481ENDIF()
482
483
484################################################################################
485# Installation stuff
486
487SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
488SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
489SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
490SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
491
492IF(UNIX AND NOT WIN32)
493  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
494  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
495ENDIF()
496
497IF(CYGWIN)
498  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
499  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
500ENDIF()
501
502IF(UNIX AND NOT WIN32 AND NOT APPLE)
503  IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
504      SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
505      MARK_AS_ADVANCED(LIB_POSTFIX)
506  ENDIF()
507ENDIF()
508IF(NOT DEFINED LIB_POSTFIX)
509    SET(LIB_POSTFIX "")
510ENDIF()
511
512# Here we apparantly do some funky stuff with making the bin/ and lib/
513# folders which is probably needed to work around a very old CMake bug?
514
515#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
516SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
517MAKE_DIRECTORY(${OUTPUT_BINDIR})
518IF(MSVC AND NOT MSVC_IDE)
519    MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
520ENDIF(MSVC AND NOT MSVC_IDE)
521
522#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
523SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
524MAKE_DIRECTORY(${OUTPUT_LIBDIR})
525IF(NOT MSVC OR MSVC_IDE)
526    MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
527ENDIF(NOT MSVC OR MSVC_IDE)
528
529# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
530# we work around the DLL placement by use of the PREFIX target property hack
531#
532# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
533# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
534
535IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 5)
536    SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
537    SET(LIBRARY_OUTPUT_PATH    ${OUTPUT_LIBDIR})
538ELSE()
539    # If CMake >= 2.6.0
540    SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
541    SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
542    IF(WIN32)
543        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
544    ELSE(WIN32)
545        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
546    ENDIF(WIN32)
547ENDIF()
548
549#SET(INSTALL_BINDIR OpenSceneGraph/bin)
550#SET(INSTALL_INCDIR OpenSceneGraph/include)
551#SET(INSTALL_LIBDIR OpenSceneGraph/lib)
552#SET(INSTALL_DOCDIR OpenSceneGraph/doc)
553
554################################################################################
555# User Options
556
557
558# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
559# may set these values without needing to manipulate the environment.
560SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
561SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
562# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
563# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
564# A formal feature request has been submited to CMake, Bug #4947.
565# It is intended for those users who have common prefixes for their INCLUDE
566# and LIBRARY locations. So if users have headers in /usr/local/include
567# and libraries in /usr/local/lib, the common prefix is /usr/local.
568# It should also cover the case where headers and libraries are
569# in the same directory.
570# Our proposal expects that FIND_* commands will automatically search for
571# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
572# Obviously, since CMake does not currently support this, we must write
573# our Find*.cmake modules to explicitly support this. Otherwise, this variable
574# will have no impact.
575# This is unofficial so this may be removed or changed at anytime.
576SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
577
578# This is for an advanced option to give aggressive warnings
579# under different compilers. If yours is not implemented, this option
580# will not be made available.
581IF(CMAKE_COMPILER_IS_GNUCXX)
582    # To be complete, we might also do GNUCC flags,
583    # but everything here is C++ code.
584    # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
585    # returns too many hits.
586    # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
587    # interesting C-specific flag.
588    # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
589    # errors instead of warnings for certain issues, including superfluous
590    # semicolons and commas, and the use of long long. -fpermissive seems
591    # to be the workaround.
592    SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive)
593
594    # Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
595
596
597ELSE()
598    IF(MSVC)
599        # FIXME: What are good aggressive warning flags for Visual Studio?
600        # And do we need to further subcase this for different versions of VS?
601        # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
602        SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
603
604
605    ELSE()
606        # CMake lacks an elseif, so other non-gcc, non-VS compilers need
607        # to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
608        # remain unset.
609    ENDIF()
610ENDIF()
611
612# This part is for the CMake menu option to toggle the warnings on/off.
613# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
614IF(OSG_AGGRESSIVE_WARNING_FLAGS)
615
616    IF (APPLE)
617        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS OFF)
618    ELSE()
619        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS ON)
620    ENDIF()
621
622    OPTION(OSG_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" ${DEFAULT_USE_AGGRESSIVE_WARNINGS})
623    MARK_AS_ADVANCED(OSG_USE_AGGRESSIVE_WARNINGS)
624
625    IF(OSG_USE_AGGRESSIVE_WARNINGS)
626        # Add flags defined by OSG_AGGRESSIVE_WARNING_FLAGS if they aren't already there
627        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
628            IF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}")
629                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
630            ENDIF()
631        ENDFOREACH()
632    ELSE()
633        # Remove all flags considered aggresive
634        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
635            STRING(REGEX REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
636        ENDFOREACH()
637    ENDIF()
638ENDIF()
639
640
641# Dynamic vs Static Linking
642OPTION(DYNAMIC_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking.  Use OFF for static." ON)
643IF   (DYNAMIC_OPENSCENEGRAPH)
644    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
645ELSE ()
646    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
647ENDIF()
648
649INCLUDE(OsgMacroUtils)
650# OSG Core
651ADD_SUBDIRECTORY(src)
652
653IF   (BUILD_OSG_APPLICATIONS)
654    ADD_SUBDIRECTORY(applications)
655ENDIF()
656
657IF   (BUILD_OSG_EXAMPLES)
658    ADD_SUBDIRECTORY(examples)
659ENDIF()
660
661
662# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
663# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
664IF(APPLE)
665    # These are just defaults/recommendations, but how we want to build
666    # out of the box. But the user needs to be able to change these options.
667    # So we must only set the values the first time CMake is run, or we
668    # will overwrite any changes the user sets.
669    # FORCE is used because the options are not reflected in the UI otherwise.
670    # Seems like a good place to add version specific compiler flags too.
671    IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
672        # This is really fragile, but CMake doesn't provide the OS system
673        # version information we need. (Darwin versions can be changed
674        # independently of OS X versions.)
675        # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
676        IF(EXISTS /Developer/SDKs/MacOSX10.6.sdk)
677            SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
678            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.6 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
679            SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Forced Cocoa windowing system in 64 bits snow leopard"  FORCE)
680            SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio " CACHE STRING "Forced imageio default image plugin for OSX in 64 bits snow leopard" FORCE)
681        ELSEIF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
682            # 64-bit compiles are not supported with Carbon. We should enable
683            # 64-bit compilation by default once osgviewer has been
684            # rewritten with Cocoa.
685            #SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
686            SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
687            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
688        ELSEIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
689            SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
690            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
691        ELSE()
692            # No Universal Binary support
693            # Should break down further to set the -mmacosx-version-min,
694            # but the SDK detection is too unreliable here.
695        ENDIF()
696    ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
697
698    OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
699
700ENDIF(APPLE)
701
702
703# For Doxygen
704INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
705OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF)
706MARK_AS_ADVANCED(CLEAR BUILD_DOCUMENTATION)
707# To build the documention, you will have to enable it
708# and then do the equivalent of "make DoxygenDoc".
709IF(BUILD_DOCUMENTATION)
710
711    OPTION(BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF)
712    IF(BUILD_REF_DOCS_SEARCHENGINE)
713        SET(SEARCHENGINE YES)
714    ELSE()
715        SET(SEARCHENGINE NO)
716    ENDIF()
717
718    OPTION(BUILD_REF_DOCS_TAGFILE "Generate a tag file named osg.tag on the documentation web server" OFF)
719    IF(BUILD_REF_DOCS_TAGFILE)
720        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg.tag")
721    ELSE()
722        SET(GENERATE_TAGFILE "")
723    ENDIF()
724
725    IF(DOT)
726        SET(HAVE_DOT YES)
727    ELSE()
728        SET(HAVE_DOT NO)
729    ENDIF()
730   
731    # If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
732    SET(GENERATE_HTMLHELP "NO")
733    IF(DOCUMENTATION_HTML_HELP)
734        # on windows Documentation.cmake finds the html help workshop fi it exists. On u*ix we might have it with wine but no way to point it out
735        IF(NOT WIN32)
736            SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
737            MARK_AS_ADVANCED(HTML_HELP_COMPILER)
738        ENDIF()
739        # this var sets a proper value in .doxygen files when coniguring them below
740        SET(GENERATE_HTMLHELP "YES")
741    endif()
742 
743    # This processes our doxyfile.cmake and substitutes paths to generate
744    # a final Doxyfile
745    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
746        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
747    )
748    # copy the osg logo to documentations target folder
749    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
750        ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg32-32.png COPYONLY
751    )
752    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
753    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs DESTINATION doc COMPONENT openscenegraph-doc)
754
755    # now set up openthreads documentation generation
756    IF(BUILD_REF_DOCS_TAGFILE)
757        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenThreadsReferenceDocs/ot.tag")
758    ENDIF()
759
760    # This processes our openthreads.doxyfile.cmake and generate a final doxyfile
761    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/openthreads.doxyfile.cmake
762        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
763    )
764    # copy the osg logo to documentations target folder
765    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
766        ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs/osg32-32.png COPYONLY
767    )
768    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
769    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs DESTINATION doc COMPONENT openthreads-doc)
770
771    # Process our other doxyfiles but don't create targets for these
772    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/all_Doxyfile
773        ${PROJECT_BINARY_DIR}/doc/all_Doxyfile)
774    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/auto_Doxyfile
775        ${PROJECT_BINARY_DIR}/doc/auto_Doxyfile)
776    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/core_Doxyfile
777        ${PROJECT_BINARY_DIR}/doc/core_Doxyfile)
778   
779    # This creates a new target to build documentation.
780    # It runs ${DOXYGEN} which is the full path and executable to
781    # Doxygen on your system, set by the FindDoxygen.cmake module
782    # (called by FindDocumentation.cmake).
783    # It runs the final generated Doxyfile against it.
784    # The DOT_PATH is substituted into the Doxyfile.
785    ADD_CUSTOM_TARGET(doc_openscenegraph ${DOXYGEN}
786        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
787    )
788    ADD_CUSTOM_TARGET(doc_openthreads ${DOXYGEN}
789        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
790    )
791ENDIF(BUILD_DOCUMENTATION)
792
793OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph" OFF)
794IF(BUILD_DASHBOARD_REPORTS)
795# The following are required to uses Dart and the Cdash dashboard
796# viewable here : http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph
797    INCLUDE(Dart)
798ENDIF()
799
800# present the packaging option only if we have the cpack command defined (effectively >= 2.6.0)
801IF(CMAKE_CPACK_COMMAND)
802    OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
803    IF(BUILD_OSG_PACKAGES)
804      INCLUDE(OsgCPack)
805    ENDIF()
806ENDIF()
807
808# Generate pkg-config configuration files
809
810SET(PKGCONFIG_FILES
811  openscenegraph
812  openscenegraph-osg
813  openscenegraph-osgDB
814  openscenegraph-osgFX
815  openscenegraph-osgGA
816  openscenegraph-osgParticle
817  openscenegraph-osgSim
818  openscenegraph-osgText
819  openscenegraph-osgUtil
820  openscenegraph-osgTerrain
821  openscenegraph-osgManipulator
822  openscenegraph-osgViewer
823  openscenegraph-osgWidget
824  openscenegraph-osgShadow
825  openscenegraph-osgAnimation
826  openscenegraph-osgVolume
827)
828
829IF(QT4_FOUND)
830  SET(PKGCONFIG_FILES ${PKGCONFIG_FILES} openscenegraph-osgQt)
831ENDIF(QT4_FOUND)
832
833FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES})
834  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc.in
835    ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc
836    @ONLY
837    )
838  INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenscenegraph-dev)
839ENDFOREACH(PKGCONFIG_FILE)
840
841
842# Run this as late as possible so users can easier spot the message
843IF (NOT DEFINED REQUIRES_LIBPATH_MESSAGE AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")
844    SET(REQUIRES_LIBPATH_MESSAGE ON)
845ENDIF()
846
847IF(REQUIRES_LIBPATH_MESSAGE)
848    IF (NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
849        SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
850
851        MESSAGE("\nThe build system is configured to install libraries to ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}\n"
852            "Your applications may not be able to find your installed libraries unless you:\n"
853            "    set your LD_LIBRARY_PATH (user specific) or\n"
854            "    update your ld.so configuration (system wide)")
855        IF(IS_DIRECTORY /etc/ld.so.conf.d)
856            MESSAGE("You have an ld.so.conf.d directory on your system, so if you wish to ensure that\n"
857                "applications find the installed osg libraries, system wide, you could install an\n"
858                "OpenSceneGraph specific ld.so configuration with:\n"
859                "    sudo make install_ld_conf\n")
860            CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in
861                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
862            )
863            ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
864                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
865                /etc/ld.so.conf.d/openscenegraph.conf
866                COMMAND ldconfig
867                COMMENT "Copying openscenegraph.conf to /etc/ld.so.conf.d and running ldconfig"
868            )
869        ELSE()
870            IF(EXISTS /etc/ld.so.conf)
871                MESSAGE("You have an ld.so.conf file in /etc, if you wish to ensure \n"
872                "that applications find the installed osg libraries, system wide, you\n"
873                "could add ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX} to it.")
874            ENDIF()
875        ENDIF()
876
877        # emit a message during installation.
878        INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}.\\nYou may need to update your ld.so configuration. \")")
879
880    ENDIF(NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
881
882ELSE()
883    SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 0 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
884ENDIF()
885
886
887# This needs to be run very last so other parts of the scripts can take
888# advantage of this.
889IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
890    SET(OSG_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
891ENDIF()
892
893#-----------------------------------------------------------------------------
894### uninstall target
895#-----------------------------------------------------------------------------
896CONFIGURE_FILE(
897  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
898  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
899  IMMEDIATE @ONLY)
900ADD_CUSTOM_TARGET(uninstall
901  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
Note: See TracBrowser for help on using the browser.