Changeset 916
- Timestamp:
- 06/06/08 17:58:03
- Files:
-
- trunk/CMakeLists.txt (modified) (9 diffs)
- trunk/CMakeModules/VpbMacroUtils.cmake (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CMakeLists.txt
r914 r916 12 12 ENDIF(WIN32) 13 13 14 if(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 OLD) 22 endif(COMMAND cmake_policy) 14 23 15 24 PROJECT(VIRTUALPLANETBUILDER) … … 34 43 35 44 # Okay, here's the problem: On some platforms, linking against OpenThreads 36 # is not enough and explicit linking to the underlying thread library 45 # is not enough and explicit linking to the underlying thread library 37 46 # 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 47 # backends (Pthreads, Sproc, Windows) so we don't know what the underlying 48 # thread library is because some platforms support multiple backends (e.g. 49 # IRIX supports Sproc and Pthreads). Linking all libraries won't work 41 50 # because the libraries may be incompatible. 42 # So the current solution is to attempt best guess linking and exempt certain 51 # So the current solution is to attempt best guess linking and exempt certain 43 52 # cases. With IRIX, we're going to hope explicit linking to the underlying 44 53 # library is not necessary. We currently don't case for pthreads on Windows … … 47 56 IF(CMAKE_SYSTEM MATCHES IRIX) 48 57 # Erase CMAKE_THREAD_LIBS_INIT and hope it works 49 SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "") 58 SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "") 50 59 ENDIF(CMAKE_SYSTEM MATCHES IRIX) 51 60 … … 60 69 FIND_LIBRARY(MATH_LIBRARY m) 61 70 ENDIF(UNIX) 62 71 63 72 FIND_PACKAGE(CURL) 64 73 … … 69 78 ${OPENGL_INCLUDE_DIR} 70 79 ) 71 80 72 81 # Common global definitions 73 82 #ADD_DEFINITIONS(-D) … … 123 132 SET(LIB_POSTFIX "") 124 133 ENDIF(NOT DEFINED LIB_POSTFIX) 125 134 126 135 #SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME}) 127 136 SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin) … … 168 177 # Automatically detected build options 169 178 EXEC_PROGRAM(osgversion ARGS Matrix::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_MATRIX) 170 IF(OSG_USE_FLOAT_MATRIX MATCHES "float") 179 IF(OSG_USE_FLOAT_MATRIX MATCHES "float") 171 180 ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX) 172 ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float") 181 ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float") 173 182 174 183 EXEC_PROGRAM(osgversion ARGS Plane::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_PLANE) 175 IF(OSG_USE_FLOAT_PLANE MATCHES "float") 184 IF(OSG_USE_FLOAT_PLANE MATCHES "float") 176 185 ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE) 177 ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float") 186 ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float") 178 187 179 188 EXEC_PROGRAM(osgversion ARGS BoundingSphere::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGSPHERE) 180 IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 189 IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 181 190 ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE) 182 ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 191 ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 183 192 184 193 EXEC_PROGRAM(osgversion ARGS BoundingBox::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGBOX) 185 IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 194 IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 186 195 ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX) 187 ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 196 ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 188 197 189 198 … … 209 218 210 219 211 # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 220 # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 212 221 # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. 213 222 IF(APPLE) 214 223 # These are just defaults/recommendations, but how we want to build 215 224 # out of the box. But the user needs to be able to change these options. 216 # So we must only set the values the first time CMake is run, or we 225 # So we must only set the values the first time CMake is run, or we 217 226 # will overwrite any changes the user sets. 218 227 # FORCE is used because the options are not reflected in the UI otherwise. 219 228 # Seems like a good place to add version specific compiler flags too. 220 229 IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) 221 # This is really fragile, but CMake doesn't provide the OS system 222 # version information we need. (Darwin versions can be changed 230 # This is really fragile, but CMake doesn't provide the OS system 231 # version information we need. (Darwin versions can be changed 223 232 # independently of OS X versions.) 224 233 # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. … … 237 246 ENDIF(EXISTS /Developer/SDKs/10.5.sdk) 238 247 ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) 239 248 240 249 OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF) 241 250 242 251 ENDIF(APPLE) 243 252 trunk/CMakeModules/VpbMacroUtils.cmake
r630 r916 6 6 # is intended as a list of variable names each one containing the path of the libraries to link to 7 7 # The existance of a varibale name with _DEBUG appended is tested and, in case it' s value is used 8 # for linking to when in debug mode 8 # for linking to when in debug mode 9 9 # the content of this library for linking when in debugging 10 10 ####################################################################################################### … … 22 22 23 23 MACRO(LINK_INTERNAL TRGTNAME) 24 FOREACH(LINKLIB ${ARGN}) 25 TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") 26 ENDFOREACH(LINKLIB) 24 IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) 25 TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN}) 26 ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) 27 FOREACH(LINKLIB ${ARGN}) 28 TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") 29 ENDFOREACH(LINKLIB) 30 ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) 27 31 ENDMACRO(LINK_INTERNAL TRGTNAME) 28 32 … … 39 43 40 44 MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME) 41 LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES}) 45 LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES}) 42 46 LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY) 43 47 IF(VIRTUALPLANETBUILDER_SONAMES) … … 63 67 # 64 68 # This set up the libraries to link to, it assumes there are two variable: one common for a group of examples or plagins 65 # kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES 66 # they are combined in a single list checked for unicity 69 # kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES 70 # they are combined in a single list checked for unicity 67 71 # the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug 68 72 # 69 # a second variable TARGET_EXTERNAL_LIBRARIES hold the list of libraries not differentiated between debug and optimized 73 # a second variable TARGET_EXTERNAL_LIBRARIES hold the list of libraries not differentiated between debug and optimized 70 74 ################################################################################## 71 75 SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES}) … … 83 87 ENDFOREACH(LINKLIB) 84 88 85 FOREACH(LINKLIB ${TARGET_LIBRARIES}) 86 TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") 87 ENDFOREACH(LINKLIB) 89 # FOREACH(LINKLIB ${TARGET_LIBRARIES}) 90 # TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") 91 # ENDFOREACH(LINKLIB) 92 LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES}) 88 93 89 94 FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES}) … … 113 118 SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}") 114 119 ENDIF(NOT TARGET_LABEL) 115 116 # here we use the command to generate the library 120 121 # here we use the command to generate the library 117 122 118 123 IF (DYNAMIC_VIRTUALPLANETBUILDER) … … 121 126 ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H}) 122 127 ENDIF(DYNAMIC_VIRTUALPLANETBUILDER) 123 128 124 129 #not sure if needed, but for plugins only msvc need the d suffix 125 130 IF(NOT MSVC) … … 127 132 ENDIF(NOT MSVC) 128 133 SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") 129 134 130 135 SETUP_LINK_LIBRARIES() 131 136 … … 153 158 154 159 IF(${IS_COMMANDLINE_APP}) 155 160 156 161 ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H}) 157 162 158 163 ELSE(${IS_COMMANDLINE_APP}) 159 164 160 165 IF(APPLE) 161 166 # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION}") … … 185 190 186 191 ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H}) 187 192 188 193 ENDIF(${IS_COMMANDLINE_APP}) 189 194 SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") 190 195 SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) 191 196 SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME}) 192 193 SETUP_LINK_LIBRARIES() 197 198 SETUP_LINK_LIBRARIES() 194 199 195 200 ENDMACRO(SETUP_EXE) … … 205 210 SET(IS_COMMANDLINE_APP 0) 206 211 ENDIF(${ARGC} GREATER 1) 207 212 208 213 SETUP_EXE(${IS_COMMANDLINE_APP}) 209 214 210 215 INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ) 211 216 … … 228 233 SET(IS_COMMANDLINE_APP 0) 229 234 ENDIF(${ARGC} GREATER 1) 230 235 231 236 SETUP_EXE(${IS_COMMANDLINE_APP}) 232 233 INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin ) 237 238 INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin ) 234 239 235 240 ENDMACRO(SETUP_EXAMPLE)
