root/OpenSceneGraph/trunk/CMakeLists.txt @ 9847

Revision 9847, 35.9 kB (checked in by robert, 5 years ago)

Introduce FFmpegAudioStream implementation

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