root/OpenSceneGraph/trunk/CMakeLists.txt @ 13557

Revision 13557, 49.5 kB (checked in by robert, 19 hours ago)

Added shaders to support experimental shader based displacement mapping technique osgTerrain::ShaderTerrain?.

  • 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
473################################################################################
474# Set Config file
475
476SET(OPENSCENEGRAPH_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/osg/Config")
477CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Config.in"
478               "${OPENSCENEGRAPH_CONFIG_HEADER}")
479
480SET(OPENSCENEGRAPH_VERSION_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/osg/Version")
481CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Version.in"
482               "${OPENSCENEGRAPH_VERSION_HEADER}")
483
484# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
485
486
487################################################################################
488# Set Version Info resource file
489
490IF(MSVC)
491    SET(OPENSCENEGRAPH_VERSIONINFO_RC "${PROJECT_BINARY_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc")
492    CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc.in"
493                   "${OPENSCENEGRAPH_VERSIONINFO_RC}")
494ENDIF()
495
496################################################################################
497# Optional build components
498
499# OSG Applications
500OPTION(BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" ON)
501
502# OSG Examples
503OPTION(BUILD_OSG_EXAMPLES "Enable to build OSG Examples" OFF)
504
505################################################################################
506# 3rd Party Dependency Stuff
507IF(WIN32 AND NOT ANDROID)
508    INCLUDE(Find3rdPartyDependencies)
509ENDIF()
510
511IF(ANDROID)
512    ANDROID_3RD_PARTY()
513ELSE()
514# Common to all platforms except android:
515    FIND_PACKAGE(FreeType)
516    FIND_PACKAGE(Inventor)
517    FIND_PACKAGE(Jasper)
518    FIND_PACKAGE(OpenEXR)
519    FIND_PACKAGE(COLLADA)
520    FIND_PACKAGE(FBX)
521    FIND_PACKAGE(ZLIB)
522    FIND_PACKAGE(Xine)
523    FIND_PACKAGE(OpenVRML)
524    FIND_PACKAGE(Performer)
525    FIND_PACKAGE(GDAL)
526    FIND_PACKAGE(GTA)
527    FIND_PACKAGE(CURL)
528    FIND_PACKAGE(LibVNCServer)
529    FIND_PACKAGE(OurDCMTK)
530    FIND_PACKAGE(FFmpeg)
531    FIND_PACKAGE(DirectShow)
532    FIND_PACKAGE(SDL)
533    FIND_PACKAGE(Poppler-glib)
534    FIND_PACKAGE(RSVG)
535    FIND_PACKAGE(GtkGl)
536    FIND_PACKAGE(DirectInput)
537    FIND_PACKAGE(NVTT)
538    FIND_PACKAGE(Asio)
539    FIND_PACKAGE(ZeroConf)
540ENDIF()
541
542IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
543    FIND_PACKAGE(ITK)
544ENDIF()
545
546# Include macro utilities here
547INCLUDE(OsgMacroUtils)
548
549OPTION(OSG_USE_QT "Enable to use Qt (build Qt-dependent libraries, plugins and examples)" ON)
550
551IF(OSG_USE_QT AND NOT ANDROID)
552# To select a specific version of QT define DESIRED_QT_VERSION
553# via cmake -DDESIRED_QT_VERSION=5
554# QUIET option disables messages if the package cannot be found.
555
556    IF  (DESIRED_QT_VERSION)
557        IF  (DESIRED_QT_VERSION MATCHES 5)
558              FIND_PACKAGE(Qt5Widgets)
559        ELSEIF (DESIRED_QT_VERSION MATCHES 4)
560              FIND_PACKAGE(Qt4)
561        ELSE()
562              FIND_PACKAGE(Qt3)
563        ENDIF()
564
565    ELSE()
566
567        FIND_PACKAGE(Qt5Widgets QUIET)
568
569        IF ( Qt5Widgets_FOUND )
570            # CMake 2.8.8 or greater required
571            BUILDER_VERSION_GREATER(2 8 7)
572            IF(NOT VALID_BUILDER_VERSION)
573                MESSAGE(
574                SEND_ERROR
575                "Qt5 requires CMake version 2.8.8 or greater!\n"
576                "Update CMake or set DESIRED_QT_VERSION to less than 5
577                or disable OSG_USE_QT."
578                )
579            ENDIF( )
580        ENDIF( )
581
582        IF ( NOT Qt5Widgets_FOUND )
583            FIND_PACKAGE(Qt4)
584
585            IF (NOT QT4_FOUND)
586                FIND_PACKAGE(Qt3)
587            ENDIF()
588        ENDIF()
589    ENDIF()
590
591    #If we have found Qt5, let's try to top off by getting the webkit as well
592    IF ( Qt5Widgets_FOUND )
593        FIND_PACKAGE(Qt5WebKitWidgets)
594    ENDIF()
595
596ENDIF()
597
598#optional example related dependencies
599IF   (BUILD_OSG_EXAMPLES AND NOT ANDROID)
600
601
602    FIND_PACKAGE(FLTK)
603    FIND_PACKAGE(GLUT)
604    FIND_PACKAGE(FOX)
605
606    SET(wxWidgets_USE_LIBS base core gl net)
607    FIND_PACKAGE(wxWidgets)
608
609ENDIF(BUILD_OSG_EXAMPLES AND NOT ANDROID)
610
611
612# Platform specific:
613# (We can approach this one of two ways. We can try to FIND everything
614# and simply check if we found the packages before actually building
615# or we can hardcode the cases. The advantage of the former is that
616# packages that are installed on platforms that don't require them
617# will still get built (presuming no compatibility issues). But this
618# also means modules that are redundant may get built. For example,
619# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
620# Also, it will clutter the CMake menu with "NOT_FOUND".
621# The downside to the latter is that it is harder to build those
622# potentially redundant modules.)
623
624# Image readers/writers depend on 3rd party libraries except for OS X which
625# can use Quicktime.
626IF(NOT ANDROID)
627    IF(NOT APPLE)
628        FIND_PACKAGE(GIFLIB)
629        FIND_PACKAGE(JPEG)
630        FIND_PACKAGE(PNG)
631        FIND_PACKAGE(TIFF)
632        # QuickTime is required for OS X, but optional for Windows.
633        IF(WIN32)
634            FIND_PACKAGE(QuickTime)
635        ENDIF()
636
637    ELSE()
638        FIND_PACKAGE(TIFF)
639        FIND_PACKAGE(QuickTime)
640        FIND_PACKAGE(QTKit)
641        FIND_PACKAGE(CoreVideo)
642        FIND_PACKAGE(CoreMedia)
643        FIND_PACKAGE(QuartzCore)
644        FIND_PACKAGE(AVFoundation)
645    ENDIF()
646ENDIF()
647
648################################################################################
649# Create bin and lib directories if required
650
651IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
652   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib ${CMAKE_BINARY_DIR}/lib/${OSG_PLUGINS})
653ENDIF()
654
655
656################################################################################
657# Installation stuff
658
659SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
660SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
661SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
662SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
663
664# Set the build postfix extension according to what configuration is being built.
665IF (CMAKE_BUILD_TYPE MATCHES "Release")
666    SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELEASE_POSTFIX}")
667ELSEIF (CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
668    SET(CMAKE_BUILD_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}")
669ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
670    SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}")
671ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug")
672    SET(CMAKE_BUILD_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
673ELSE()
674    SET(CMAKE_BUILD_POSTFIX "")
675ENDIF()
676
677IF(UNIX AND NOT WIN32)
678  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
679  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
680ENDIF()
681
682IF(CYGWIN)
683  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
684  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
685ENDIF()
686
687IF(UNIX AND NOT WIN32 AND NOT APPLE)
688  IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
689      SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
690      MARK_AS_ADVANCED(LIB_POSTFIX)
691  ENDIF()
692ENDIF()
693IF(NOT DEFINED LIB_POSTFIX)
694    SET(LIB_POSTFIX "")
695ENDIF()
696
697# Here we apparantly do some funky stuff with making the bin/ and lib/
698# folders which is probably needed to work around a very old CMake bug?
699
700#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
701SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
702MAKE_DIRECTORY(${OUTPUT_BINDIR})
703IF(MSVC AND NOT MSVC_IDE)
704    MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
705ENDIF(MSVC AND NOT MSVC_IDE)
706
707#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
708SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
709MAKE_DIRECTORY(${OUTPUT_LIBDIR})
710IF(NOT MSVC OR MSVC_IDE)
711    MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
712ENDIF(NOT MSVC OR MSVC_IDE)
713
714# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
715# we work around the DLL placement by use of the PREFIX target property hack
716#
717# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
718# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
719#
720# CMake >= 2.8.1 changed the output directory algorithm (See doc).
721# 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.
722# (Doc reads "multi-configuration generators (VS, Xcode) do NOT append a per-configuration subdirectory to the specified directory").
723# 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.
724IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 5)
725    # If CMake < 2.6.0
726    SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
727    SET(LIBRARY_OUTPUT_PATH    ${OUTPUT_LIBDIR})
728ELSE()
729    # If CMake >= 2.6.0
730    SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
731    SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
732    IF(WIN32)
733        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
734    ELSE(WIN32)
735        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
736    ENDIF(WIN32)
737
738    # Testing CMAKE_VERSION is possible in >= 2.6.4 only
739    BUILDER_VERSION_GREATER(2 8 0)
740    IF(VALID_BUILDER_VERSION)  # If CMake >= 2.8.1
741        FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES})        # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
742            STRING(TOUPPER "${CONF}" CONF)                # Go uppercase (DEBUG, RELEASE...)
743            SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
744            SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
745            IF(WIN32)
746                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
747            ELSE()
748                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
749            ENDIF()
750        ENDFOREACH()
751    ENDIF(VALID_BUILDER_VERSION)
752ENDIF()
753
754#SET(INSTALL_BINDIR OpenSceneGraph/bin)
755#SET(INSTALL_INCDIR OpenSceneGraph/include)
756#SET(INSTALL_LIBDIR OpenSceneGraph/lib)
757#SET(INSTALL_DOCDIR OpenSceneGraph/doc)
758
759################################################################################
760# User Options
761
762
763# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
764# may set these values without needing to manipulate the environment.
765SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
766SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
767# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
768# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
769# A formal feature request has been submited to CMake, Bug #4947.
770# It is intended for those users who have common prefixes for their INCLUDE
771# and LIBRARY locations. So if users have headers in /usr/local/include
772# and libraries in /usr/local/lib, the common prefix is /usr/local.
773# It should also cover the case where headers and libraries are
774# in the same directory.
775# Our proposal expects that FIND_* commands will automatically search for
776# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
777# Obviously, since CMake does not currently support this, we must write
778# our Find*.cmake modules to explicitly support this. Otherwise, this variable
779# will have no impact.
780# This is unofficial so this may be removed or changed at anytime.
781SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
782
783# This is for an advanced option to give aggressive warnings
784# under different compilers. If yours is not implemented, this option
785# will not be made available.
786IF(CMAKE_COMPILER_IS_GNUCXX)
787    # To be complete, we might also do GNUCC flags,
788    # but everything here is C++ code.
789    # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
790    # returns too many hits.
791    # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
792    # interesting C-specific flag.
793    # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
794    # errors instead of warnings for certain issues, including superfluous
795    # semicolons and commas, and the use of long long. -fpermissive seems
796    # to be the workaround.
797    SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive)
798
799    # Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
800
801
802ELSE()
803    IF(MSVC)
804        # FIXME: What are good aggressive warning flags for Visual Studio?
805        # And do we need to further subcase this for different versions of VS?
806        # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
807        SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
808        IF(MSVC11)
809            SET(OSG_AGGRESSIVE_WARNING_FLAGS ${OSG_AGGRESSIVE_WARNING_FLAGS} /wd4250)
810        ENDIF()
811
812    ELSE()
813        # CMake lacks an elseif, so other non-gcc, non-VS compilers need
814        # to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
815        # remain unset.
816    ENDIF()
817ENDIF()
818
819# This part is for the CMake menu option to toggle the warnings on/off.
820# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
821IF(OSG_AGGRESSIVE_WARNING_FLAGS)
822
823    IF (APPLE)
824        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS OFF)
825    ELSE()
826        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS ON)
827    ENDIF()
828
829    OPTION(OSG_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" ${DEFAULT_USE_AGGRESSIVE_WARNINGS})
830    MARK_AS_ADVANCED(OSG_USE_AGGRESSIVE_WARNINGS)
831
832    IF(OSG_USE_AGGRESSIVE_WARNINGS)
833        # Add flags defined by OSG_AGGRESSIVE_WARNING_FLAGS if they aren't already there
834        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
835            IF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}")
836                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
837            ENDIF()
838        ENDFOREACH()
839    ELSE()
840        # Remove all flags considered aggresive
841        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
842            STRING(REGEX REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
843        ENDFOREACH()
844    ENDIF()
845ENDIF()
846
847
848# Dynamic vs Static Linking
849OPTION(DYNAMIC_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking.  Use OFF for static." ON)
850IF   (DYNAMIC_OPENSCENEGRAPH)
851    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
852ELSE ()
853    SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
854ENDIF()
855
856
857# OSG Core
858ADD_SUBDIRECTORY(src)
859
860IF   (BUILD_OSG_APPLICATIONS AND NOT ANDROID)
861    ADD_SUBDIRECTORY(applications)
862ENDIF()
863
864IF   (BUILD_OSG_EXAMPLES)
865    ADD_SUBDIRECTORY(examples)
866ENDIF()
867
868
869IF(APPLE AND NOT ANDROID)
870
871        #Here we check if the user specified IPhone SDK
872    IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
873
874        #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
875        IF(OSG_BUILD_PLATFORM_IPHONE)
876            SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
877            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)
878        ELSE()
879            #simulator uses i386 architectures
880            SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
881            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)
882        ENDIF()
883
884        #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
885        SET(CMAKE_OSX_SYSROOT "${IPHONE_SDKROOT}" CACHE STRING "System root for iOS" FORCE)
886
887        #hack, force link to opengles
888        set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES")
889
890        #use the IPhone windowing system
891        SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Forced IPhone windowing system on iOS"  FORCE)
892        SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for iOS" FORCE)
893
894        #I think this or similar will be required for IPhone apps
895        OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" ON)
896
897    ELSE()
898
899        # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
900        # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
901
902        # These are just defaults/recommendations, but how we want to build
903        # out of the box. But the user needs to be able to change these options.
904        # So we must only set the values the first time CMake is run, or we
905        # will overwrite any changes the user sets.
906        # FORCE is used because the options are not reflected in the UI otherwise.
907        # Seems like a good place to add version specific compiler flags too.
908        IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
909            IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
910                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
911                # 64 Bit Works, i386,ppc is not supported any more
912                SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
913                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)
914            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
915                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
916                # 64 Bit Works, PPC is not supported any more
917                SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
918                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)
919            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
920                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
921                # 64-bit compiles are not supported with Carbon.
922                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
923                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)
924            ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
925                SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
926                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
927                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)
928            ELSE()
929                # No Universal Binary support
930                # Should break down further to set the -mmacosx-version-min,
931                # but the SDK detection is too unreliable here.
932            ENDIF()
933        ENDIF()
934
935        OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
936
937    ENDIF()
938
939ENDIF()
940
941
942# For Doxygen
943INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
944OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make doc_openscenegraph doc_openthreads)" OFF)
945MARK_AS_ADVANCED(CLEAR BUILD_DOCUMENTATION)
946# To build the documention, you will have to enable it
947# and then do the equivalent of "make doc_openscenegraph doc_openthreads".
948IF(BUILD_DOCUMENTATION)
949
950    OPTION(BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF)
951    IF(BUILD_REF_DOCS_SEARCHENGINE)
952        SET(SEARCHENGINE YES)
953    ELSE()
954        SET(SEARCHENGINE NO)
955    ENDIF()
956
957    OPTION(BUILD_REF_DOCS_TAGFILE "Generate a tag file named osg.tag on the documentation web server" OFF)
958    IF(BUILD_REF_DOCS_TAGFILE)
959        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg.tag")
960    ELSE()
961        SET(GENERATE_TAGFILE "")
962    ENDIF()
963
964    IF(DOT)
965        SET(HAVE_DOT YES)
966    ELSE()
967        SET(HAVE_DOT NO)
968    ENDIF()
969
970    # If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
971    SET(GENERATE_HTMLHELP "NO")
972    IF(DOCUMENTATION_HTML_HELP)
973        # 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
974        IF(NOT WIN32)
975            SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
976            MARK_AS_ADVANCED(HTML_HELP_COMPILER)
977        ENDIF()
978        # this var sets a proper value in .doxygen files when configuring them below
979        SET(GENERATE_HTMLHELP "YES")
980    endif()
981
982    # This processes our doxyfile.cmake and substitutes paths to generate
983    # a final Doxyfile
984    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
985        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
986    )
987    # copy the osg logo to documentations target folder
988    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
989        ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg32-32.png COPYONLY
990    )
991    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
992    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs DESTINATION doc COMPONENT openscenegraph-doc)
993
994    # now set up openthreads documentation generation
995    IF(BUILD_REF_DOCS_TAGFILE)
996        SET(GENERATE_TAGFILE "${OpenSceneGraph_BINARY_DIR}/doc/OpenThreadsReferenceDocs/ot.tag")
997    ENDIF()
998
999    # This processes our openthreads.doxyfile.cmake and generate a final doxyfile
1000    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/openthreads.doxyfile.cmake
1001        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
1002    )
1003    # copy the osg logo to documentations target folder
1004    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png
1005        ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs/osg32-32.png COPYONLY
1006    )
1007    #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc)
1008    INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs DESTINATION doc COMPONENT openthreads-doc)
1009
1010    # Process our other doxyfiles but don't create targets for these
1011    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/all_Doxyfile
1012        ${PROJECT_BINARY_DIR}/doc/all_Doxyfile)
1013    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/auto_Doxyfile
1014        ${PROJECT_BINARY_DIR}/doc/auto_Doxyfile)
1015    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/core_Doxyfile
1016        ${PROJECT_BINARY_DIR}/doc/core_Doxyfile)
1017
1018    # This creates a new target to build documentation.
1019    # It runs ${DOXYGEN} which is the full path and executable to
1020    # Doxygen on your system, set by the FindDoxygen.cmake module
1021    # (called by FindDocumentation.cmake).
1022    # It runs the final generated Doxyfile against it.
1023    # The DOT_PATH is substituted into the Doxyfile.
1024    ADD_CUSTOM_TARGET(doc_openscenegraph ${DOXYGEN}
1025        ${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
1026    )
1027    SET_TARGET_PROPERTIES(doc_openscenegraph PROPERTIES FOLDER "Documentation")
1028
1029    ADD_CUSTOM_TARGET(doc_openthreads ${DOXYGEN}
1030        ${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
1031    )
1032    SET_TARGET_PROPERTIES(doc_openthreads PROPERTIES FOLDER "Documentation")
1033ENDIF(BUILD_DOCUMENTATION)
1034
1035OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph" OFF)
1036IF(BUILD_DASHBOARD_REPORTS)
1037# The following are required to uses Dart and the Cdash dashboard
1038# viewable here : http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph
1039    INCLUDE(Dart)
1040ENDIF()
1041
1042# present the packaging option only if we have the cpack command defined (effectively >= 2.6.0)
1043IF(CMAKE_CPACK_COMMAND)
1044    OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
1045    IF(BUILD_OSG_PACKAGES)
1046      INCLUDE(OsgCPack)
1047    ENDIF()
1048ENDIF()
1049
1050# Generate pkg-config configuration files
1051
1052SET(PKGCONFIG_FILES
1053  openscenegraph
1054  openscenegraph-osg
1055  openscenegraph-osgDB
1056  openscenegraph-osgFX
1057  openscenegraph-osgGA
1058  openscenegraph-osgParticle
1059  openscenegraph-osgSim
1060  openscenegraph-osgText
1061  openscenegraph-osgUtil
1062  openscenegraph-osgTerrain
1063  openscenegraph-osgManipulator
1064  openscenegraph-osgViewer
1065  openscenegraph-osgWidget
1066  openscenegraph-osgShadow
1067  openscenegraph-osgAnimation
1068  openscenegraph-osgVolume
1069)
1070
1071IF(QT4_FOUND OR Qt5Widgets_FOUND )
1072  SET(PKGCONFIG_FILES ${PKGCONFIG_FILES} openscenegraph-osgQt)
1073ENDIF()
1074
1075FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES})
1076  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc.in
1077    ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc
1078    @ONLY
1079    )
1080  INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenscenegraph-dev)
1081ENDFOREACH(PKGCONFIG_FILE)
1082
1083
1084# Run this as late as possible so users can easier spot the message
1085IF (NOT DEFINED REQUIRES_LIBPATH_MESSAGE AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")
1086    SET(REQUIRES_LIBPATH_MESSAGE ON)
1087ENDIF()
1088
1089IF(REQUIRES_LIBPATH_MESSAGE)
1090    IF (NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
1091        SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
1092
1093        MESSAGE("\nThe build system is configured to install libraries to ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}\n"
1094            "Your applications may not be able to find your installed libraries unless you:\n"
1095            "    set your LD_LIBRARY_PATH (user specific) or\n"
1096            "    update your ld.so configuration (system wide)")
1097        IF(IS_DIRECTORY /etc/ld.so.conf.d)
1098            MESSAGE("You have an ld.so.conf.d directory on your system, so if you wish to ensure that\n"
1099                "applications find the installed osg libraries, system wide, you could install an\n"
1100                "OpenSceneGraph specific ld.so configuration with:\n"
1101                "    sudo make install_ld_conf\n")
1102            CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in
1103                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
1104            )
1105            ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
1106                ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
1107                /etc/ld.so.conf.d/openscenegraph.conf
1108                COMMAND ldconfig
1109                COMMENT "Copying openscenegraph.conf to /etc/ld.so.conf.d and running ldconfig"
1110            )
1111        ELSE()
1112            IF(EXISTS /etc/ld.so.conf)
1113                MESSAGE("You have an ld.so.conf file in /etc, if you wish to ensure \n"
1114                "that applications find the installed osg libraries, system wide, you\n"
1115                "could add ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX} to it.")
1116            ENDIF()
1117        ENDIF()
1118
1119        # emit a message during installation.
1120        INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}.\\nYou may need to update your ld.so configuration. \")")
1121
1122    ENDIF(NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE)
1123
1124ELSE()
1125    SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 0 CACHE INTERNAL "Flag to track whether the libpath message has been reported before")
1126ENDIF()
1127
1128
1129# This needs to be run very last so other parts of the scripts can take
1130# advantage of this.
1131IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
1132    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")
1133ENDIF()
1134
1135#-----------------------------------------------------------------------------
1136### uninstall target
1137#-----------------------------------------------------------------------------
1138CONFIGURE_FILE(
1139  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
1140  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
1141  IMMEDIATE @ONLY)
1142ADD_CUSTOM_TARGET(uninstall
1143  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
1144
1145#
1146IF(ANDROID)
1147    message(STATUS "Creating Android Makefile Master files" )
1148    configure_file("${OSG_ANDROID_TEMPLATES}/Android.mk.master.in" "${CMAKE_BINARY_DIR}/Android.mk")
1149    configure_file("${OSG_ANDROID_TEMPLATES}/Application.mk.master.in" "${CMAKE_BINARY_DIR}/Application.mk")
1150    configure_file("${OSG_ANDROID_TEMPLATES}/AndroidManifest.xml.master.in" "${CMAKE_BINARY_DIR}/AndroidManifest.xml")
1151ENDIF(ANDROID)
1152
Note: See TracBrowser for help on using the browser.