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