Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6038 for sandbox/cmake


Ignore:
Timestamp:
Nov 5, 2009, 9:22:22 PM (15 years ago)
Author:
rgrieder
Message:

Synchronised sandbox with current code trunk. There should be a few bug fixes.

Location:
sandbox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sandbox

  • sandbox/cmake/CompilerConfigMSVC.cmake

    r5695 r6038  
    7070
    7171# Overwrite CMake default flags here.
    72 SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -Gm -RTC1" Debug          CACHE)
    73 SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE)
    74 SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"      RelWithDebInfo CACHE)
    75 SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE)
     72SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -MP2 -RTC1" Debug          CACHE)
     73SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"       Release        CACHE)
     74SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"       RelWithDebInfo CACHE)
     75SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"       MinSizeRel     CACHE)
    7676
    7777# Use Link time code generation for Release config if ORXONOX_RELEASE is defined
  • sandbox/cmake/LibraryConfig.cmake

    r5782 r6038  
    8989##### Boost #####
    9090# Expand the next statement if newer boost versions than 1.36.1 are released
    91 SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0)
     91SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0)
    9292FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
    9393# No auto linking, so this option is useless anyway
  • sandbox/cmake/PackageConfig.cmake

    r5782 r6038  
    2626
    2727# Check package version info
    28 # MAJOR: Interface breaking change somewhere (library version changed, etc.)
    29 # MINOR: Bug fix or small conformant changes
    30 SET(DEPENDENCY_VERSION_REQUIRED 3)
     28# MAJOR: Breaking change
     29# MINOR: No breaking changes by the dependency package
     30#        For example any code running on 3.0 should still run on 3.1
     31#        But you can specify that the code only runs on 3.1 and higher
     32#        or 4.0 and higher (so both 3.1 and 4.0 will work).
     33SET(ALLOWED_MINIMUM_VERSIONS 3.1 4.0)
     34
    3135IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
    3236  SET(DEPENDENCY_VERSION 1.0)
     
    4448
    4549INCLUDE(CompareVersionStrings)
    46 COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${DEPENDENCY_VERSION_REQUIRED} _result TRUE)
    47 IF(NOT _result EQUAL 0)
     50SET(_version_match FALSE)
     51FOREACH(_version ${ALLOWED_MINIMUM_VERSIONS})
     52  # Get major version
     53  STRING(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _major_version "${_version}")
     54  COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_major_version} _result TRUE)
     55  IF(_result EQUAL 0)
     56    COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_version} _result FALSE)
     57    IF(NOT _result LESS 0)
     58      SET(_version_match TRUE)
     59    ENDIF()
     60  ENDIF()
     61ENDFOREACH(_version)
     62IF(NOT _version_match)
    4863  MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
    49           "Required version: ${DEPENDENCY_VERSION_REQUIRED}\n"
    50           "You can get a new version from www.orxonox.net")
     64          "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n"
     65          "You can get a new version from www.orxonox.net")
    5166ENDIF()
    5267
  • sandbox/cmake/ParseMacroArguments.cmake

    r5695 r6038  
    3939  # Using LIST(FIND ...) speeds up the process
    4040  SET(_keywords ${_switches} ${_list_names})
     41
     42  # Reset all arguments
     43  FOREACH(_arg ${_switches} ${_list_names})
     44    SET(_arg_${_arg})
     45  ENDFOREACH(_arg)
    4146
    4247  # Parse all the arguments and set the corresponding variable
  • sandbox/cmake/PrecompiledHeaderFiles.cmake

    r3251 r6038  
    110110    GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
    111111    # Make sure we recompile the pch file even if only the flags change
    112     IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}")
     112    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}" OR NOT EXISTS "${_pch_dep_helper_file}")
    113113      SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
    114114      FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
  • sandbox/cmake/SourceFileUtilities.cmake

    r2710 r6038  
    2424 #    [ADD/SET]_SOURCE_FILES - Writes source files to the cache by force and
    2525 #                             adds the current directory.
    26  #    GET_ALL_HEADER_FILES - Finds all header files recursively.
     26 #                             Also compiles multiple source files into a single
     27 #                             one by including them
     28 #                             Use COMPILATION_[BEGIN|END] in
     29 #                             [ADD|SET]_SOURCE_FILES and specify the name of
     30 #                             the new source file after COMPILATION_BEGIN
     31 #    GET_ALL_HEADER_FILES   - Finds all header files recursively.
    2732 #    GENERATE_SOURCE_GROUPS - Set Visual Studio source groups.
    2833 #
    2934
     35FUNCTION(PREPARE_SOURCE_FILES)
     36  SET(_fullpath_sources)
     37  FOREACH(_file ${ARGN})
     38    IF(_file STREQUAL "COMPILATION_BEGIN")
     39      SET(_compile TRUE)
     40      # Next file is the name of the compilation
     41      SET(_get_name TRUE)
     42    ELSEIF(_get_name)
     43      SET(_get_name FALSE)
     44      SET(_compilation_name ${_file})
     45    ELSEIF(_file STREQUAL "COMPILATION_END")
     46      IF(NOT _compilation_name)
     47        MESSAGE(FATAL_ERROR "No name provided for source file compilation")
     48      ENDIF()
     49      IF(NOT DISABLE_COMPILATIONS)
     50        SET(_compilation_file ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name})
     51        SET(_include_string)
     52        FOREACH(_file2 ${_compilation})
     53          SET(_include_string "${_include_string}#include \"${_file2}\"\n")
     54        ENDFOREACH(_file2)
     55        IF(EXISTS )
     56          FILE(READ ${_compilation_file} _include_string_file)
     57        ENDIF()
     58        IF(NOT _include_string STREQUAL "${_include_string_file}")
     59          FILE(WRITE ${_compilation_file} "${_include_string}")
     60        ENDIF()
     61        LIST(APPEND _fullpath_sources ${_compilation_file})
     62        # MSVC hack that excludes the compilations from the intellisense database
     63        # (There is a bug with the "-" instead of "/". Only works for "Zm#" argument)
     64        IF(MSVC)
     65          SET_SOURCE_FILES_PROPERTIES(${_compilation_file} PROPERTIES COMPILE_FLAGS "-Zm1000")
     66        ENDIF()
     67      ENDIF()
     68      SET(_compilation_name)
     69      SET(_compilation)
     70      SET(_compile FALSE)
     71    ELSE()
     72      # Prefix the full path
     73      GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
     74      LIST(APPEND _fullpath_sources ${_filepath})
     75      IF(_compile AND NOT DISABLE_COMPILATIONS)
     76        LIST(APPEND _compilation ${_filepath})
     77        LIST(APPEND _fullpath_sources "H")
     78      ENDIF()
     79    ENDIF()
     80  ENDFOREACH(_file)
     81  SET(_fullpath_sources ${_fullpath_sources} PARENT_SCOPE)
     82ENDFUNCTION(PREPARE_SOURCE_FILES)
     83
     84
    3085# Adds source files with the full path to a list
    3186FUNCTION(ADD_SOURCE_FILES _varname)
    32   # Prefix the full path
    33   SET(_fullpath_sources)
    34   FOREACH(_file ${ARGN})
    35     GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
    36     LIST(APPEND _fullpath_sources ${_filepath})
    37   ENDFOREACH(_file)
     87  PREPARE_SOURCE_FILES(${ARGN})
    3888  # Write into the cache to avoid variable scoping in subdirs
    3989  SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     
    4393# Sets source files with the full path
    4494FUNCTION(SET_SOURCE_FILES _varname)
    45   # Prefix the full path
    46   SET(_fullpath_sources)
    47   FOREACH(_file ${ARGN})
    48     GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
    49     LIST(APPEND _fullpath_sources ${_filepath})
    50   ENDFOREACH(_file)
     95  PREPARE_SOURCE_FILES(${ARGN})
    5196  # Write into the cache to avoid variable scoping in subdirs
    5297  SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     
    66111    GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
    67112    FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
    68     GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
    69     STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
    70     SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
     113    IF(NOT _relative_path MATCHES "^\\.\\.")
     114      GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
     115      STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
     116      SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
     117    ELSE()
     118      # Has to be a compilation
     119      SOURCE_GROUP("Compilations" FILES ${_file})
     120    ENDIF()
    71121  ENDFOREACH(_file)
    72122
  • sandbox/cmake/TargetUtilities.cmake

    r5695 r6038  
    6767ENDIF()
    6868
    69 FUNCTION(ORXONOX_ADD_LIBRARY _target_name)
     69MACRO(ORXONOX_ADD_LIBRARY _target_name)
    7070  TU_ADD_TARGET(${_target_name} LIBRARY "STATIC;SHARED" ${ARGN})
    71 ENDFUNCTION(ORXONOX_ADD_LIBRARY)
    72 
    73 FUNCTION(ORXONOX_ADD_EXECUTABLE _target_name)
     71ENDMACRO(ORXONOX_ADD_LIBRARY)
     72
     73MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
    7474  TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
    75 ENDFUNCTION(ORXONOX_ADD_EXECUTABLE)
    76 
    77 
    78 FUNCTION(TU_ADD_TARGET _target_name _target_type _additional_switches)
     75ENDMACRO(ORXONOX_ADD_EXECUTABLE)
     76
     77
     78MACRO(TU_ADD_TARGET _target_name _target_type _additional_switches)
    7979  CAPITALISE_NAME(${_target_name} _target_name_capitalised)
    8080
     
    8888
    8989
    90   # GET_HEADER_FILES
     90  # Workaround: Source file properties get lost when leaving a subdirectory
     91  # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY
     92  FOREACH(_file ${_arg_SOURCE_FILES})
     93    IF(_file STREQUAL "H")
     94      SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     95    ELSE()
     96      SET(_last_file ${_file})
     97      LIST(APPEND _${_target_name}_source_files ${_file})
     98    ENDIF()
     99  ENDFOREACH(_file)
     100
     101  # Assemble all header files of the library
    91102  IF(_arg_FIND_HEADER_FILES)
    92     GET_ALL_HEADER_FILES(_${target_name}_header_files)
     103    GET_ALL_HEADER_FILES(_${_target_name}_header_files)
    93104  ENDIF()
    94105
    95106  # Remove potential duplicates
    96   SET(_${_target_name}_files ${_${target_name}_header_files} ${_arg_SOURCE_FILES})
     107  SET(_${_target_name}_files ${_${_target_name}_header_files} ${_${_target_name}_source_files})
    97108  LIST(REMOVE_DUPLICATES _${_target_name}_files)
    98109
     
    141152  ENDIF()
    142153
     154  # No warnings needed from third party libraries
     155  IF(_arg_ORXONOX_EXTERNAL)
     156    REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
     157    ADD_COMPILER_FLAGS("-w")
     158  ENDIF()
     159
    143160  # Set default linking if required
    144161  IF(NOT _arg_SHARED AND NOT _arg_STATIC)
     
    156173    SET(_arg_STATIC)
    157174  ENDIF()
     175
     176  # Don't compile header files
     177  FOREACH(_file ${_${_target_name}_files})
     178    IF(NOT _file MATCHES "\\.(c|cc|cpp)")
     179      SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     180    ENDIF()
     181  ENDFOREACH(_file)
     182
     183
    158184
    159185  # Add the library/executable
     
    164190    ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL}
    165191                   ${_${_target_name}_files})
     192  ENDIF()
     193
     194
     195
     196  # Change library prefix to "lib"
     197  IF(MSVC AND ${_target_type} STREQUAL "LIBRARY")
     198    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
     199      PREFIX "lib"
     200    )
     201  ENDIF()
     202
     203  # MSVC hack to exclude external library sources from the intellisense database
     204  # (IntelliSense stops working when adding "-Zm1000" as compile flag. "/Zm1000"
     205  # would not work because of the slash)
     206  IF(_arg_ORXONOX_EXTERNAL AND MSVC)
     207    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES COMPILE_FLAGS "-Zm1000")
    166208  ENDIF()
    167209
     
    216258  ENDIF()
    217259
    218 ENDFUNCTION(TU_ADD_TARGET)
     260ENDMACRO(TU_ADD_TARGET)
    219261
    220262
Note: See TracChangeset for help on using the changeset viewer.