Changeset 8729 for code/trunk/cmake/tools/TargetUtilities.cmake
- Timestamp:
- Jul 4, 2011, 2:47:44 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/cmake/tools/TargetUtilities.cmake
r8421 r8729 40 40 # NO_INSTALL: Do not install the target at all 41 41 # NO_VERSION: Prevents adding any version to a target 42 # NO_BUILD_UNITS: Disables automatic (full) build units 42 43 # 43 44 # Lists: … … 54 55 # PCH_EXCLUDE: Source files to be excluded from PCH support 55 56 # OUTPUT_NAME: If you want a different name than the target name 57 # EXCLUDE_FROM_BUILD_UNITS: Specifies files that are not put into 58 # automatic (full) build units. They can still 59 # explicitely be included in a BUILD_UNIT (partial) 56 60 # Note: 57 61 # This function also installs the target! … … 62 66 # 63 67 68 INCLUDE(BuildUnits) 64 69 INCLUDE(CMakeDependentOption) 65 70 INCLUDE(CapitaliseName) … … 87 92 SET(_switches FIND_HEADER_FILES EXCLUDE_FROM_ALL ORXONOX_EXTERNAL 88 93 NO_DLL_INTERFACE NO_SOURCE_GROUPS PCH_NO_DEFAULT 89 NO_INSTALL NO_VERSION ${_additional_switches}) 94 NO_INSTALL NO_VERSION NO_BUILD_UNITS 95 ${_additional_switches}) 90 96 SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES 91 97 DEFINE_SYMBOL TOLUA_FILES PCH_FILE 92 98 PCH_EXCLUDE OUTPUT_NAME LINK_LIBS_LINUX 93 LINK_LIBS_WIN32 LINK_LIBS_APPLE LINK_LIBS_UNIX) 99 LINK_LIBS_WIN32 LINK_LIBS_APPLE LINK_LIBS_UNIX 100 EXCLUDE_FROM_BUILD_UNITS) 94 101 95 102 PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN}) 96 103 97 # Process source files with support for compilations104 # Process source files with support for build units 98 105 # Note: All file paths are relative to the root source directory, even the 99 # name of the compilation file.106 # name of the build unit. 100 107 SET(_${_target_name}_source_files) 101 SET(_get_ compilation_file FALSE)102 SET(_add_to_ compilationFALSE)108 SET(_get_build_unit_file FALSE) 109 SET(_add_to_build_unit FALSE) 103 110 FOREACH(_file ${_arg_SOURCE_FILES}) 104 IF(_file STREQUAL "COMPILATION_BEGIN") 105 # Next file is the name of the compilation 106 SET(_get_compilation_file TRUE) 107 ELSEIF(_file STREQUAL "COMPILATION_END") 108 IF(NOT _compilation_file) 109 MESSAGE(FATAL_ERROR "No name provided for source file compilation") 110 ENDIF() 111 IF(NOT DISABLE_COMPILATIONS) 112 IF(NOT _compilation_include_string) 113 MESSAGE(STATUS "Warning: Empty source file compilation!") 114 ENDIF() 115 IF(EXISTS ${_compilation_file}) 116 FILE(READ ${_compilation_file} _include_string_file) 117 ENDIF() 118 IF(NOT _compilation_include_string STREQUAL "${_include_string_file}") 119 FILE(WRITE ${_compilation_file} "${_compilation_include_string}") 120 ENDIF() 121 LIST(APPEND _${_target_name}_source_files ${_compilation_file}) 122 ENDIF() 123 SET(_add_to_compilation FALSE) 124 ELSEIF(_get_compilation_file) 125 SET(_compilation_file ${CMAKE_BINARY_DIR}/${_file}) 126 SET(_get_compilation_file FALSE) 127 SET(_add_to_compilation TRUE) 128 SET(_compilation_include_string) 111 IF(_file STREQUAL "BUILD_UNIT") 112 # Next file is the name of the build unit 113 SET(_get_build_unit_file TRUE) 114 ELSEIF(_file STREQUAL "END_BUILD_UNIT") 115 IF(NOT _build_unit_file) 116 MESSAGE(FATAL_ERROR "No name provided for build unit") 117 ENDIF() 118 IF(ENABLE_BUILD_UNITS) 119 IF(NOT _build_unit_include_string) 120 MESSAGE(STATUS "Warning: Empty build unit!") 121 ENDIF() 122 IF(EXISTS ${_build_unit_file}) 123 FILE(READ ${_build_unit_file} _include_string_file) 124 ENDIF() 125 IF(NOT _build_unit_include_string STREQUAL "${_include_string_file}") 126 FILE(WRITE ${_build_unit_file} "${_build_unit_include_string}") 127 ENDIF() 128 LIST(APPEND _${_target_name}_source_files ${_build_unit_file}) 129 LIST(APPEND _${_target_name}_build_units ${_build_unit_file}) 130 # Store the number of files included. May be used for full build units. 131 SET_SOURCE_FILES_PROPERTIES(${_build_unit_file} 132 PROPERTIES BUILD_UNIT_SIZE "${_build_unit_count}") 133 ENDIF() 134 SET(_add_to_build_unit FALSE) 135 ELSEIF(_get_build_unit_file) 136 # Note: ${_file} is relative to the binary directory 137 SET(_build_unit_file ${CMAKE_BINARY_DIR}/${_file}) 138 SET(_get_build_unit_file FALSE) 139 SET(_add_to_build_unit TRUE) 140 SET(_build_unit_include_string) 141 SET(_build_unit_count "0") 129 142 ELSE() 130 143 # Default, add source file … … 146 159 LIST(APPEND _${_target_name}_source_files ${_file}) 147 160 148 # Handle compilations149 IF(_add_to_ compilation AND NOT DISABLE_COMPILATIONS)161 # Handle build units 162 IF(_add_to_build_unit AND ENABLE_BUILD_UNITS) 150 163 IF(_file MATCHES "\\.(c|cc|cpp|cxx)$") 151 SET(_compilation_include_string "${_compilation_include_string}#include \"${_file}\"\n") 164 SET(_build_unit_include_string "${_build_unit_include_string}#include \"${_file}\"\n") 165 MATH(EXPR _build_unit_count "1 + ${_build_unit_count}") 152 166 ENDIF() 153 167 # Don't compile these files, even if they are source files … … 183 197 ENDIF() 184 198 199 # Mark files to be excluded from build units 200 IF(_arg_EXCLUDE_FROM_BUILD_UNITS) 201 SET_SOURCE_FILES_PROPERTIES(${_arg_EXCLUDE_FROM_BUILD_UNITS} 202 PROPERTIES EXCLUDE_FROM_BUILD_UNITS TRUE) 203 ENDIF() 204 205 # Full build units 206 IF(ENABLE_BUILD_UNITS AND NOT _arg_NO_BUILD_UNITS) 207 # Use full build units even in partial mode for externals 208 IF(ENABLE_BUILD_UNITS MATCHES "full" OR _arg_ORXONOX_EXTERNAL) 209 GENERATE_BUILD_UNITS(${_target_name} _${_target_name}_files) 210 ENDIF() 211 ENDIF() 212 185 213 # First part (pre target) of precompiled header files 186 214 IF(PCH_COMPILER_SUPPORT AND _arg_PCH_FILE) … … 196 224 MARK_AS_ADVANCED(PCH_ENABLE_${_target_name_upper}) 197 225 198 IF(PCH_ENABLE_${_target_name_upper} )226 IF(PCH_ENABLE_${_target_name_upper} AND NOT PCH_DISABLE_${_target_name}) 199 227 PRECOMPILED_HEADER_FILES_PRE_TARGET(${_target_name} ${_arg_PCH_FILE} _${_target_name}_files EXCLUDE ${_arg_PCH_EXCLUDE}) 200 228 ENDIF() … … 344 372 345 373 # Second part of precompiled header files 346 IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE )374 IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE AND NOT PCH_DISABLE_${_target_name}) 347 375 PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE}) 348 376 ENDIF()
Note: See TracChangeset
for help on using the changeset viewer.