Changeset 916

Show
Ignore:
Timestamp:
06/06/08 17:58:03
Author:
robert
Message:

From Jean-Sebastien Guay, changes to support of CMake 2.6.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CMakeLists.txt

    r914 r916  
    1212ENDIF(WIN32) 
    1313 
     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 OLD) 
     22endif(COMMAND cmake_policy) 
    1423 
    1524PROJECT(VIRTUALPLANETBUILDER) 
     
    3443 
    3544# 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 
    3746# 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 
    4150# 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 
    4352# cases. With IRIX, we're going to hope explicit linking to the underlying 
    4453# library is not necessary. We currently don't case for pthreads on Windows 
     
    4756IF(CMAKE_SYSTEM MATCHES IRIX) 
    4857    # 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 "") 
    5059ENDIF(CMAKE_SYSTEM MATCHES IRIX) 
    5160 
     
    6069    FIND_LIBRARY(MATH_LIBRARY m) 
    6170ENDIF(UNIX) 
    62      
     71 
    6372FIND_PACKAGE(CURL) 
    6473 
     
    6978    ${OPENGL_INCLUDE_DIR} 
    7079) 
    71      
     80 
    7281# Common global definitions 
    7382#ADD_DEFINITIONS(-D) 
     
    123132    SET(LIB_POSTFIX "") 
    124133ENDIF(NOT DEFINED LIB_POSTFIX) 
    125      
     134 
    126135#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME}) 
    127136SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin) 
     
    168177# Automatically detected build options 
    169178EXEC_PROGRAM(osgversion ARGS Matrix::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_MATRIX) 
    170 IF(OSG_USE_FLOAT_MATRIX MATCHES "float")         
     179IF(OSG_USE_FLOAT_MATRIX MATCHES "float") 
    171180    ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX) 
    172 ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float")         
     181ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float") 
    173182 
    174183EXEC_PROGRAM(osgversion ARGS Plane::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_PLANE) 
    175 IF(OSG_USE_FLOAT_PLANE MATCHES "float")         
     184IF(OSG_USE_FLOAT_PLANE MATCHES "float") 
    176185    ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE) 
    177 ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float")         
     186ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float") 
    178187 
    179188EXEC_PROGRAM(osgversion ARGS BoundingSphere::value_type  OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGSPHERE) 
    180 IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double")         
     189IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 
    181190    ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE) 
    182 ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double")         
     191ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") 
    183192 
    184193EXEC_PROGRAM(osgversion ARGS BoundingBox::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGBOX) 
    185 IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double")         
     194IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 
    186195    ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX) 
    187 ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double")         
     196ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") 
    188197 
    189198 
     
    209218 
    210219 
    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 
    212221# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. 
    213222IF(APPLE) 
    214223    # These are just defaults/recommendations, but how we want to build 
    215224    # 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 
    217226    # will overwrite any changes the user sets. 
    218227    # FORCE is used because the options are not reflected in the UI otherwise. 
    219228    # Seems like a good place to add version specific compiler flags too. 
    220229    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 
    223232        # independently of OS X versions.) 
    224233        # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. 
     
    237246        ENDIF(EXISTS /Developer/SDKs/10.5.sdk) 
    238247    ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE) 
    239      
     248 
    240249    OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF) 
    241      
     250 
    242251ENDIF(APPLE) 
    243252 
  • trunk/CMakeModules/VpbMacroUtils.cmake

    r630 r916  
    66#  is intended as a list of variable names each one containing  the path of the libraries to link to 
    77#  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 
    99#  the content of this library for linking when in debugging 
    1010####################################################################################################### 
     
    2222 
    2323MACRO(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) 
    2731ENDMACRO(LINK_INTERNAL TRGTNAME) 
    2832 
     
    3943 
    4044MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME) 
    41     LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES})  
     45    LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES}) 
    4246    LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY) 
    4347    IF(VIRTUALPLANETBUILDER_SONAMES) 
     
    6367    # 
    6468    # 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 
    6771    # the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug 
    6872    # 
    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 
    7074    ################################################################################## 
    7175    SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES}) 
     
    8387    ENDFOREACH(LINKLIB) 
    8488 
    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}) 
    8893 
    8994    FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES}) 
     
    113118            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}") 
    114119    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 
    117122 
    118123    IF   (DYNAMIC_VIRTUALPLANETBUILDER) 
     
    121126        ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H}) 
    122127    ENDIF(DYNAMIC_VIRTUALPLANETBUILDER) 
    123      
     128 
    124129    #not sure if needed, but for plugins only msvc need the d suffix 
    125130    IF(NOT MSVC) 
     
    127132    ENDIF(NOT MSVC) 
    128133    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") 
    129   
     134 
    130135    SETUP_LINK_LIBRARIES() 
    131136 
     
    153158 
    154159    IF(${IS_COMMANDLINE_APP}) 
    155      
     160 
    156161        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H}) 
    157          
     162 
    158163    ELSE(${IS_COMMANDLINE_APP}) 
    159      
     164 
    160165        IF(APPLE) 
    161166            # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION}") 
     
    185190 
    186191        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H}) 
    187          
     192 
    188193    ENDIF(${IS_COMMANDLINE_APP}) 
    189194    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") 
    190195    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) 
    191196    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME}) 
    192      
    193     SETUP_LINK_LIBRARIES()     
     197 
     198    SETUP_LINK_LIBRARIES() 
    194199 
    195200ENDMACRO(SETUP_EXE) 
     
    205210            SET(IS_COMMANDLINE_APP 0) 
    206211        ENDIF(${ARGC} GREATER 1) 
    207              
     212 
    208213        SETUP_EXE(${IS_COMMANDLINE_APP}) 
    209          
     214 
    210215    INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin  ) 
    211216 
     
    228233            SET(IS_COMMANDLINE_APP 0) 
    229234        ENDIF(${ARGC} GREATER 1) 
    230              
     235 
    231236        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  ) 
    234239 
    235240ENDMACRO(SETUP_EXAMPLE)