Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
sandbox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox

  • 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
Note: See TracChangeset for help on using the changeset viewer.