root/OpenSceneGraph/trunk/CMakeLists.txt @ 13467

Revision 13467, 48.1 kB (checked in by robert, 2 hours ago)

Improved handling of ComboBox? popup toggling

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