Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7818 for code/trunk/cmake


Ignore:
Timestamp:
Dec 26, 2010, 9:07:43 PM (13 years ago)
Author:
rgrieder
Message:

Merged changes related to Visual Leak Detector and source file handling from sandbox QT to trunk.

Location:
code/trunk/cmake
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/cmake/CompilerConfigMSVC.cmake

    r7810 r7818  
    3535
    3636######################## Options ########################
    37 
    38 # Currently VLD has a problem with MSVC9 although it actually is supported
    39 IF(MSVC80)
    40   OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
    41 ENDIF()
    42 # Make sure the value is "on" or "off" for vld.ini
    43 IF(VISUAL_LEAK_DETECTOR_ENABLE)
    44   SET(VISUAL_LEAK_DETECTOR_ENABLE on)
    45 ELSE()
    46   SET(VISUAL_LEAK_DETECTOR_ENABLE off)
    47 ENDIF()
    4837
    4938# Orxonox only supports MSVC 8 and above, which gets asserted above
     
    159148IF(ORXONOX_RELEASE)
    160149  ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF -LTCG" ReleaseAll   CACHE)
     150  # Static linker flags have to be added manually to a target
     151  SET(ORXONOX_STATIC_LINKER_FLAGS "/LTCG")
    161152ELSE()
    162153  ADD_LINKER_FLAGS("-INCREMENTAL:YES"                  RelWithDebInfo     CACHE)
  • code/trunk/cmake/PackageConfigMSVC.cmake

    r5781 r7818  
    5757  SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib  CACHE FILEPATH "")
    5858
    59   # Visual Leak Detector
    60   SET(VLD_INCLUDE_DIR  ${DEP_INCLUDE_DIR}/vld   CACHE PATH "")
    61   SET(VLD_LIBRARY_DIR  ${DEP_LIBRARY_DIR}       CACHE PATH "")
    62   LINK_DIRECTORIES(${VLD_LIBRARY_DIR}) # Used for auto-linking
    63   MARK_AS_ADVANCED(VLD_INCLUDE_DIR VLD_LIBRARY_DIR)
    64 
    6559ENDIF(MSVC)
  • code/trunk/cmake/tools/SourceFileUtilities.cmake

    r7415 r7818  
    3434
    3535FUNCTION(PREPARE_SOURCE_FILES)
    36   SET(_fullpath_sources)
     36  SET(_source_files)
    3737  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 ${_compilation_file})
    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         # 2nd Note: Exploiting this results in a strange separation of the compilation
    65         # file, causing the compiler not to use multi processing --> slower compiling.
    66         #IF(MSVC)
    67         #    SET_SOURCE_FILES_PROPERTIES(${_compilation_file} PROPERTIES COMPILE_FLAGS "-Zm1000")
    68         #ENDIF()
    69       ENDIF()
    70       SET(_compilation_name)
    71       SET(_compilation)
    72       SET(_compile FALSE)
     38    IF(_file MATCHES "^(COMPILATION_BEGIN|COMPILATION_END)$")
     39      # Append keywords verbatim
     40      LIST(APPEND _source_files ${_file})
    7341    ELSE()
    74       # Prefix the full path
    75       GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
    76       LIST(APPEND _fullpath_sources ${_filepath})
    77       IF(_compile AND NOT DISABLE_COMPILATIONS)
    78         LIST(APPEND _compilation ${_filepath})
    79         LIST(APPEND _fullpath_sources "H")
    80       ENDIF()
     42      # Store file with path relative to the root source directory
     43      FILE(RELATIVE_PATH _file_rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
     44      LIST(APPEND _source_files ./${_file_rel})
    8145    ENDIF()
    8246  ENDFOREACH(_file)
    83   SET(_fullpath_sources ${_fullpath_sources} PARENT_SCOPE)
     47  SET(_source_files ${_source_files} PARENT_SCOPE)
    8448ENDFUNCTION(PREPARE_SOURCE_FILES)
    8549
     
    8953  PREPARE_SOURCE_FILES(${ARGN})
    9054  # Write into the cache to avoid variable scoping in subdirs
    91   SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     55  SET(${_varname} ${${_varname}} ${_source_files} CACHE INTERNAL "Do not edit")
    9256ENDFUNCTION(ADD_SOURCE_FILES)
    9357
     
    9761  PREPARE_SOURCE_FILES(${ARGN})
    9862  # Write into the cache to avoid variable scoping in subdirs
    99   SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     63  SET(${_varname} ${_source_files} CACHE INTERNAL "Do not edit")
    10064ENDFUNCTION(SET_SOURCE_FILES)
    10165
     
    11377    GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
    11478    FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
    115     IF(NOT _relative_path MATCHES "^\\.\\.")
     79    IF(NOT _relative_path MATCHES "^\\.\\./") # Has "../" at the beginning
    11680      GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
    11781      STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
  • code/trunk/cmake/tools/TargetUtilities.cmake

    r7416 r7818  
    9090  PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
    9191
    92 
    93   # Workaround: Source file properties get lost when leaving a subdirectory
    94   # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY
     92  # Process source files with support for compilations
     93  # Note: All file paths are relative to the root source directory, even the
     94  #       name of the compilation file.
     95  SET(_${_target_name}_source_files)
     96  SET(_get_compilation_file FALSE)
     97  SET(_add_to_compilation FALSE)
    9598  FOREACH(_file ${_arg_SOURCE_FILES})
    96     IF(_file STREQUAL "H")
    97       SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     99    IF(_file STREQUAL "COMPILATION_BEGIN")
     100      # Next file is the name of the compilation
     101      SET(_get_compilation_file TRUE)
     102    ELSEIF(_file STREQUAL "COMPILATION_END")
     103      IF(NOT _compilation_file)
     104        MESSAGE(FATAL_ERROR "No name provided for source file compilation")
     105      ENDIF()
     106      IF(NOT _compilation_include_string)
     107        MESSAGE(STATUS "Warning: Empty source file compilation!")
     108      ENDIF()
     109      IF(NOT DISABLE_COMPILATIONS)
     110        IF(EXISTS ${_compilation_file})
     111          FILE(READ ${_compilation_file} _include_string_file)
     112        ENDIF()
     113        IF(NOT _compilation_include_string STREQUAL "${_include_string_file}")
     114          FILE(WRITE ${_compilation_file} "${_compilation_include_string}")
     115        ENDIF()
     116        LIST(APPEND _${_target_name}_source_files ${_compilation_file})
     117      ENDIF()
     118      SET(_add_to_compilation FALSE)
     119    ELSEIF(_get_compilation_file)
     120      SET(_compilation_file ${CMAKE_BINARY_DIR}/${_file})
     121      SET(_get_compilation_file FALSE)
     122      SET(_add_to_compilation TRUE)
     123      SET(_compilation_include_string)
    98124    ELSE()
    99       SET(_last_file ${_file})
     125      # Default, add source file
     126
     127      # Prepare relative paths
     128      IF(NOT _file MATCHES "^(.\\:|\\/)")
     129        # Path can be relative to the current source directory if the file was
     130        # not added with the source file macros. Otherwise there is a "./" at
     131        # the beginning of each file and the filename is relative
     132        # to the CMAKE_SOURCE_DIR
     133        STRING(REGEX REPLACE "^\\.\\/(.+)$" "\\1" _temp ${_file})
     134        IF(NOT ${_temp} STREQUAL ${_file})
     135          SET(_file ${CMAKE_SOURCE_DIR}/${_temp})
     136        ELSE()
     137          SET(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
     138        ENDIF()
     139      ENDIF()
     140
    100141      LIST(APPEND _${_target_name}_source_files ${_file})
     142
     143      # Handle compilations
     144      IF(_add_to_compilation AND NOT DISABLE_COMPILATIONS)
     145        IF(_file MATCHES "\\.(c|cc|cpp|cxx)$")
     146          SET(_compilation_include_string "${_compilation_include_string}#include \"${_file}\"\n")
     147        ENDIF()
     148        # Don't compile these files, even if they are source files
     149        SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     150      ENDIF()
    101151    ENDIF()
    102152  ENDFOREACH(_file)
     
    172222  # Don't compile header files
    173223  FOREACH(_file ${_${_target_name}_files})
    174     IF(NOT _file MATCHES "\\.(c|cc|cpp)")
     224    IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx)$")
    175225      SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
    176226    ENDIF()
     
    217267    # Ensure that the main program depends on the module
    218268    SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE STRING "" FORCE)
     269  ENDIF()
     270
     271  # Static library flags are not globally available
     272  IF(ORXONOX_STATIC_LINKER_FLAGS)
     273    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES STATIC_LIBRARY_FLAGS ${ORXONOX_STATIC_LINKER_FLAGS})
    219274  ENDIF()
    220275
Note: See TracChangeset for help on using the changeset viewer.