root/OpenSceneGraph/trunk/CMakeLists.txt @ 13482

Revision 13482, 49.0 kB (checked in by robert, 3 hours ago)

From Farshid Lashkari, "I've attached a small fix to the Collada loader which prevents a null pointer access in some cases."

  • Property svn:eol-style set to native
Line 
1set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
2set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3
4IF(WIN32)
5    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
6ELSE(WIN32)
7    IF(APPLE)
8        CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
9    ELSE(APPLE)
10        CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
11    ENDIF(APPLE)
12ENDIF(WIN32)
13
14if(COMMAND cmake_policy)
15    # Works around warnings libraries linked against that don't
16    # have absolute paths (e.g. -lpthreads)
17    cmake_policy(SET CMP0003 NEW)
18
19    # Works around warnings about escaped quotes in ADD_DEFINITIONS
20    # statements.
21    cmake_policy(SET CMP0005 NEW)
22
23    # tell CMake to prefer CMake's own CMake modules when available
24    # only available from cmake-2.8.4
25    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 8 AND ${CMAKE_PATCH_VERSION} GREATER 3)
26        cmake_policy(SET CMP0017 NEW)
27    endif()
28
29    # cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
30    # quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
31    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
32        cmake_policy(SET CMP0008 OLD)
33    endif()
34endif()
35
36PROJECT(OpenSceneGraph)
37
38SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
39SET(OPENSCENEGRAPH_MINOR_VERSION 1)
40SET(OPENSCENEGRAPH_PATCH_VERSION 8)
41SET(OPENSCENEGRAPH_SOVERSION 98)
42
43# set to 0 when not a release candidate, non zero means that any generated
44# svn tags will be treated as release candidates of given number
45SET(OPENSCENEGRAPH_RELEASE_CANDIDATE 0)
46
47SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
48
49SET(OSG_PLUGINS osgPlugins-${OPENSCENEGRAPH_VERSION})
50
51SET(OSG_PLUGIN_PREFIX "")
52
53IF (CYGWIN)
54    SET(OSG_PLUGIN_PREFIX "cygwin_")
55ENDIF()
56
57IF(MINGW)
58    SET(OSG_PLUGIN_PREFIX "mingw_")
59ENDIF()
60
61
62# We want to build SONAMES shared librariess
63SET(OPENSCENEGRAPH_SONAMES TRUE)
64SET(OPENTHREADS_SONAMES TRUE)
65
66SET(OpenThreads_SOURCE_DIR ${OpenSceneGraph_SOURCE_DIR})
67
68# We have some custom .cmake scripts not in the official distribution.
69# Maybe this can be used override existing behavior if needed?
70SET(CMAKE_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
71
72## Option to enable Android build using AndroidNDK
73OPTION(OSG_BUILD_PLATFORM_ANDROID OFF)
74IF(OSG_BUILD_PLATFORM_ANDROID)
75
76    CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
77
78    INCLUDE(OsgAndroidMacroUtils)
79    SET(ANDROID TRUE)
80    IF(NOT ANDROID_PLATFORM)
81        MESSAGE("Warning Android Platform version NOT defined, Default selected version: 5")
82        SET(ANDROID_PLATFORM 5)
83    ENDIF()
84    IF(NOT ANDROID_ABI)
85        MESSAGE("Warning Android ABI version NOT defined, Default selection: armeabi armeabi-v7a")
86        SET(ANDROID_ABI "armeabi armeabi-v7a")
87    ENDIF()
88    IF(NOT ANDROID_STL)
89        MESSAGE("Warning Android STL NOT defined, Default selection: gnustl_static")
90        SET(ANDROID_STL "gnustl_static")
91    ENDIF()
92    IF(ANDROID_DEBUG)
93        MESSAGE("Warning Android Build is in debug mode")
94        SET(ANDROID_RELEASE_OPTIM "debug")
95    ELSE()
96        MESSAGE("Warning Android Build is in release mode")
97        SET(ANDROID_RELEASE_OPTIM "release")
98    ENDIF()
99    IF(ANDROID_NEON)
100        MESSAGE("Warning Android NEON optimizations enabled, this will not be available on all armeabi-v7a devices ie. Tegra2")
101        SET(ANDROID_OPTIM_NEON true)
102    ELSE()
103        SET(ANDROID_OPTIM_NEON false)
104    ENDIF()
105    IF(ANDROID_ARM32)
106        MESSAGE("Warning ARM 32bit instruction set will be used")
107        SET(ANDROID_OPTIM_ARM32 true)
108    ELSE()
109        SET(ANDROID_OPTIM_ARM32 false)
110    ENDIF()
111
112    FIND_PACKAGE(AndroidNDK REQUIRED)
113
114    SET(OSG_ANDROID_TEMPLATES "${CMAKE_SOURCE_DIR}/PlatformSpecifics/Android")
115
116    SET(J  "4" CACHE STRING "how many processes for make -j <J>")
117
118    ADD_CUSTOM_COMMAND(
119        OUTPUT    Android-OpenSceneGraph
120        DEPENDS   ${CMAKE_BINARY_DIR}/Android.mk
121        COMMAND   "${ANDROID_NDK}/ndk-build"
122        ARGS      --directory=${CMAKE_BINARY_DIR} NDK_APPLICATION_MK=Application.mk -j${J} NDK_LOG=1
123    )
124
125    ADD_CUSTOM_TARGET(ndk ALL echo
126          DEPENDS Android-OpenSceneGraph
127    )
128    install(DIRECTORY include/ DESTINATION include/
129        PATTERN ".svn" EXCLUDE
130    )
131    install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ DESTINATION include/
132    )
133    install(DIRECTORY ${CMAKE_BINARY_DIR}/obj/ DESTINATION obj/
134        PATTERN ".svn" EXCLUDE
135        PATTERN "objs" EXCLUDE
136    )
137
138    ADD_DEFINITIONS(-DANDROID)
139
140ENDIF()
141
142
143
144# Okay, here's the problem: On some platforms, linking against OpenThreads
145# is not enough and explicit linking to the underlying thread library
146# is also required (e.g. FreeBSD). But OpenThreads may be built with different
147# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
148# thread library is because some platforms support multiple backends (e.g.
149# IRIX supports Sproc and Pthreads). Linking all libraries won't work
150# because the libraries may be incompatible.
151# So the current solution is to attempt best guess linking and exempt certain
152# cases. With IRIX, we're going to hope explicit linking to the underlying
153# library is not necessary. We currently don't case for pthreads on Windows
154# which might be an issue on things like Cygwin. This may need to be fixed.
155IF(NOT ANDROID)
156    FIND_PACKAGE(Threads)
157ENDIF()
158IF(CMAKE_SYSTEM MATCHES IRIX)
159    # Erase CMAKE_THREAD_LIBS_INIT and hope it works
160    SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
161ENDIF()
162
163OPTION(OSG_MAINTAINER "Enable OpenSceneGraph maintainer build methods, such as making svn branches, tags, updating ChangeLog." OFF)
164IF (OSG_MAINTAINER)
165
166    SET(OPENSCENEGRAPH_SVN "trunk")
167    #SET(OPENSCENEGRAPH_SVN "branches")
168    SET(OPENSCENEGRAPH_BRANCH OpenSceneGraph-${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION})
169
170    #
171    # Provide target for tagging a release
172    #
173    SET(SVNCOMMAND svn)
174    SET(SVNTRUNKDIR     http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk)
175    SET(SVNTAGDIR       http://svn.openscenegraph.org/osg/OpenSceneGraph/tags)
176    SET(SVNBRANCHDIR    http://svn.openscenegraph.org/osg/OpenSceneGraph/branches)
177
178    IF   (OPENSCENEGRAPH_SVN STREQUAL "trunk")
179        SET(SVNSOURCEDIR ${SVNTRUNKDIR})
180    ELSE()
181        SET(SVNSOURCEDIR ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH})
182    ENDIF()
183
184
185    IF   (OPENSCENEGRAPH_RELEASE_CANDIDATE EQUAL 0)
186        SET(RELEASE_NAME OpenSceneGraph-${OPENSCENEGRAPH_VERSION})
187    ELSE()
188        SET(RELEASE_NAME OpenSceneGraph-${OPENSCENEGRAPH_VERSION}-rc${OPENSCENEGRAPH_RELEASE_CANDIDATE})
189    ENDIF()
190
191
192    ADD_CUSTOM_TARGET(tag-test
193        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
194    )
195
196    ADD_CUSTOM_TARGET(tag-run
197        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
198    )
199
200    ADD_CUSTOM_TARGET(branch-test
201        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH} -m "Branch ${OPENSCENEGRAPH_BRANCH}"
202    )
203
204    ADD_CUSTOM_TARGET(branch-run
205        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${OPENSCENEGRAPH_BRANCH} -m "Branch ${OPENSCENEGRAPH_BRANCH}"
206    )
207
208    #
209    # Provide target for generating ChangeLog
210    #
211    SET(GENERATELOGS svn2cl)
212
213    ADD_CUSTOM_TARGET(ChangeLog
214        COMMAND ${SVNCOMMAND} update
215        COMMAND ${GENERATELOGS} ${SVNSOURCEDIR}
216    )
217
218ENDIF(OSG_MAINTAINER)
219
220IF(NOT ANDROID)
221IF(APPLE)
222    # Determine the canonical name of the selected Platform SDK
223    EXECUTE_PROCESS(COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "CanonicalName"
224                    OUTPUT_VARIABLE OSG_OSX_SDK_NAME
225                    OUTPUT_STRIP_TRAILING_WHITESPACE)
226
227    # Trying to get CMake to generate an XCode IPhone project, current efforts are to get iphoneos sdk 3.1 working
228    # Added option which needs manually setting to select the IPhone SDK for building. We can only have one of the below
229    # set to true. Should realy have an OSG_BUILD_PLATFORM variable that we set to our desired platform
230    OPTION(OSG_BUILD_PLATFORM_IPHONE "Enable IPhoneSDK Device support" OFF)
231    OPTION(OSG_BUILD_PLATFORM_IPHONE_SIMULATOR "Enable IPhoneSDK Simulator support" OFF)
232
233    IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
234
235        #you need to manually set the default sdk version here
236        SET (IPHONE_SDKVER "6.0" CACHE STRING "IOS SDK-Version")
237
238        #the below is taken from ogre, it states the gcc stuff needs to happen before PROJECT() is called. I've no clue if we even need it
239        # Force gcc <= 4.2 on iPhone
240        include(CMakeForceCompiler)
241        CMAKE_FORCE_C_COMPILER(llvm-gcc-4.2 GNU)
242        CMAKE_FORCE_CXX_COMPILER(llvm-gcc-4.2 GNU)
243        SET(GCC_THUMB_SUPPORT NO)
244
245        #set either the device sdk or the simulator sdk. Can't find away to separate these in the same project
246        IF(OSG_BUILD_PLATFORM_IPHONE)
247            SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer")
248            SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneOS${IPHONE_SDKVER}.sdk")
249        ELSE()
250            SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer")
251            SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk")
252        ENDIF()
253
254        # Apple iOS: Find OpenGLES
255        FIND_LIBRARY(OPENGLES_LIBRARY OpenGLES)
256    ELSE ()
257        FIND_LIBRARY(CARBON_LIBRARY Carbon)
258        FIND_LIBRARY(COCOA_LIBRARY Cocoa)
259
260        # Apple OS X: Find OpenGL and AGL
261        FIND_PACKAGE(OpenGL)
262        FIND_LIBRARY(AGL_LIBRARY AGL)
263    ENDIF ()
264
265    OPTION(OSG_COMPILE_FRAMEWORKS "compile frameworks instead of dylibs (experimental)" OFF)
266    SET(OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install name dir for compiled frameworks")
267ELSE()
268    # Non-Apple: Find OpenGL
269    FIND_PACKAGE(OpenGL)
270ENDIF()
271ENDIF()
272
273IF(UNIX AND NOT ANDROID)
274    # Not sure what this will do on Cygwin and Msys
275    # Also, remember OS X X11 is a user installed option so it may not exist.
276    FIND_PACKAGE(X11)
277    # Some Unicies need explicit linkage to the Math library or the build fails.
278    FIND_LIBRARY(MATH_LIBRARY m)
279
280    FIND_LIBRARY(DL_LIBRARY dl)
281    IF(NOT DL_LIBRARY)
282        SET(DL_LIBRARY "") # change from NOTFOUND to empty when passed to linker
283    ENDIF()
284
285    IF( CMAKE_SYSTEM MATCHES "Linux" )
286        FIND_LIBRARY( RT_LIBRARY rt )
287    ENDIF( CMAKE_SYSTEM MATCHES "Linux" )
288
289ENDIF()
290
291INCLUDE_DIRECTORIES(
292    ${OpenSceneGraph_SOURCE_DIR}/include
293    ${OPENGL_INCLUDE_DIR}
294)
295
296# Make the headers visible to everything
297IF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
298   INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
299ENDIF()
300
301# Common global definitions
302#ADD_DEFINITIONS(-D)
303# Platform specific definitions
304
305
306IF(WIN32 AND NOT ANDROID)
307
308    IF(MSVC)
309        # This option is to enable the /MP switch for Visual Studio 2005 and above compilers
310        OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
311        MARK_AS_ADVANCED(WIN32_USE_MP)
312        IF(WIN32_USE_MP)
313            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
314        ENDIF(WIN32_USE_MP)
315
316        # turn off various warnings
317        # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
318        #     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}")
319        # endforeach(warning)
320
321        # This option is to enable the /DYNAMICBASE switch
322        # It is used to workaround a bug in Windows 7 when linking in release, which results in corrupt
323        # 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
324        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)
325        MARK_AS_ADVANCED(WIN32_USE_DYNAMICBASE)
326        IF(WIN32_USE_DYNAMICBASE)
327            SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DYNAMICBASE")
328        ENDIF(WIN32_USE_DYNAMICBASE)
329
330        # More MSVC specific compilation flags
331        ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
332        ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
333
334        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)
335        MARK_AS_ADVANCED(MSVC_DISABLE_CHECKED_ITERATORS)
336        IF(MSVC_DISABLE_CHECKED_ITERATORS)
337            ADD_DEFINITIONS(-D_SECURE_SCL=0)
338        ENDIF(MSVC_DISABLE_CHECKED_ITERATORS)
339
340        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)
341        MARK_AS_ADVANCED(MSVC_USE_DEFAULT_STACK_SIZE)
342        IF(MSVC_USE_DEFAULT_STACK_SIZE)
343            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
344            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
345            STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
346        ENDIF(MSVC_USE_DEFAULT_STACK_SIZE)
347        get_filename_component( CMAKE_MAKE_PROGRAM_NAME ${CMAKE_MAKE_PROGRAM} NAME)
348        IF (CMAKE_MAKE_PROGRAM_NAME STREQUAL "VCExpress.exe")
349            OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS - VCExpress detected, not supported in VCExpress )" OFF)
350        ELSE()
351            OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS" ON)
352        ENDIF()
353        SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ${MSVC_BUILD_USE_SOLUTION_FOLDERS})
354    ENDIF()
355
356    #needed for net plugin
357    SET (OSG_SOCKET_LIBS wsock32)
358    # Both Cygwin and Msys need -DNOMINMAX ???
359    IF(UNIX)
360        ADD_DEFINITIONS(-DNOMINMAX)
361    ENDIF()
362
363########################################################################################################
364# the following options are MSVC specific,
365# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
366# fron bin folder without requiring installation step.
367# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
368# it also use a hack to get rid of Debug and Release folder in MSVC projects
369# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
370#
371# the second option disable incremental linking in debug build , that is enabled by default by CMake
372##########################################################################################################
373
374    IF(MSVC)
375        IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
376            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")
377            SET(OSG_MSVC_VERSIONED_DLL OFF)
378            SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
379        ELSE()
380            OPTION(OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" ON)
381            MARK_AS_ADVANCED(OSG_MSVC_VERSIONED_DLL)
382            OPTION(OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON)
383            MARK_AS_ADVANCED(OSG_MSVC_DEBUG_INCREMENTAL_LINK)
384            IF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
385                SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
386                SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
387                SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
388            ENDIF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
389        ENDIF()
390    ENDIF(MSVC)
391ENDIF(WIN32 AND NOT ANDROID)
392
393########################################################################################################
394##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
395########################################################################################################
396#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
397#luigi#SET(CMAKE_SKIP_RPATH TRUE)
398#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
399#luigi#IF(UNIX)
400#luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
401#luigi#    IF (contains)
402#luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  CMAKE_CXX_COMPILER to g++")
403#luigi#        SET(CMAKE_CXX_COMPILER "g++")
404#luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
405#luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
406#luigi#    ENDIF (contains)
407#luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
408#luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
409#luigi#ENDIF(UNIX)
410########################################################################################################
411
412OPTION(OSG_NOTIFY_DISABLED "Set to ON to build OpenSceneGraph with the notify() disabled." OFF)
413
414OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." OFF)
415MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX)
416
417OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." OFF)
418MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE)
419
420OPTION(OSG_USE_FLOAT_BOUNDINGSPHERE "Set to ON to build OpenSceneGraph with float BoundingSphere instead of double." ON)
421MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
422
423OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
424MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
425
426IF (WIN32)
427    OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF)
428    MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME)
429ENDIF()
430
431OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC warnings generated by OSG headers." ON)
432MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
433
434OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
435
436OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON)
437OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON)
438OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF)
439OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF)
440OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF)
441OPTION(OSG_GL_LIBRARY_STATIC "Set to ON to statically link with OpenGL/GLES library." OFF)
442
443SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
444
445# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
446# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
447# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
448# SET(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
449# SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE})
450
451OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
452OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
453OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
454OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ${OSG_GL1_AVAILABLE})
455OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
456
457OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
458
459################################################################################
460# Set Config file
461
462SET(OPENSCENEGRAPH_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/osg/Config")
463CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Config.in"
464               "${OPENSCENEGRAPH_CONFIG_HEADER}")
465
466SET(OPENSCENEGRAPH_VERSION_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/osg/Version")
467CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Version.in"
468               "${OPENSCENEGRAPH_VERSION_HEADER}")
469
470# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
471
472
473################################################################################
474# Set Version Info resource file
475
476IF(MSVC)
477    SET(OPENSCENEGRAPH_VERSIONINFO_RC "${PROJECT_BINARY_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc")
478    CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc.in"
479                   "${OPENSCENEGRAPH_VERSIONINFO_RC}")
480ENDIF()
481
482################################################################################
483# Optional build components
484
485# OSG Applications
486OPTION(BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" ON)
487
488# OSG Examples
489OPTION(BUILD_OSG_EXAMPLES "Enable to build OSG Examples" OFF)
490
491################################################################################
492# 3rd Party Dependency Stuff
493IF(WIN32 AND NOT ANDROID)
494    INCLUDE(Find3rdPartyDependencies)
495ENDIF()
496
497IF(ANDROID)
498    ANDROID_3RD_PARTY()
499ELSE()
500# Common to all platforms except android:
501    FIND_PACKAGE(FreeType)
502    FIND_PACKAGE(Inventor)
503    FIND_PACKAGE(Jasper)
504    FIND_PACKAGE(OpenEXR)
505    FIND_PACKAGE(COLLADA)
506    FIND_PACKAGE(FBX)
507    FIND_PACKAGE(ZLIB)
508    FIND_PACKAGE(Xine)
509    FIND_PACKAGE(OpenVRML)
510    FIND_PACKAGE(Performer)
511    FIND_PACKAGE(GDAL)
512    FIND_PACKAGE(GTA)
513    FIND_PACKAGE(CURL)
514    FIND_PACKAGE(LibVNCServer)
515    FIND_PACKAGE(OurDCMTK)
516    FIND_PACKAGE(FFmpeg)
517    FIND_PACKAGE(DirectShow)
518    FIND_PACKAGE(SDL)
519    FIND_PACKAGE(Poppler-glib)
520    FIND_PACKAGE(RSVG)
521    FIND_PACKAGE(GtkGl)
522    FIND_PACKAGE(DirectInput)
523    FIND_PACKAGE(NVTT)
524    FIND_PACKAGE(Asio)
525    FIND_PACKAGE(ZeroConf)
526ENDIF()
527
528IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
529    FIND_PACKAGE(ITK)
530ENDIF()
531
532# Include macro utilities here
533INCLUDE(OsgMacroUtils)
534
535OPTION(OSG_USE_QT "Enable to use Qt (build Qt-dependent libraries, plugins and examples)" ON)
536
537IF(OSG_USE_QT AND NOT ANDROID)
538# To select a specific version of QT define DESIRED_QT_VERSION
539# via cmake -DDESIRED_QT_VERSION=5
540# QUIET option disables messages if the package cannot be found.
541
542    IF  (DESIRED_QT_VERSION)
543        IF  (DESIRED_QT_VERSION MATCHES 5)
544              FIND_PACKAGE(Qt5Widgets)
545        ELSEIF (DESIRED_QT_VERSION MATCHES 4)
546              FIND_PACKAGE(Qt4)
547        ELSE()
548              FIND_PACKAGE(Qt3)
549        ENDIF()
550
551    ELSE()
552
553        FIND_PACKAGE(Qt5Widgets QUIET)
554       
555        IF ( Qt5Widgets_FOUND )
556            # CMake 2.8.8 or greater required
557            BUILDER_VERSION_GREATER(2 8 7)
558            IF(NOT VALID_BUILDER_VERSION)
559                MESSAGE(
560                SEND_ERROR
561                "Qt5 requires CMake version 2.8.8 or greater!\n"
562                "Update CMake or set DESIRED_QT_VERSION to less than 5
563                or disable OSG_USE_QT."
564                )
565            ENDIF( )
566        ENDIF( )
567
568        IF ( NOT Qt5Widgets_FOUND )
569            FIND_PACKAGE(Qt4)
570
571            IF (NOT QT4_FOUND)
572                FIND_PACKAGE(Qt3)
573            ENDIF()
574        ENDIF()
575    ENDIF()
576
577    #If we have found Qt5, let's try to top off by getting the webkit as well
578    IF ( Qt5Widgets_FOUND )
579        FIND_PACKAGE(Qt5WebKitWidgets)
580    ENDIF()
581
582ENDIF()
583
584#optional example related dependencies
585IF   (BUILD_OSG_EXAMPLES AND NOT ANDROID)
586
587
588    FIND_PACKAGE(FLTK)
589    FIND_PACKAGE(GLUT)
590    FIND_PACKAGE(FOX)
591
592    SET(wxWidgets_USE_LIBS base core gl net)
593    FIND_PACKAGE(wxWidgets)
594
595ENDIF(BUILD_OSG_EXAMPLES AND NOT ANDROID)
596
597
598# Platform specific:
599# (We can approach this one of two ways. We can try to FIND everything
600# and simply check if we found the packages before actually building
601# or we can hardcode the cases. The advantage of the former is that
602# packages that are installed on platforms that don't require them
603# will still get built (presuming no compatibility issues). But this
604# also means modules that are redundant may get built. For example,
605# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
606# Also, it will clutter the CMake menu with "NOT_FOUND".
607# The downside to the latter is that it is harder to build those
608# potentially redundant modules.)
609
610# Image readers/writers depend on 3rd party libraries except for OS X which
611# can use Quicktime.
612IF(NOT ANDROID)
613    IF(NOT APPLE)
614        FIND_PACKAGE(GIFLIB)
615        FIND_PACKAGE(JPEG)
616        FIND_PACKAGE(PNG)
617        FIND_PACKAGE(TIFF)
618        # QuickTime is required for OS X, but optional for Windows.
619        IF(WIN32)
620            FIND_PACKAGE(QuickTime)
621        ENDIF()
622
623    ELSE()
624        FIND_PACKAGE(TIFF)
625        FIND_PACKAGE(QuickTime)
626        FIND_PACKAGE(QTKit)
627        FIND_PACKAGE(CoreVideo)
628        FIND_PACKAGE(CoreMedia)
629        FIND_PACKAGE(QuartzCore)
630        FIND_PACKAGE(AVFoundation)
631    ENDIF()
632ENDIF()
633
634################################################################################
635# Create bin and lib directories if required
636
637IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
638   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib ${CMAKE_BINARY_DIR}/lib/${OSG_PLUGINS})
639ENDIF()
640
641
642################################################################################
643# Installation stuff
644
645SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
646SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
647SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
648SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
649
650# Set the build postfix extension according to what configuration is being built.
651IF (CMAKE_BUILD_TYPE MATCHES "Release")
652    SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELEASE_POSTFIX}")
653ELSEIF (CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
654    SET(CMAKE_BUILD_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}")
655ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
656    SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}")
657ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug")
658    SET(CMAKE_BUILD_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
659ELSE()
660    SET(CMAKE_BUILD_POSTFIX "")
661ENDIF()
662
663IF(UNIX AND NOT WIN32)
664  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
665  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
666ENDIF()
667
668IF(CYGWIN)
669  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
670  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
671ENDIF()
672
673IF(UNIX AND NOT WIN32 AND NOT APPLE)
674  IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
675      SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
676      MARK_AS_ADVANCED(LIB_POSTFIX)
677  ENDIF()
678ENDIF()
679IF(NOT DEFINED LIB_POSTFIX)
680    SET(LIB_POSTFIX "")
681ENDIF()
682
683# Here we apparantly do some funky stuff with making the bin/ and lib/
684# folders which is probably needed to work around a very old CMake bug?
685
686#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
687SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
688MAKE_DIRECTORY(${OUTPUT_BINDIR})
689IF(MSVC AND NOT MSVC_IDE)
690    MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
691ENDIF(MSVC AND NOT MSVC_IDE)
692
693#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
694SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
695MAKE_DIRECTORY(${OUTPUT_LIBDIR})
696IF(NOT MSVC OR MSVC_IDE)
697    MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
698ENDIF(NOT MSVC OR MSVC_IDE)
699
700# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
701# we work around the DLL placement by use of the PREFIX target property hack
702#
703# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
704# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
705#
706# CMake >= 2.8.1 changed the output directory algorithm (See doc).
707# Here we also set per-configuration directories (CMAKE_*_OUTPUT_DIRECTORY_<CONFIG>), or else binaries are generated in /bin/Debug and /bin/Release, etc. with MSVC and Xcode.
708# (Doc reads "multi-configuration generators (VS, Xcode) do NOT append a per-configuration subdirectory to the specified directory").
709# The workaround for 2.6.x (adding "../" as an output prefix for each target) seem to have no effect in >=2.8.1, so there is no need to change this.
710IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 5)
711    # If CMake < 2.6.0
712    SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
713    SET(LIBRARY_OUTPUT_PATH    ${OUTPUT_LIBDIR})
714ELSE()
715    # If CMake >= 2.6.0
716    SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
717    SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
718    IF(WIN32)
719        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
720    ELSE(WIN32)
721        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
722    ENDIF(WIN32)
723
724    # Testing CMAKE_VERSION is possible in >= 2.6.4 only
725    BUILDER_VERSION_GREATER(2 8 0)
726    IF(VALID_BUILDER_VERSION)  # If CMake >= 2.8.1
727        FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES})        # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
728            STRING(TOUPPER "${CONF}" CONF)                # Go uppercase (DEBUG, RELEASE...)
729            SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
730            SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
731            IF(WIN32)
732                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
733            ELSE()
734                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
735            ENDIF()
736        ENDFOREACH()
737    ENDIF(VALID_BUILDER_VERSION)
738ENDIF()
739
740#SET(INSTALL_BINDIR OpenSceneGraph/bin)
741#SET(INSTALL_INCDIR OpenSceneGraph/include)
742#SET(INSTALL_LIBDIR OpenSceneGraph/lib)
743#SET(INSTALL_DOCDIR OpenSceneGraph/doc)
744
745################################################################################
746# User Options
747
748
749# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
750# may set these values without needing to manipulate the environment.
751SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
752SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
753# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
754# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
755# A formal feature request has been submited to CMake, Bug #4947.
756# It is intended for those users who have common prefixes for their INCLUDE
757# and LIBRARY locations. So if users have headers in /usr/local/include
758# and libraries in /usr/local/lib, the common prefix is /usr/local.
759# It should also cover the case where headers and libraries are
760# in the same directory.
761# Our proposal expects that FIND_* commands will automatically search for
762# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
763# Obviously, since CMake does not currently support this, we must write
764# our Find*.cmake modules to explicitly support this. Otherwise, this variable
765# will have no impact.
766# This is unofficial so this may be removed or changed at anytime.
767SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
768
769# This is for an advanced option to give aggressive warnings
770# under different compilers. If yours is not implemented, this option
771# will not be made available.
772IF(CMAKE_COMPILER_IS_GNUCXX)
773    # To be complete, we might also do GNUCC flags,
774    # but everything here is C++ code.
775    # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
776    # returns too many hits.
777    # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
778    # interesting C-specific flag.
779    # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
780    # errors instead of warnings for certain issues, including superfluous
781    # semicolons and commas, and the use of long long. -fpermissive seems
782    # to be the workaround.
783    SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive)
784
785    # Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
786
787
788ELSE()
789    IF(MSVC)
790        # FIXME: What are good aggressive warning flags for Visual Studio?
791        # And do we need to further subcase this for different versions of VS?
792        # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
793        SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
794        IF(MSVC11)
795            SET(OSG_AGGRESSIVE_WARNING_FLAGS ${OSG_AGGRESSIVE_WARNING_FLAGS} /wd4250)
796        ENDIF()
797
798    ELSE()
799        # CMake lacks an elseif, so other non-gcc, non-VS compilers need
800        # to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
801        # remain unset.
802    ENDIF()
803ENDIF()
804
805# This part is for the CMake menu option to toggle the warnings on/off.
806# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
807IF(OSG_AGGRESSIVE_WARNING_FLAGS)
808
809    IF (APPLE)
810        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS OFF)
811    ELSE()
812        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS ON)
813    ENDIF()
814
815    OPTION(OSG_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" ${DEFAULT_USE_AGGRESSIVE_WARNINGS})
816    MARK_AS_ADVANCED(OSG_USE_AGGRESSIVE_WARNINGS)
817
818    IF(OSG_USE_AGGRESSIVE_WARNINGS)
819        # Add flags defined by OSG_AGGRESSIVE_WARNING_FLAGS if they aren't already there
820        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
821            IF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}")
822                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
823            ENDIF()
824        ENDFOREACH()
825    ELSE()
826        # Remove all flags considered aggresive
827        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
828            STRING(REGEX REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
829        ENDFOREACH()
830    ENDIF()
831ENDIF()
832
833
834# Dynamic vs Static Linking
835OPTION(DYNAMIC_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking.  Use OFF for static." ON)
836IF   (DYNAMIC_OPENSCENEGRAPH)
837    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
838ELSE ()
839    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
840ENDIF()
841
842
843# OSG Core
844ADD_SUBDIRECTORY(src)
845
846IF   (BUILD_OSG_APPLICATIONS AND NOT ANDROID)
847    ADD_SUBDIRECTORY(applications)
848ENDIF()
849
850IF   (BUILD_OSG_EXAMPLES)
851    ADD_SUBDIRECTORY(examples)
852ENDIF()
853
854
855IF(APPLE AND NOT ANDROID)
856
857        #Here we check if the user specified IPhone SDK
858    IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
859
860        #set iphone arch and flags taken from http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-the-iphone-using-cmake
861        IF(OSG_BUILD_PLATFORM_IPHONE)
862            SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
863            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=4.1 -mno-thumb -arch armv6 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
864        ELSE()
865            #simulator uses i386 architectures
866            SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
867            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -arch i386 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
868        ENDIF()
869
870        #here we set the specific iphone sdk version. We can only set either device or simulator sdk. So if you want both you currently have to have two seperate projects
871        SET(CMAKE_OSX_SYSROOT "${IPHONE_SDKROOT}" CACHE STRING "System root for iOS" FORCE)
872
873        #hack, force link to opengles
874        set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES")
875
876        #use the IPhone windowing system
877        SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Forced IPhone windowing system on iOS"  FORCE)
878        SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for iOS" FORCE)
879
880        #I think this or similar will be required for IPhone apps
881        OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" ON)
882
883    ELSE()
884
885        # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
886        # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
887
888        # These are just defaults/recommendations, but how we want to build
889        # out of the box. But the user needs to be able to change these options.
890        # So we must only set the values the first time CMake is run, or we
891        # will overwrite any changes the user sets.
892        # FORCE is used because the options are not reflected in the UI otherwise.
893        # Seems like a good place to add version specific compiler flags too.
894        IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
895            IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
896                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
897                # 64 Bit Works, i386,ppc is not supported any more
898                SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
899                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
900            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
901                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
902                # 64 Bit Works, PPC is not supported any more
903                SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
904                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
905            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
906                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
907                # 64-bit compiles are not supported with Carbon.
908                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
909                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)
910            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
911                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
912                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
913                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)
914            ELSE()
915                # No Universal Binary support
916                # Should break down further to set the -mmacosx-version-min,
917                # but the SDK detection is too unreliable here.
918            ENDIF()
919        ENDIF()
920
921        OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
922
923    ENDIF()
924
925ENDIF()
926
927
928# For Doxygen
929INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
930OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make doc_openscenegraph doc_openthreads)" OFF)
931MARK_AS_ADVANCED(CLEAR BUILD_DOCUMENTATION)
932# To build the documention, you will have to enable it
933# and then do the equivalent of "make doc_openscenegraph doc_openthreads".
934IF(BUILD_DOCUMENTATION)
935
936    OPTION(BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF)
937    IF(BUILD_REF_DOCS_SEARCHENGINE)
938        SET(SEARCHENGINE YES)
939    ELSE()
940        SET(SEARCHENGINE NO)
941    ENDIF()
942
943    OPTION(BUILD_REF_DOCS_TAGFILE "Generate a tag file named osg.tag on the documentation web server" OFF)
944    IF(BUILD_REF_DOCS_TAGFILE)
945        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg.tag")
946    ELSE()
947        SET(GENERATE_TAGFILE "")
948    ENDIF()
949
950    IF(DOT)
951        SET(HAVE_DOT YES)
952    ELSE()
953        SET(HAVE_DOT NO)
954    ENDIF()
955
956    # If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
957    SET(GENERATE_HTMLHELP "NO")
958    IF(DOCUMENTATION_HTML_HELP)
959        # on windows Documentation.cmake finds the html help workshop if it exists. On u*ix we might have it with wine but no way to point it out
960        IF(NOT WIN32)
961            SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
962            MARK_AS_ADVANCED(HTML_HELP_COMPILER)
963        ENDIF()
964        # this var sets a proper value in .doxygen files when configuring them below
965        SET(GENERATE_HTMLHELP "YES")
966    endif()
967
968    # This processes our doxyfile.cmake and substitutes paths to generate
969    # a final Doxyfile
970    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
971        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
972    )
973    # copy the osg logo to documentations target folder
974    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
975        ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg32-32.png COPYONLY
976    )
977    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
978    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs DESTINATION doc COMPONENT openscenegraph-doc)
979
980    # now set up openthreads documentation generation
981    IF(BUILD_REF_DOCS_TAGFILE)
982        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenThreadsReferenceDocs/ot.tag")
983    ENDIF()
984
985    # This processes our openthreads.doxyfile.cmake and generate a final doxyfile
986    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/openthreads.doxyfile.cmake
987        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
988    )
989    # copy the osg logo to documentations target folder
990    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
991        ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs/osg32-32.png COPYONLY
992    )
993    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
994    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs DESTINATION doc COMPONENT openthreads-doc)
995
996    # Process our other doxyfiles but don't create targets for these
997    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/all_Doxyfile
998        ${PROJECT_BINARY_DIR}/doc/all_Doxyfile)
999    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/auto_Doxyfile
1000        ${PROJECT_BINARY_DIR}/doc/auto_Doxyfile)
1001    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/core_Doxyfile
1002        ${PROJECT_BINARY_DIR}/doc/core_Doxyfile)
1003
1004    # This creates a new target to build documentation.
1005    # It runs ${DOXYGEN} which is the full path and executable to
1006    # Doxygen on your system, set by the FindDoxygen.cmake module
1007    # (called by FindDocumentation.cmake).
1008    # It runs the final generated Doxyfile against it.
1009    # The DOT_PATH is substituted into the Doxyfile.
1010    ADD_CUSTOM_TARGET(doc_openscenegraph ${DOXYGEN}
1011        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
1012    )
1013    SET_TARGET_PROPERTIES(doc_openscenegraph PROPERTIES FOLDER "Documentation")
1014
1015    ADD_CUSTOM_TARGET(doc_openthreads ${DOXYGEN}
1016        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
1017    )
1018    SET_TARGET_PROPERTIES(doc_openthreads PROPERTIES FOLDER "Documentation")
1019ENDIF(BUILD_DOCUMENTATION)
1020
1021OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph" OFF)
1022IF(BUILD_DASHBOARD_REPORTS)
1023# The following are required to uses Dart and the Cdash dashboard
1024# viewable here : http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph
1025    INCLUDE(Dart)
1026ENDIF()
1027
1028# present the packaging option only if we have the cpack command defined (effectively >= 2.6.0)
1029IF(CMAKE_CPACK_COMMAND)
1030    OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
1031    IF(BUILD_OSG_PACKAGES)
1032      INCLUDE(OsgCPack)
1033    ENDIF()
1034ENDIF()
1035
1036# Generate pkg-config configuration files
1037
1038SET(PKGCONFIG_FILES
1039  openscenegraph
1040  openscenegraph-osg
1041  openscenegraph-osgDB
1042  openscenegraph-osgFX
1043  openscenegraph-osgGA
1044  openscenegraph-osgParticle
1045  openscenegraph-osgSim
1046  openscenegraph-osgText
1047  openscenegraph-osgUtil
1048  openscenegraph-osgTerrain
1049  openscenegraph-osgManipulator
1050  openscenegraph-osgViewer
1051  openscenegraph-osgWidget
1052  openscenegraph-osgShadow
1053  openscenegraph-osgAnimation
1054  openscenegraph-osgVolume
1055)
1056
1057IF(QT4_FOUND OR Qt5Widgets_FOUND )
1058  SET(PKGCONFIG_FILES ${PKGCONFIG_FILES} openscenegraph-osgQt)
1059ENDIF()
1060
1061FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES})
1062  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc.in
1063    ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc
1064    @ONLY
1065    )
1066  INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenscenegraph-dev)
1067ENDFOREACH(PKGCONFIG_FILE)
1068
1069
1070# Run this as late as possible so users can easier spot the message
1071IF (NOT DEFINED REQUIRES_LIBPATH_MESSAGE AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")
1072    SET(REQUIRES_LIBPATH_MESSAGE ON)
1073ENDIF()
1074
1075IF(REQUIRES_LIBPATH_MESSAGE)
1076    IF (NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
1077        SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
1078
1079        MESSAGE("\nThe build system is configured to install libraries to ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}\n"
1080            "Your applications may not be able to find your installed libraries unless you:\n"
1081            "    set your LD_LIBRARY_PATH (user specific) or\n"
1082            "    update your ld.so configuration (system wide)")
1083        IF(IS_DIRECTORY /etc/ld.so.conf.d)
1084            MESSAGE("You have an ld.so.conf.d directory on your system, so if you wish to ensure that\n"
1085                "applications find the installed osg libraries, system wide, you could install an\n"
1086                "OpenSceneGraph specific ld.so configuration with:\n"
1087                "    sudo make install_ld_conf\n")
1088            CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in
1089                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
1090            )
1091            ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
1092                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
1093                /etc/ld.so.conf.d/openscenegraph.conf
1094                COMMAND ldconfig
1095                COMMENT "Copying openscenegraph.conf to /etc/ld.so.conf.d and running ldconfig"
1096            )
1097        ELSE()
1098            IF(EXISTS /etc/ld.so.conf)
1099                MESSAGE("You have an ld.so.conf file in /etc, if you wish to ensure \n"
1100                "that applications find the installed osg libraries, system wide, you\n"
1101                "could add ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX} to it.")
1102            ENDIF()
1103        ENDIF()
1104
1105        # emit a message during installation.
1106        INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}.\\nYou may need to update your ld.so configuration. \")")
1107
1108    ENDIF(NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
1109
1110ELSE()
1111    SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 0 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
1112ENDIF()
1113
1114
1115# This needs to be run very last so other parts of the scripts can take
1116# advantage of this.
1117IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
1118    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")
1119ENDIF()
1120
1121#-----------------------------------------------------------------------------
1122### uninstall target
1123#-----------------------------------------------------------------------------
1124CONFIGURE_FILE(
1125  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
1126  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
1127  IMMEDIATE @ONLY)
1128ADD_CUSTOM_TARGET(uninstall
1129  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
1130
1131#
1132IF(ANDROID)
1133    message(STATUS "Creating Android Makefile Master files" )
1134    configure_file("${OSG_ANDROID_TEMPLATES}/Android.mk.master.in" "${CMAKE_BINARY_DIR}/Android.mk")
1135    configure_file("${OSG_ANDROID_TEMPLATES}/Application.mk.master.in" "${CMAKE_BINARY_DIR}/Application.mk")
1136    configure_file("${OSG_ANDROID_TEMPLATES}/AndroidManifest.xml.master.in" "${CMAKE_BINARY_DIR}/AndroidManifest.xml")
1137ENDIF(ANDROID)
1138
Note: See TracBrowser for help on using the browser.