root/OpenSceneGraph/trunk/CMakeLists.txt @ 11055

Revision 11055, 37.7 kB (checked in by robert, 4 years ago)

From Alberto Luaces, "he new GNU linker, "gold", is going to replace soon the current ld in
almost all Linux distributions. Although it is 100% compatible with ld,
by default it gives an error if a library has unresolved symbols at link
time, that is, it has set -Wl,--no-undefined by default. Debian folks
have found that libosg.so and libosgDB.so use some functions belonging
to libdl.so {dlsym,dlopen,dlclose,dlerror} without linking to it.

My changes link those two libraries to libdl.so explicitly in the same
way it is already done for libm.so and librt.so."

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