root/OpenSceneGraph/trunk/CMakeLists.txt @ 13552

Revision 13552, 49.6 kB (checked in by robert, 29 hours ago)

Updated ChangeLog? and AUTHORS

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