| 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.4.6 FATAL_ERROR) |
|---|
| 6 |
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7) |
|---|
| 7 |
MESSAGE("Warning: A critical CMake bug exists in 2.4.6 and below. Trying to build Universal Binaries will result in a compile error that seems unrelated. Either avoid building Universal Binaries by changing the CMAKE_OSX_ARCHITECTURES field to list only your architecture, or upgrade to the current CVS version of CMake or a newer stable version if it exists.") |
|---|
| 8 |
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7) |
|---|
| 9 |
ELSE(APPLE) |
|---|
| 10 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR) |
|---|
| 11 |
ENDIF(APPLE) |
|---|
| 12 |
ENDIF(WIN32) |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
PROJECT(VIRTUALPLANETBUILDER) |
|---|
| 16 |
|
|---|
| 17 |
SET(VIRTUALPLANETBUILDER_MAJOR_VERSION 0) |
|---|
| 18 |
SET(VIRTUALPLANETBUILDER_MINOR_VERSION 9) |
|---|
| 19 |
SET(VIRTUALPLANETBUILDER_PATCH_VERSION 1) |
|---|
| 20 |
SET(VIRTUALPLANETBUILDER_SOVERSION 1) |
|---|
| 21 |
|
|---|
| 22 |
SET(VIRTUALPLANETBUILDER_VERSION ${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION}) |
|---|
| 23 |
|
|---|
| 24 |
# We want to build SONAMES shared librariess |
|---|
| 25 |
SET(VIRTUALPLANETBUILDER_SONAMES TRUE) |
|---|
| 26 |
SET(OPENTHREADS_SONAMES TRUE) |
|---|
| 27 |
|
|---|
| 28 |
SET(OpenThreads_SOURCE_DIR ${VIRTUALPLANETBUILDER_SOURCE_DIR}) |
|---|
| 29 |
|
|---|
| 30 |
# We have some custom .cmake scripts not in the official distribution. |
|---|
| 31 |
# Maybe this can be used override existing behavior if needed? |
|---|
| 32 |
SET(CMAKE_MODULE_PATH "${VIRTUALPLANETBUILDER_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
# Okay, here's the problem: On some platforms, linking against OpenThreads |
|---|
| 36 |
# is not enough and explicit linking to the underlying thread library |
|---|
| 37 |
# is also required (e.g. FreeBSD). But OpenThreads may be built with different |
|---|
| 38 |
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying |
|---|
| 39 |
# thread library is because some platforms support multiple backends (e.g. |
|---|
| 40 |
# IRIX supports Sproc and Pthreads). Linking all libraries won't work |
|---|
| 41 |
# because the libraries may be incompatible. |
|---|
| 42 |
# So the current solution is to attempt best guess linking and exempt certain |
|---|
| 43 |
# cases. With IRIX, we're going to hope explicit linking to the underlying |
|---|
| 44 |
# library is not necessary. We currently don't case for pthreads on Windows |
|---|
| 45 |
# which might be an issue on things like Cygwin. This may need to be fixed. |
|---|
| 46 |
FIND_PACKAGE(Threads) |
|---|
| 47 |
IF(CMAKE_SYSTEM MATCHES IRIX) |
|---|
| 48 |
# Erase CMAKE_THREAD_LIBS_INIT and hope it works |
|---|
| 49 |
SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "") |
|---|
| 50 |
ENDIF(CMAKE_SYSTEM MATCHES IRIX) |
|---|
| 51 |
|
|---|
| 52 |
# Find OpenGL |
|---|
| 53 |
FIND_PACKAGE(OpenGL) |
|---|
| 54 |
|
|---|
| 55 |
IF(UNIX) |
|---|
| 56 |
# Not sure what this will do on Cygwin and Msys |
|---|
| 57 |
# Also, remember OS X X11 is a user installed option so it may not exist. |
|---|
| 58 |
FIND_PACKAGE(X11) |
|---|
| 59 |
# Some Unicies need explicit linkage to the Math library or the build fails. |
|---|
| 60 |
FIND_LIBRARY(MATH_LIBRARY m) |
|---|
| 61 |
ENDIF(UNIX) |
|---|
| 62 |
|
|---|
| 63 |
# Make the headers visible to everything |
|---|
| 64 |
INCLUDE_DIRECTORIES( |
|---|
| 65 |
${VIRTUALPLANETBUILDER_SOURCE_DIR}/include |
|---|
| 66 |
${OPENGL_INCLUDE_DIR} |
|---|
| 67 |
) |
|---|
| 68 |
|
|---|
| 69 |
# Common global definitions |
|---|
| 70 |
#ADD_DEFINITIONS(-D) |
|---|
| 71 |
# Platform specific definitions |
|---|
| 72 |
|
|---|
| 73 |
######################################################################################################## |
|---|
| 74 |
##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful |
|---|
| 75 |
######################################################################################################## |
|---|
| 76 |
#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE) |
|---|
| 77 |
#luigi#SET(CMAKE_SKIP_RPATH TRUE) |
|---|
| 78 |
#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE) |
|---|
| 79 |
#luigi#IF(UNIX) |
|---|
| 80 |
#luigi# LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST}) |
|---|
| 81 |
#luigi# IF (contains) |
|---|
| 82 |
#luigi# MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting CMAKE_CXX_COMPILER to g++") |
|---|
| 83 |
#luigi# SET(CMAKE_CXX_COMPILER "g++") |
|---|
| 84 |
#luigi# SET(CMAKE_CXX_COMPILER_LOADED 2) |
|---|
| 85 |
#luigi# SET(CMAKE_CXX_COMPILER_WORKS 2) |
|---|
| 86 |
#luigi# ENDIF (contains) |
|---|
| 87 |
#luigi# SET(CMAKE_CXX_FLAGS_RELEASE "-O2") |
|---|
| 88 |
#luigi# SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs") |
|---|
| 89 |
#luigi#ENDIF(UNIX) |
|---|
| 90 |
######################################################################################################## |
|---|
| 91 |
|
|---|
| 92 |
# Common to all platforms: |
|---|
| 93 |
SET(OSG_DIR "" CACHE PATH "set to base osg install path") |
|---|
| 94 |
|
|---|
| 95 |
SET(CMAKE_DEBUG_POSTFIX "d") |
|---|
| 96 |
|
|---|
| 97 |
FIND_PACKAGE(OSG) |
|---|
| 98 |
FIND_PACKAGE(GDAL) |
|---|
| 99 |
# FIND_PACKAGE(ShapeLib) |
|---|
| 100 |
|
|---|
| 101 |
################################################################################ |
|---|
| 102 |
# Create bin and lib directories if required |
|---|
| 103 |
|
|---|
| 104 |
IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") |
|---|
| 105 |
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib) |
|---|
| 106 |
ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
################################################################################ |
|---|
| 110 |
# Installation stuff |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
IF(UNIX AND NOT WIN32 AND NOT APPLE) |
|---|
| 114 |
IF(CMAKE_SIZEOF_VOID_P MATCHES "8") |
|---|
| 115 |
SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement") |
|---|
| 116 |
MARK_AS_ADVANCED(LIB_POSTFIX) |
|---|
| 117 |
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8") |
|---|
| 118 |
ENDIF(UNIX AND NOT WIN32 AND NOT APPLE) |
|---|
| 119 |
IF(NOT DEFINED LIB_POSTFIX) |
|---|
| 120 |
SET(LIB_POSTFIX "") |
|---|
| 121 |
ENDIF(NOT DEFINED LIB_POSTFIX) |
|---|
| 122 |
|
|---|
| 123 |
#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME}) |
|---|
| 124 |
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin) |
|---|
| 125 |
MAKE_DIRECTORY(${OUTPUT_BINDIR}) |
|---|
| 126 |
SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR}) |
|---|
| 127 |
|
|---|
| 128 |
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}) |
|---|
| 129 |
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib) |
|---|
| 130 |
MAKE_DIRECTORY(${OUTPUT_LIBDIR}) |
|---|
| 131 |
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR}) |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
#SET(INSTALL_BINDIR VIRTUALPLANETBUILDER/bin) |
|---|
| 136 |
#SET(INSTALL_INCDIR VIRTUALPLANETBUILDER/include) |
|---|
| 137 |
#SET(INSTALL_LIBDIR VIRTUALPLANETBUILDER/lib) |
|---|
| 138 |
#SET(INSTALL_DOCDIR VIRTUALPLANETBUILDER/doc) |
|---|
| 139 |
|
|---|
| 140 |
################################################################################ |
|---|
| 141 |
# User Options |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users |
|---|
| 145 |
# may set these values without needing to manipulate the environment. |
|---|
| 146 |
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.") |
|---|
| 147 |
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.") |
|---|
| 148 |
# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced |
|---|
| 149 |
# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH. |
|---|
| 150 |
# A formal feature request has been submited to CMake, Bug #4947. |
|---|
| 151 |
# It is intended for those users who have common prefixes for their INCLUDE |
|---|
| 152 |
# and LIBRARY locations. So if users have headers in /usr/local/include |
|---|
| 153 |
# and libraries in /usr/local/lib, the common prefix is /usr/local. |
|---|
| 154 |
# It should also cover the case where headers and libraries are |
|---|
| 155 |
# in the same directory. |
|---|
| 156 |
# Our proposal expects that FIND_* commands will automatically search for |
|---|
| 157 |
# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH. |
|---|
| 158 |
# Obviously, since CMake does not currently support this, we must write |
|---|
| 159 |
# our Find*.cmake modules to explicitly support this. Otherwise, this variable |
|---|
| 160 |
# will have no impact. |
|---|
| 161 |
# This is unofficial so this may be removed or changed at anytime. |
|---|
| 162 |
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.") |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
# Dynamic vs Static Linking |
|---|
| 166 |
OPTION(DYNAMIC_VIRTUALPLANETBUILDER "Set to ON to build VIRTUALPLANETBUILDER for dynamic linking. Use OFF for static." ON) |
|---|
| 167 |
IF (DYNAMIC_VIRTUALPLANETBUILDER) |
|---|
| 168 |
SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") |
|---|
| 169 |
ELSE (DYNAMIC_VIRTUALPLANETBUILDER) |
|---|
| 170 |
SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") |
|---|
| 171 |
ENDIF(DYNAMIC_VIRTUALPLANETBUILDER) |
|---|
| 172 |
|
|---|
| 173 |
INCLUDE(VpbMacroUtils) |
|---|
| 174 |
|
|---|
| 175 |
# VPB Core |
|---|
| 176 |
ADD_SUBDIRECTORY(src) |
|---|
| 177 |
|
|---|
| 178 |
# VPB Applications |
|---|
| 179 |
OPTION(BUILD_APPLICATIONS "Enable to build VPB Applications (e.g. osgdem)" ON) |
|---|
| 180 |
IF (BUILD_APPLICATIONS) |
|---|
| 181 |
ADD_SUBDIRECTORY(applications) |
|---|
| 182 |
ENDIF(BUILD_APPLICATIONS) |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 |
|---|
| 187 |
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. |
|---|
| 188 |
IF(APPLE) |
|---|
| 189 |
# These are just defaults/recommendations, but how we want to build |
|---|
| 190 |
# out of the box. But the user needs to be able to change these options. |
|---|
| 191 |
# So we must only set the values the first time CMake is run, or we |
|---|
| 192 |
# will overwrite any changes the user sets. |
|---|
| 193 |
# FORCE is used because the options are not reflected in the UI otherwise. |
|---|
| 194 |
# Seems like a good place to add version specific compiler flags too. |
|---|
| 195 |
IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) |
|---|
| 196 |
# This is really fragile, but CMake doesn't provide the OS system |
|---|
| 197 |
# version information we need. (Darwin versions can be changed |
|---|
| 198 |
# independently of OS X versions.) |
|---|
| 199 |
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. |
|---|
| 200 |
IF(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| 201 |
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) |
|---|
| 202 |
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) |
|---|
| 203 |
ELSE(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| 204 |
IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| 205 |
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE) |
|---|
| 206 |
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) |
|---|
| 207 |
ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| 208 |
# No Universal Binary support |
|---|
| 209 |
# Should break down further to set the -mmacosx-version-min, |
|---|
| 210 |
# but the SDK detection is too unreliable here. |
|---|
| 211 |
ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| 212 |
ENDIF(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| 213 |
ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) |
|---|
| 214 |
|
|---|
| 215 |
OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF) |
|---|
| 216 |
|
|---|
| 217 |
ENDIF(APPLE) |
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
# This needs to be run very last so other parts of the scripts can take |
|---|
| 221 |
# advantage of this. |
|---|
| 222 |
IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) |
|---|
| 223 |
SET(VOB_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") |
|---|
| 224 |
ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) |
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
#----------------------------------------------------------------------------- |
|---|
| 228 |
### uninstall target |
|---|
| 229 |
#----------------------------------------------------------------------------- |
|---|
| 230 |
CONFIGURE_FILE( |
|---|
| 231 |
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in" |
|---|
| 232 |
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
|---|
| 233 |
IMMEDIATE @ONLY) |
|---|
| 234 |
ADD_CUSTOM_TARGET(uninstall |
|---|
| 235 |
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
|---|
| 236 |
|
|---|