From aa55fe23c232e22a790f6daa1c95f2a6c24a04db Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 11 Mar 2012 18:25:23 +0100 Subject: [PATCH 001/169] cotire 1.0.0 First release. --- .gitignore | 3 + CMake/cotire.cmake | 2649 ++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 11 + HISTORY.md | 3 + MANUAL.md | 403 +++++++ README.md | 116 ++ license | 22 + src/CMakeLists.txt | 28 + src/example.cpp | 24 + src/example.h | 10 + src/log.cpp | 17 + src/log.h | 10 + src/main.cpp | 12 + 13 files changed, 3308 insertions(+) create mode 100755 .gitignore create mode 100644 CMake/cotire.cmake create mode 100644 CMakeLists.txt create mode 100644 HISTORY.md create mode 100644 MANUAL.md create mode 100644 README.md create mode 100644 license create mode 100644 src/CMakeLists.txt create mode 100644 src/example.cpp create mode 100644 src/example.h create mode 100644 src/log.cpp create mode 100644 src/log.h create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..b33cb3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# ignore CMake build directories +build*/ +.DS_Store diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake new file mode 100644 index 0000000..ff3beee --- /dev/null +++ b/CMake/cotire.cmake @@ -0,0 +1,2649 @@ +# - cotire (compile time reducer) +# +# See the cotire manual for usage hints. +# +#============================================================================= +# Copyright 2012 Sascha Kratky +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +#============================================================================= + +if(__COTIRE_INCLUDED) + return() +endif() +set(__COTIRE_INCLUDED TRUE) + +# we need the CMake variables CMAKE_SCRIPT_MODE_FILE and CMAKE_ARGV available since 2.8.5 +cmake_minimum_required(VERSION 2.8.5) + +set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.0") + +include(CMakeParseArguments) + +function (cotire_determine_compiler_version _language _versionPrefix) + if (NOT ${_versionPrefix}_VERSION) + if (MSVC) + # use CMake's predefined version variable for MSVC, if available + if (DEFINED MSVC_VERSION) + set (${_versionPrefix}_VERSION "${MSVC_VERSION}") + else() + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} + ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) + string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" + ${_versionPrefix}_VERSION "${_versionLine}") + endif() + else() + # assume GCC like command line interface + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} "-dumpversion" + OUTPUT_VARIABLE ${_versionPrefix}_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) + endif() + if (${_versionPrefix}_VERSION) + set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" CACHE INTERNAL "${_language} compiler version") + endif() + set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" PARENT_SCOPE) + if (COTIRE_DEBUG) + message (STATUS "${CMAKE_${_language}_COMPILER} version ${${_versionPrefix}_VERSION}") + endif() + endif() +endfunction() + +function (cotire_get_source_file_extension _sourceFile _extVar) + # get_filename_component returns extension from first occurrence of . in file name + # this function computes the extension from last occurrence of . in file name + string (FIND "${_sourceFile}" "." _index REVERSE) + if (_index GREATER -1) + math (EXPR _index "${_index} + 1") + string (SUBSTRING "${_sourceFile}" ${_index} -1 _sourceExt) + else() + set (_sourceExt "") + endif() + set (${_extVar} "${_sourceExt}" PARENT_SCOPE) +endfunction() + +macro (cotire_check_is_path_relative_to _path _isRelativeVar) + set (${_isRelativeVar} FALSE) + foreach (_dir ${ARGN}) + file (RELATIVE_PATH _relPath "${_dir}" "${_path}") + if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")) + set (${_isRelativeVar} TRUE) + break() + endif() + endforeach() +endmacro() + +function (cotire_filter_language_source_files _language _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) + set (_sourceFiles "") + set (_excludedSourceFiles "") + set (_cotiredSourceFiles "") + if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}") + else() + set (_languageExtensions "") + endif() + if (CMAKE_${_language}_IGNORE_EXTENSIONS) + set (_ignoreExtensions "${CMAKE_${_language}_IGNORE_EXTENSIONS}") + else() + set (_ignoreExtensions "") + endif() + foreach (_sourceFile ${ARGN}) + get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) + get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) + get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) + get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) + set (_sourceIsFiltered FALSE) + if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic) + cotire_get_source_file_extension("${_sourceFile}" _sourceExt) + if (_sourceExt) + list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) + list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex) + if (_sourceIndex GREATER -1 AND _ignoreIndex LESS 0) + set (_sourceIsFiltered TRUE) + endif() + endif() + endif() + if (COTIRE_DEBUG) + message (STATUS "${_sourceFile} filtered=${_sourceIsFiltered} language=${_sourceLanguage} header=${_sourceIsHeaderOnly}") + endif() + if (_sourceIsFiltered) + get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) + get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) + get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) + if (COTIRE_DEBUG) + message (STATUS "${_sourceFile} excluded=${_sourceIsExcluded} cotired=${_sourceIsCotired}") + endif() + if (_sourceIsCotired) + list (APPEND _cotiredSourceFiles "${_sourceFile}") + elseif (_sourceIsExcluded OR _sourceCompileFlags) + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") + endif() + endif() + endforeach() + if (COTIRE_DEBUG) + message (STATUS "All: ${ARGN}") + message (STATUS "${_language}: ${_sourceFiles}") + message (STATUS "Excluded: ${_excludedSourceFiles}") + message (STATUS "Cotired: ${_cotiredSourceFiles}") + endif() + set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE) + set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE) + set (${_cotiredSourceFilesVar} ${_cotiredSourceFiles} PARENT_SCOPE) +endfunction() + +function (cotire_get_objects_with_property_on _filteredObjectsVar _property _type) + set (_filteredObjects "") + foreach (_object ${ARGN}) + get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (_propertyValue) + list (APPEND _filteredObjects "${_object}") + endif() + endif() + endforeach() + set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) +endfunction() + +function (cotire_get_objects_with_property_off _filteredObjectsVar _property _type) + set (_filteredObjects "") + foreach (_object ${ARGN}) + get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (NOT _propertyValue) + list (APPEND _filteredObjects "${_object}") + endif() + endif() + endforeach() + set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_file_property_values _valuesVar _property) + set (_values "") + foreach (_sourceFile ${ARGN}) + get_source_file_property(_propertyValue "${_sourceFile}" ${_property}) + if (_propertyValue) + list (APPEND _values "${_propertyValue}") + endif() + endforeach() + set (${_valuesVar} ${_values} PARENT_SCOPE) +endfunction() + +function (cotrie_copy_set_properites _configurations _type _source _target) + set (_properties "") + foreach (_property ${ARGN}) + if ("${_property}" MATCHES "") + foreach (_config ${_configurations}) + string (TOUPPER "${_config}" _config) + string (REPLACE "" "${_config}" _configProperty "${_property}") + list (APPEND _properties ${_configProperty}) + endforeach() + else() + list (APPEND _properties ${_property}) + endif() + endforeach() + foreach (_property ${_properties}) + get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} ${_source} PROPERTY ${_property}) + set_property(${_type} ${_target} PROPERTY ${_property} "${_propertyValue}") + endif() + endforeach() +endfunction() + +function (cotire_filter_compile_flags _flagFilter _matchedOptionsVar _unmatchedOptionsVar) + if (MSVC) + set (_flagPrefix "[/-]") + else() + set (_flagPrefix "--?") + endif() + set (_optionFlag "") + set (_matchedOptions "") + set (_unmatchedOptions "") + foreach (_compileFlag ${ARGN}) + if (_compileFlag) + if (_optionFlag AND NOT "${_compileFlag}" MATCHES "^${_flagPrefix}") + # option with separate argument + list (APPEND _matchedOptions "${_compileFlag}") + set (_optionFlag "") + elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})$") + # remember option + set (_optionFlag "${CMAKE_MATCH_2}") + elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})(.+)$") + # option with joined argument + list (APPEND _matchedOptions "${CMAKE_MATCH_3}") + set (_optionFlag "") + else() + # flush remembered option + if (_optionFlag) + list (APPEND _matchedOptions "${_optionFlag}") + set (_optionFlag "") + endif() + # add to unfiltered options + list (APPEND _unmatchedOptions "${_compileFlag}") + endif() + endif() + endforeach() + if (_optionFlag) + list (APPEND _matchedOptions "${_optionFlag}") + endif() + if (COTIRE_DEBUG) + message (STATUS "Filter ${_flagFilter}") + if (_matchedOptions) + message (STATUS "Matched ${_matchedOptions}") + endif() + if (_unmatchedOptions) + message (STATUS "Unmatched ${_unmatchedOptions}") + endif() + endif() + set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE) + set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compile_flags _config _language _directory _target _flagsVar) + string (TOUPPER "${_config}" _config) + # collect options from CMake language variables + set (_compileFlags "") + if (CMAKE_${_language}_FLAGS) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}") + endif() + if (CMAKE_${_language}_FLAGS_${_config}) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_config}}") + endif() + if (_target) + # add option from CMake target type variable + get_target_property(_targetType ${_target} TYPE) + if (_targetType STREQUAL "MODULE_LIBRARY") + # flags variable for module library uses different name SHARED_MODULE + # (e.g., CMAKE_SHARED_MODULE_C_FLAGS) + set (_targetType SHARED_MODULE) + endif() + if (CMAKE_${_targetType}_${_language}_FLAGS) + set (_compileFlags "${_compileFlags} ${CMAKE_${_targetType}_${_language}_FLAGS}") + endif() + endif() + if (_directory) + # add_definitions may have been used to add flags to the compiler command + get_directory_property(_dirDefinitions DIRECTORY "${_directory}" DEFINITIONS) + if (_dirDefinitions) + set (_compileFlags "${_compileFlags} ${_dirDefinitions}") + endif() + endif() + if (_target) + # add target compile options + get_target_property(_targetflags ${_target} COMPILE_FLAGS) + if (_targetflags) + set (_compileFlags "${_compileFlags} ${_targetflags}") + endif() + endif() + if (UNIX) + separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") + elseif(WIN32) + separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}") + else() + separate_arguments(_compileFlags) + endif() + # platform specific flags + if (APPLE) + get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_config}) + if (NOT _architectures) + get_target_property(_architectures ${_target} OSX_ARCHITECTURES) + endif() + foreach (_arch ${_architectures}) + list (APPEND _compileFlags "-arch" "${_arch}") + endforeach() + if (CMAKE_OSX_SYSROOT AND CMAKE_OSX_SYSROOT_DEFAULT AND CMAKE_${_language}_HAS_ISYSROOT) + if (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "${CMAKE_OSX_SYSROOT_DEFAULT}") + list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}") + endif() + endif() + if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG) + list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() + endif() + if (COTIRE_DEBUG AND _compileFlags) + message (STATUS "Target ${_target} compile flags ${_compileFlags}") + endif() + set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_include_directories _config _language _directory _target _includeDirsVar) + set (_includeDirs "") + # default include dirs + if (CMAKE_INCLUDE_CURRENT_DIR) + list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}") + list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + # parse additional include directories from target compile flags + cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) + cotire_filter_compile_flags("I" _dirs _ignore ${_targetFlags}) + if (_dirs) + list (APPEND _includeDirs ${_dirs}) + endif() + # target include directories + get_directory_property(_dirs DIRECTORY "${_directory}" INCLUDE_DIRECTORIES) + list (LENGTH _includeDirs _projectInsertIndex) + foreach (_dir ${_dirs}) + if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE) + cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") + if (_isRelative) + list (INSERT _includeDirs _projectInsertIndex "${_dir}") + math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1") + else() + list (APPEND _includeDirs "${_dir}") + endif() + else() + list (APPEND _includeDirs "${_dir}") + endif() + endforeach() + list (REMOVE_DUPLICATES _includeDirs) + if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) + list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) + endif() + if (COTIRE_DEBUG AND _includeDirs) + message (STATUS "Target ${_target} include dirs ${_includeDirs}") + endif() + set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE) +endfunction() + +macro (cotire_make_C_identifier _identifierVar _str) + # mimic CMake SystemTools::MakeCindentifier behavior + if ("${_str}" MATCHES "^[0-9].+$") + set (_str "_${str}") + endif() + string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") +endmacro() + +function (cotire_get_target_export_symbol _target _exportSymbolVar) + set (_exportSymbol "") + get_target_property(_targetType ${_target} TYPE) + get_target_property(_enableExports ${_target} ENABLE_EXPORTS) + if (_targetType MATCHES "(SHARED|MODULE)_LIBRARY" OR + (_targetType STREQUAL "EXECUTABLE" AND _enableExports)) + get_target_property(_exportSymbol ${_target} DEFINE_SYMBOL) + if (NOT _exportSymbol) + set (_exportSymbol "${_target}_EXPORTS") + endif() + cotire_make_C_identifier(_exportSymbol "${_exportSymbol}") + endif() + set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compile_definitions _config _language _directory _target _definitionsVar) + string (TOUPPER "${_config}" _config) + set (_configDefinitions "") + # CMAKE_INTDIR for multi-configuration build systems + if (CMAKE_CONFIGURATION_TYPES) + list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"") + endif() + # target export define symbol + cotire_get_target_export_symbol("${_target}" _defineSymbol) + if (_defineSymbol) + list (APPEND _configDefinitions "${_defineSymbol}") + endif() + # directory compile definitions + get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS_${_config}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + # target compile definitions + get_target_property(_definitions ${_target} COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_config}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + # parse additional compile definitions from target compile flags + # and don't look at directory compile definitions, which we already handled + cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) + cotire_filter_compile_flags("D" _definitions _ignore ${_targetFlags}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + list (REMOVE_DUPLICATES _configDefinitions) + if (COTIRE_DEBUG AND _configDefinitions) + message (STATUS "Target ${_target} compile definitions ${_configDefinitions}") + endif() + set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) + # parse target compile flags omitting compile definitions and include directives + cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) + cotire_filter_compile_flags("[ID]" _ignore _compilerFlags ${_targetFlags}) + if (COTIRE_DEBUG AND _compileFlags) + message (STATUS "Target ${_target} compiler flags ${_compileFlags}") + endif() + set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) + set (_extraProperties ${ARGN}) + set (_result "") + if (_extraProperties) + list (FIND _extraProperties "${_sourceFile}" _index) + if (_index GREATER -1) + math (EXPR _index "${_index} + 1") + list (LENGTH _extraProperties _len) + math (EXPR _len "${_len} - 1") + foreach (_index RANGE ${_index} ${_len}) + list (GET _extraProperties ${_index} _value) + if ("${_value}" MATCHES "${_pattern}") + list (APPEND _result "${_value}") + else() + break() + endif() + endforeach() + endif() + endif() + set (${_resultVar} ${_result} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar) + set (_compileDefinitions "") + if (NOT CMAKE_SCRIPT_MODE_FILE) + string (TOUPPER "${_config}" _config) + get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_config}) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + endif() + cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+(=.*)?$" _definitions ${ARGN}) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + if (COTIRE_DEBUG AND _compileDefinitions) + message (STATUS "Source ${_sourceFile} compile definitions ${_compileDefinitions}") + endif() + set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_files_compile_definitions _config _language _definitionsVar) + set (_configDefinitions "") + foreach (_sourceFile ${ARGN}) + cotire_get_source_compile_definitions("${_config}" "${_language}" "${_sourceFile}" _sourceDefinitions) + if (_sourceDefinitions) + list (APPEND _configDefinitions "${_sourceFile}" ${_sourceDefinitions} "-") + endif() + endforeach() + set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar) + set (_sourceUndefs "") + if (NOT CMAKE_SCRIPT_MODE_FILE) + get_source_file_property(_undefs "${_sourceFile}" ${_property}) + if (_undefs) + list (APPEND _sourceUndefs ${_undefs}) + endif() + endif() + cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+$" _undefs ${ARGN}) + if (_undefs) + list (APPEND _sourceUndefs ${_undefs}) + endif() + if (COTIRE_DEBUG AND _sourceUndefs) + message (STATUS "Source ${_sourceFile} ${_property} undefs ${_sourceUndefs}") + endif() + set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_files_undefs _property _sourceUndefsVar) + set (_sourceUndefs "") + foreach (_sourceFile ${ARGN}) + cotire_get_source_undefs("${_sourceFile}" ${_property} _undefs) + if (_undefs) + list (APPEND _sourceUndefs "${_sourceFile}" ${_undefs} "-") + endif() + endforeach() + set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) +endfunction() + +macro (cotire_set_cmd_to_prologue _cmdVar) + set (${_cmdVar} "${CMAKE_COMMAND}") + list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") + if (COTIRE_VERBOSE) + list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") + elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") + list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=$(VERBOSE)") + endif() +endmacro() + +macro (cotire_add_definitions_to_cmd _cmdVar) + foreach (_definition ${ARGN}) + if (MSVC) + list (APPEND ${_cmdVar} "/D${_definition}") + else() + list (APPEND ${_cmdVar} "-D${_definition}") + endif() + endforeach() +endmacro() + +macro (cotire_add_includes_to_cmd _cmdVar) + foreach (_include ${ARGN}) + if (MSVC) + file (TO_NATIVE_PATH "${_include}" _include) + list (APPEND ${_cmdVar} "/I${_include}") + else() + list (APPEND ${_cmdVar} "-I${_include}") + endif() + endforeach() +endmacro() + +macro (cotire_add_compile_flags_to_cmd _cmdVar) + foreach (_flag ${ARGN}) + list (APPEND ${_cmdVar} "${_flag}") + endforeach() +endmacro() + +function (cotire_check_file_up_to_date _fileIsUpToDateVar _file) + set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) + set (_triggerFile "") + foreach (_dependencyFile ${ARGN}) + if (EXISTS "${_dependencyFile}" AND "${_dependencyFile}" IS_NEWER_THAN "${_file}") + set (_triggerFile "${_dependencyFile}") + break() + endif() + endforeach() + get_filename_component(_fileName "${_file}" NAME) + if (EXISTS "${_file}") + if (_triggerFile) + if (COTIRE_VERBOSE) + message (STATUS "${_fileName} update triggered by ${_triggerFile} change.") + endif() + else() + if (COTIRE_VERBOSE) + message (STATUS "${_fileName} is up-to-date.") + endif() + set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE) + endif() + else() + if (COTIRE_VERBOSE) + message (STATUS "${_fileName} does not exist yet.") + endif() + endif() +endfunction() + +macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar) + set (${_relPathVar} "") + foreach (_includeDir ${_includeDirs}) + if (IS_DIRECTORY "${_includeDir}") + file (RELATIVE_PATH _relPath "${_includeDir}" "${_headerFile}") + if (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.") + string (LENGTH "${${_relPathVar}}" _closestLen) + string (LENGTH "${_relPath}" _relLen) + if (_closestLen EQUAL 0 OR _relLen LESS _closestLen) + set (${_relPathVar} "${_relPath}") + endif() + endif() + elseif ("${_includeDir}" STREQUAL "${_headerFile}") + # if path matches exactly, return short non-empty string + set (${_relPathVar} "1") + break() + endif() + endforeach() +endmacro() + +macro (cotire_check_header_file_location _headerFile _insideIncudeDirs _outsideIncudeDirs _headerIsInside) + # check header path against ignored and honored include directories + cotire_find_closest_relative_path("${_headerFile}" "${_insideIncudeDirs}" _insideRelPath) + if (_insideRelPath) + # header is inside, but could be become outside if there is a shorter outside match + cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncudeDirs}" _outsideRelPath) + if (_outsideRelPath) + string (LENGTH "${_insideRelPath}" _insideRelPathLen) + string (LENGTH "${_outsideRelPath}" _outsideRelPathLen) + if (_outsideRelPathLen LESS _insideRelPathLen) + set (${_headerIsInside} FALSE) + else() + set (${_headerIsInside} TRUE) + endif() + else() + set (${_headerIsInside} TRUE) + endif() + else() + # header is outside + set (${_headerIsInside} FALSE) + endif() +endmacro() + +macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar) + if (NOT EXISTS "${_headerFile}") + set (${_headerIsIgnoredVar} TRUE) + elseif (IS_DIRECTORY "${_headerFile}") + set (${_headerIsIgnoredVar} TRUE) + elseif ("${_headerFile}" MATCHES "\\.\\." AND "${_headerFile}" MATCHES "\\.h$") + # ignore C headers with embedded parent directory references + # these often stem from using GCC #include_next tricks + # which break the precompiled header compilation with the error message + # "error: no include path in which to search for header.h" + set (${_headerIsIgnoredVar} TRUE) + else() + set (${_headerIsIgnoredVar} FALSE) + endif() +endmacro() + +macro (cotire_check_ignore_header_file_ext _headerFile _ignoreExtensionsVar _headerIsIgnoredVar) + # check header file extension + cotire_get_source_file_extension("${_headerFile}" _headerFileExt) + set (${_headerIsIgnoredVar} FALSE) + if (_headerFileExt) + list (FIND ${_ignoreExtensionsVar} "${_headerFileExt}" _index) + if (_index GREATER -1) + set (${_headerIsIgnoredVar} TRUE) + endif() + endif() +endmacro() + +macro (cotire_parse_line _line _headerFileVar _headerDepthVar) + if (MSVC) + # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: + # English: "Note: including file:" + # German: "Hinweis: Einlesen der Datei:" + # We use a very general regular expression, relying on the presence of the : character + if ("${_line}" MATCHES "^[^:]+:[^:]+:( +)(.*)$") + # Visual Studio compiler output + string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) + get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) + else() + set (${_headerFileVar} "") + set (${_headerDepthVar} 0) + endif() + else() + if ("${_line}" MATCHES "^(\\.+) (.*)$") + # GCC like output + string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) + if (IS_ABSOLUTE "${CMAKE_MATCH_2}") + set (${_headerFileVar} "${CMAKE_MATCH_2}") + else() + get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" REALPATH) + endif() + else() + set (${_headerFileVar} "") + set (${_headerDepthVar} 0) + endif() + endif() +endmacro() + +function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honoredIncudeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar) + if (WIN32) + # prevent CMake macro invocation errors due to backslash characters in Windows paths + string (REPLACE "\\" "/" _scanOutput "${_scanOutput}") + endif() + string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}") + string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}") + list (LENGTH _scanOutput _len) + # remove duplicate lines to speed up parsing + list (REMOVE_DUPLICATES _scanOutput) + list (LENGTH _scanOutput _uniqueLen) + if (COTIRE_VERBOSE) + message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes") + if (_ignoredExtensions) + message (STATUS "Ignored extensions: ${_ignoredExtensions}") + endif() + if (_ignoredIncudeDirs) + message (STATUS "Ignored paths: ${_ignoredIncudeDirs}") + endif() + if (_honoredIncudeDirs) + message (STATUS "Included paths: ${_honoredIncudeDirs}") + endif() + endif() + set (_sourceFiles ${ARGN}) + set (_selectedIncludes "") + set (_unparsedLines "") + # stack keeps track of inside/outside project status of processed header files + set (_headerIsInsideStack "") + foreach (_line IN LISTS _scanOutput) + if (_line) + cotire_parse_line("${_line}" _headerFile _headerDepth) + if (_headerFile) + cotire_check_header_file_location("${_headerFile}" "${_ignoredIncudeDirs}" "${_honoredIncudeDirs}" _headerIsInside) + if (COTIRE_DEBUG) + message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}") + endif() + # update stack + list (LENGTH _headerIsInsideStack _stackLen) + if (_headerDepth GREATER _stackLen) + math (EXPR _stackLen "${_stackLen} + 1") + foreach (_index RANGE ${_stackLen} ${_headerDepth}) + list (APPEND _headerIsInsideStack ${_headerIsInside}) + endforeach() + else() + foreach (_index RANGE ${_headerDepth} ${_stackLen}) + list (REMOVE_AT _headerIsInsideStack -1) + endforeach() + list (APPEND _headerIsInsideStack ${_headerIsInside}) + endif() + if (COTIRE_DEBUG) + message (STATUS "${_headerIsInsideStack}") + endif() + # header is a candidate if it is outside project + if (NOT _headerIsInside) + # get parent header file's inside/outside status + if (_headerDepth GREATER 1) + math (EXPR _index "${_headerDepth} - 2") + list (GET _headerIsInsideStack ${_index} _parentHeaderIsInside) + else() + set (_parentHeaderIsInside TRUE) + endif() + # select header file if parent header file is inside project + # (e.g., a project header file that includes a standard header file) + if (_parentHeaderIsInside) + cotire_check_ignore_header_file_path("${_headerFile}" _headerIsIgnored) + if (NOT _headerIsIgnored) + cotire_check_ignore_header_file_ext("${_headerFile}" _ignoredExtensions _headerIsIgnored) + if (NOT _headerIsIgnored) + list (APPEND _selectedIncludes "${_headerFile}") + else() + # fix header's inside status on stack, it is ignored by extension now + list (REMOVE_AT _headerIsInsideStack -1) + list (APPEND _headerIsInsideStack TRUE) + endif() + endif() + if (COTIRE_DEBUG) + message (STATUS "${_headerFile} ${_ignoredExtensions} ${_headerIsIgnored}") + endif() + endif() + endif() + else() + if (MSVC) + # for cl.exe do not keep unparsed lines which solely consist of a source file name + string (FIND "${_sourceFiles}" "${_line}" _index) + if (_index LESS 0) + list (APPEND _unparsedLines "${_line}") + endif() + else() + list (APPEND _unparsedLines "${_line}") + endif() + endif() + endif() + endforeach() + list (REMOVE_DUPLICATES _selectedIncludes) + set (${_selectedIncludesVar} ${_selectedIncludes} PARENT_SCOPE) + set (${_unparsedLinesVar} ${_unparsedLines} PARENT_SCOPE) +endfunction() + +function (cotire_scan_includes _includesVar) + set(_options "") + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION LANGUAGE UNPARSED_LINES) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + if (NOT _option_LANGUAGE) + set (_option_LANGUAGE "CXX") + endif() + if (NOT _option_COMPILER_EXECUTABLE) + set (_option_COMPILER_EXECUTABLE "${CMAKE_${_option_LANGUAGE}_COMPILER}") + endif() + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + set (_cmd "${_option_COMPILER_EXECUTABLE}") + cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) + cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) + cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) + cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) + # only consider existing source files for scanning + set (_existingSourceFiles "") + foreach (_sourceFile ${_sourceFiles}) + if (EXISTS "${_sourceFile}") + list (APPEND _existingSourceFiles "${_sourceFile}") + endif() + endforeach() + if (NOT _existingSourceFiles) + set (${_includesVar} "" PARENT_SCOPE) + return() + endif() + list (APPEND _cmd ${_existingSourceFiles}) + if (COTIRE_VERBOSE) + message (STATUS "execute_process: ${_cmd}") + endif() + if (WIN32) + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + endif() + execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_QUIET ERROR_VARIABLE _output) + cotire_parse_includes( + "${_option_LANGUAGE}" "${_output}" + "${_option_IGNORE_PATH}" "${_option_INCLUDE_PATH}" + "${_option_IGNORE_EXTENSIONS}" + _includes _unparsedLines + ${_sourceFiles}) + set (${_includesVar} ${_includes} PARENT_SCOPE) + if (_option_UNPARSED_LINES) + set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) + endif() +endfunction() + +macro (cotire_append_undefs _contentsVar) + set (_undefs ${ARGN}) + if (_undefs) + list (REMOVE_DUPLICATES _undefs) + foreach (_definition ${_undefs}) + list (APPEND ${_contentsVar} "#undef ${_definition}") + endforeach() + endif() +endmacro() + +macro (cotire_comment_str _language _commentText _commentVar) + if ("${_language}" STREQUAL "CMAKE") + set (${_commentVar} "# ${_commentText}") + else() + set (${_commentVar} "/* ${_commentText} */") + endif() +endmacro() + +function (cotire_write_file _language _file _contents _force) + cotire_comment_str("${_language}" "cotire.cmake ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1) + cotire_comment_str("${_language}" "${_file}" _header2) + set (_contents "${_header1}\n${_header2}\n${_contents}") + if (COTIRE_DEBUG) + message ("${_contents}") + endif() + if (_force OR NOT EXISTS "${_file}") + file (WRITE "${_file}" "${_contents}") + else() + file (READ "${_file}" _oldContents) + if (NOT "${_oldContents}" STREQUAL "${_contents}") + file (WRITE "${_file}" "${_contents}") + else() + if (COTIRE_DEBUG) + message (STATUS "${_file} unchanged") + endif() + endif() + endif() +endfunction() + +function (cotire_generate_unity_source _unityFile) + set(_options "") + set(_oneValueArgs LANGUAGE) + set(_multiValueArgs + DEPENDS SOURCES_COMPILE_DEFINITIONS + PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (_option_DEPENDS) + cotire_check_file_up_to_date(_unityFileIsUpToDate "${_unityFile}" ${_option_DEPENDS}) + if (_unityFileIsUpToDate) + return() + endif() + endif() + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + if (NOT _option_PRE_UNDEFS) + set (_option_PRE_UNDEFS "") + endif() + if (NOT _option_SOURCES_PRE_UNDEFS) + set (_option_SOURCES_PRE_UNDEFS "") + endif() + if (NOT _option_POST_UNDEFS) + set (_option_POST_UNDEFS "") + endif() + if (NOT _option_SOURCES_POST_UNDEFS) + set (_option_SOURCES_POST_UNDEFS "") + endif() + set (_contents "") + if (_option_LANGUAGE AND _sourceFiles) + if ("${_option_LANGUAGE}" STREQUAL "CXX") + list (APPEND _contents "#ifdef __cplusplus") + elseif ("${_option_LANGUAGE}" STREQUAL "C") + list (APPEND _contents "#ifndef __cplusplus") + endif() + endif() + set (_compileUndefinitions "") + foreach (_sourceFile ${_sourceFiles}) + cotire_get_source_compile_definitions( + "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions + ${_option_SOURCES_COMPILE_DEFINITIONS}) + cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_PRE_UNDEFS _sourcePreUndefs ${_option_SOURCES_PRE_UNDEFS}) + cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_POST_UNDEFS _sourcePostUndefs ${_option_SOURCES_POST_UNDEFS}) + if (_option_PRE_UNDEFS) + list (APPEND _compileUndefinitions ${_option_PRE_UNDEFS}) + endif() + if (_sourcePreUndefs) + list (APPEND _compileUndefinitions ${_sourcePreUndefs}) + endif() + if (_compileUndefinitions) + cotire_append_undefs(_contents ${_compileUndefinitions}) + set (_compileUndefinitions "") + endif() + if (_sourcePostUndefs) + list (APPEND _compileUndefinitions ${_sourcePostUndefs}) + endif() + if (_option_POST_UNDEFS) + list (APPEND _compileUndefinitions ${_option_POST_UNDEFS}) + endif() + foreach (_definition ${_compileDefinitions}) + if ("${_definition}" MATCHES "^([a-zA-Z0-9_]+)=(.+)$") + list (APPEND _contents "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}") + list (INSERT _compileUndefinitions 0 "${CMAKE_MATCH_1}") + else() + list (APPEND _contents "#define ${_definition}") + list (INSERT _compileUndefinitions 0 "${_definition}") + endif() + endforeach() + get_filename_component(_sourceFile "${_sourceFile}" ABSOLUTE) + if (WIN32) + file (TO_NATIVE_PATH "${_sourceFile}" _sourceFile) + endif() + list (APPEND _contents "#include \"${_sourceFile}\"") + endforeach() + if (_compileUndefinitions) + cotire_append_undefs(_contents ${_compileUndefinitions}) + set (_compileUndefinitions "") + endif() + if (_option_LANGUAGE AND _sourceFiles) + list (APPEND _contents "#endif") + endif() + list (APPEND _contents "") + string (REPLACE ";" "\n" _contents "${_contents}") + if (COTIRE_VERBOSE) + message ("${_contents}") + endif() + cotire_write_file("${_option_LANGUAGE}" "${_unityFile}" "${_contents}" TRUE) +endfunction() + +function (cotire_generate_prefix_header _prefixFile) + set(_options "") + set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION) + set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS + INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (_option_DEPENDS) + cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) + if (_prefixFileIsUpToDate) + return() + endif() + endif() + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + cotire_scan_includes(_selectedHeaders ${_sourceFiles} + LANGUAGE "${_option_LANGUAGE}" + COMPILER_EXECUTABLE "${_option_COMPILER_EXECUTABLE}" + COMPILER_ID "${_option_COMPILER_ID}" + COMPILER_VERSION "${_option_COMPILER_VERSION}" + COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} + COMPILE_FLAGS ${_option_COMPILE_FLAGS} + INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES} + IGNORE_PATH ${_option_IGNORE_PATH} + INCLUDE_PATH ${_option_INCLUDE_PATH} + IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} + UNPARSED_LINES _unparsedLines) + cotire_generate_unity_source("${_prefixFile}" LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) + set (_unparsedLinesFile "${_prefixFile}.log") + if (_unparsedLines) + if (COTIRE_VERBOSE OR NOT _selectedHeaders) + list (LENGTH _unparsedLines _skippedLineCount) + file (RELATIVE_PATH _unparsedLinesFileRelPath "${CMAKE_BINARY_DIR}" "${_unparsedLinesFile}") + message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFileRelPath}") + endif() + string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") + else() + file (REMOVE "${_unparsedLinesFile}") + endif() +endfunction() + +function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) + set (_flags ${${_flagsVar}}) + if ("${_compilerID}" STREQUAL "MSVC") + # cl.exe options used + # /nologo suppresses display of sign-on banner + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /EP preprocess to stdout without #line directives + # /showIncludes list include files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /showIncludes) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP /showIncludes") + endif() + elseif ("${_compilerID}" STREQUAL "GNU") + # GCC options used + # -H print the name of each header file used + # -M do dependency scanning + # -MG don't raise error on missing files + # -fdirectives-only do not expand macros, requires GCC >= 4.3 + if (_flags) + # append to list + list (APPEND _flags -H -M -MG) + if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") + list (APPEND _flags "-fdirectives-only") + endif() + else() + # return as a flag string + set (_flags "-H -M -MG") + if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") + set (_flags "${_flags} -fdirectives-only") + endif() + endif() + elseif ("${_compilerID}" STREQUAL "Clang") + # Clang options used + # -H print the name of each header file used + # -M do dependency scanning + if (_flags) + # append to list + list (APPEND _flags -H -M) + else() + # return as a flag string + set (_flags "-H -M") + endif() + else() + message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersion _prefixFile _pchFile _hostFile _flagsVar) + set (_flags ${${_flagsVar}}) + if ("${_compilerID}" STREQUAL "MSVC") + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) + # cl.exe options used + # /Yc creates a precompiled header file + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /Zs syntax check only + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" + "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + else() + # return as a flag string + set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + endif() + elseif ("${_compilerID}" MATCHES "GNU|Clang") + # GCC / Clang options used + # -x specify the source language + # -c compile but do not link + # -o place output in file + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + if (_flags) + # append to list + list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + else() + # return as a flag string + set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + endif() + else() + message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) + set (_flags ${${_flagsVar}}) + if ("${_compilerID}" STREQUAL "MSVC") + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + # cl.exe options used + # /Yu uses a precompiled header file during build + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + if (_flags) + # append to list + list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + endif() + elseif ("${_compilerID}" MATCHES "GNU|Clang") + # GCC / Clang options used + # -include process include file as the first line of the primary source file + # -Winvalid-pch warns if precompiled header is found but cannot be used + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}" "-Winvalid-pch") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -Winvalid-pch") + endif() + else() + message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) + set(_options "") + set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION LANGUAGE) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_LANGUAGE) + set (_option_LANGUAGE "CXX") + endif() + if (NOT _option_COMPILER_EXECUTABLE) + set (_option_COMPILER_EXECUTABLE "${CMAKE_${_option_LANGUAGE}_COMPILER") + endif() + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + set (_cmd "${_option_COMPILER_EXECUTABLE}") + cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) + cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) + cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) + cotire_add_pch_compilation_flags( + "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) + if (COTIRE_VERBOSE) + message (STATUS "execute_process: ${_cmd}") + endif() + if (WIN32) + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + endif() + execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result) + if (_result) + message (FATAL_ERROR "Error ${_result} precompiling ${_prefixFile}.") + endif() +endfunction() + +function (cotire_check_precompiled_header_support _language _target _msgVar) + if (MSVC) + # supported since Visual Studio C++ 6.0 + # and CMake does not support an earlier version + set (${_msgVar} "" PARENT_SCOPE) + elseif ("${CMAKE_${_language}_COMPILER_ID}" STREQUAL "GNU") + # GCC PCH support requires GCC >= 3.4 + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND + "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") + set (${_msgVar} + "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID} version ${COTIRE_${_language}_COMPILER_VERSION}." + PARENT_SCOPE) + else() + set (${_msgVar} "" PARENT_SCOPE) + endif() + elseif ("${CMAKE_${_language}_COMPILER_ID}" STREQUAL "Clang") + # Clang has PCH support + set (${_msgVar} "" PARENT_SCOPE) + else() + set (${_msgVar} "Unsupported ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}." PARENT_SCOPE) + endif() + if (APPLE) + # PCH compilation not supported by GCC / Clang when multiple build architectures (e.g., i386, x86_64) are selected + if (CMAKE_CONFIGURATION_TYPES) + set (_configs ${CMAKE_CONFIGURATION_TYPES}) + else() + set (_configs ${CMAKE_BUILD_TYPE}) + endif() + foreach (_config ${_configs}) + cotire_get_target_compile_flags("${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" _targetFlags) + cotire_filter_compile_flags("arch" _architectures _ignore ${_targetFlags}) + list (LENGTH _architectures _numberOfArchitectures) + if (_numberOfArchitectures GREATER 1) + string (REPLACE ";" ", " _architectureStr "${_architectures}") + set (${_msgVar} + "Precompiled headers not supported on Darwin for multiple architecture builds (${_architectureStr})." + PARENT_SCOPE) + break() + endif() + endforeach() + endif() +endfunction() + +macro (cotire_get_intermediate_dir _cotireDir) + get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) +endmacro() + +function (cotire_make_untiy_source_file_paths _language _target _maxIncludes _unityFilesVar) + set (_sourceFiles ${ARGN}) + list (LENGTH _sourceFiles _numberOfSources) + set (_unityFileExt_C ".c") + set (_unityFileExt_CXX ".cxx") + if (NOT DEFINED _unityFileExt_${_language}) + set (${_unityFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + cotire_get_intermediate_dir(_baseDir) + set (_startIndex 0) + set (_index 0) + set (_unityFiles "") + foreach (_sourceFile ${_sourceFiles}) + get_source_file_property(_startNew "${_sourceFile}" COTIRE_START_NEW_UNITY_SOURCE) + math (EXPR _unityFileCount "${_index} - ${_startIndex}") + if (_startNew OR (_maxIncludes GREATER 0 AND NOT _unityFileCount LESS _maxIncludes)) + if (_index GREATER 0) + math (EXPR _endIndex "${_index} - 1") + set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") + list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + endif() + set (_startIndex ${_index}) + endif() + math (EXPR _index "${_index} + 1") + endforeach() + if (_startIndex EQUAL 0) + set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}") + list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + elseif (_startIndex LESS _numberOfSources) + math (EXPR _endIndex "${_index} - 1") + set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") + list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + endif() + set (${_unityFilesVar} ${_unityFiles} PARENT_SCOPE) + if (COTIRE_DEBUG) + message(STATUS "${_unityFiles}") + endif() +endfunction() + +function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar) + set (_prefixFileExt_C ".h") + set (_prefixFileExt_CXX ".hxx") + if (NOT _language) + set (_prefixFileBaseName "${_target}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_C}") + elseif (DEFINED _prefixFileExt_${_language}) + set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_${_language}}") + else() + set (_prefixFileBaseName "") + set (_prefixFileName "") + endif() + set (${_prefixFileBaseNameVar} "${_prefixFileBaseName}" PARENT_SCOPE) + set (${_prefixFileNameVar} "${_prefixFileName}" PARENT_SCOPE) +endfunction() + +function (cotire_make_prefix_file_path _language _target _prefixFileVar) + cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) + set (${_prefixFileVar} "" PARENT_SCOPE) + if (_prefixFileName) + if (NOT _language) + set (_language "C") + endif() + if (MSVC OR "${CMAKE_${_language}_COMPILER_ID}" MATCHES "GNU|Clang") + cotire_get_intermediate_dir(_baseDir) + set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE) + endif() + endif() +endfunction() + +function (cotire_make_pch_file_path _language _target _pchFileVar) + cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) + set (${_pchFileVar} "" PARENT_SCOPE) + if (_prefixFileBaseName AND _prefixFileName) + cotire_check_precompiled_header_support("${_language}" "${_target}" _msg) + if (NOT _msg) + if (XCODE) + # For Xcode, we completely hand off the compilation of the prefix header to the IDE + return() + endif() + cotire_get_intermediate_dir(_baseDir) + if (MSVC) + # MSVC uses the extension .pch added to the prefix header base name + set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE) + elseif ("${CMAKE_${_language}_COMPILER_ID}" MATCHES "GNU|Clang") + # GCC / Clang look for a precompiled header corresponding to the prefix header with the extension .gch appended + set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +function (cotire_select_unity_source_files _unityFile _sourcesVar) + set (_sourceFiles ${ARGN}) + if (_sourceFiles AND "${_unityFile}" MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}_([0-9]+)_([0-9]+)") + set (_startIndex ${CMAKE_MATCH_1}) + set (_endIndex ${CMAKE_MATCH_2}) + list (LENGTH _sourceFiles _numberOfSources) + if (NOT _startIndex LESS _numberOfSources) + math (EXPR _startIndex "${_numberOfSources} - 1") + endif() + if (NOT _endIndex LESS _numberOfSources) + math (EXPR _endIndex "${_numberOfSources} - 1") + endif() + set (_files "") + foreach (_index RANGE ${_startIndex} ${_endIndex}) + list (GET _sourceFiles ${_index} _file) + list (APPEND _files "${_file}") + endforeach() + else() + set (_files ${_sourceFiles}) + endif() + set (${_sourcesVar} ${_files} PARENT_SCOPE) +endfunction() + +function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar) + get_target_property(_targetSourceFiles ${_target} SOURCES) + set (_dependencySources "") + # depend on target's generated source files + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) + if (_generatedSources) + # but omit all generated source files that have the COTIRE_EXCLUDED property set to true + cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources}) + if (_excludedGeneratedSources) + list (REMOVE_ITEM _generatedSources ${_excludedGeneratedSources}) + endif() + # and omit all generated source files that have the COTIRE_DEPENDENCY property set to false explicitly + cotire_get_objects_with_property_off(_excludedNonDependencySources COTIRE_DEPENDENCY SOURCE ${_generatedSources}) + if (_excludedNonDependencySources) + list (REMOVE_ITEM _generatedSources ${_excludedNonDependencySources}) + endif() + if (_generatedSources) + list (APPEND _dependencySources ${_generatedSources}) + endif() + endif() + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_language} ${_target} unity source depends on ${_dependencySources}") + endif() + set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) +endfunction() + +function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar) + get_target_property(_targetSourceFiles ${_target} SOURCES) + # depend on target source files marked with custom COTIRE_DEPENDENCY property + set (_dependencySources "") + cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles}) + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_language} ${_target} prefix header DEPENDS ${_dependencySources}") + endif() + set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) +endfunction() + +function (cotire_generate_target_script _language _configurations _target _targetScriptVar) + set (COTIRE_TARGET_SOURCES ${ARGN}) + set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_cotire.cmake") + cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS) + cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS) + # set up variables to be configured + set (COTIRE_TARGET_LANGUAGE "${_language}") + set (COTIRE_TARGET_CONFIGURATIONS "${_configurations}") + cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) + get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) + get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) + get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS) + get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) + get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) + if (CMAKE_CONFIGURATION_TYPES) + set (COTIRE_TARGET_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}") + foreach (_config ${CMAKE_CONFIGURATION_TYPES}) + cotire_get_target_include_directories( + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_config}) + cotire_get_target_compile_definitions( + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_config}) + cotire_get_target_compiler_flags( + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_config}) + cotire_get_source_files_compile_definitions( + "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_config} ${COTIRE_TARGET_SOURCES}) + endforeach() + else() + set (COTIRE_TARGET_CONFIGURATION_TYPES "") + cotire_get_target_include_directories( + "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES) + cotire_get_target_compile_definitions( + "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS) + cotire_get_target_compiler_flags( + "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS) + cotire_get_source_files_compile_definitions( + "${CMAKE_BUILD_TYPE}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS ${COTIRE_TARGET_SOURCES}) + endif() + get_cmake_property(_vars VARIABLES) + string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") + # remove COTIRE_VERBOSE which is passed as a CMake define on command line + list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) + set (_contents "") + foreach (_var IN LISTS _matchVars ITEMS + MSVC CMAKE_GENERATOR CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + if (DEFINED ${_var}) + string (REPLACE "\"" "\\\"" _value "${${_var}}") + set (_contents "${_contents}set (${_var} \"${_value}\")\n") + endif() + endforeach() + cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) + set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) +endfunction() + +function (cotire_setup_pch_file_compilation _language _targetScript _prefixFile _pchFile) + set (_sourceFiles ${ARGN}) + if (MSVC) + # for Visual Studio, we attach the precompiled header compilation to the first source file + # the remaining files include the precompiled header, see cotire_setup_prefix_file_inclusion + if (_sourceFiles) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + list (GET _sourceFiles 0 _hostFile) + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_pch_compilation_flags( + "${_language}" "MSVC" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) + set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") + # make first source file depend on prefix header + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") + endif() + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + # for makefile based generator, we add a custom command to precompile the prefix header + if (_targetScript) + cotire_set_cmd_to_prologue(_cmds) + list (GET _sourceFiles 0 _hostFile) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") + file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") + endif() + set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) + add_custom_command(OUTPUT "${_pchFile}" + COMMAND ${_cmds} + DEPENDS "${_prefixFile}" + IMPLICIT_DEPENDS ${_language} "${_prefixFile}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) + endif() + endif() +endfunction() + +function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) + set (_sourceFiles ${ARGN}) + if (MSVC) + # for Visual Studio, we include the precompiled header in all but the first source file + # the first source file does the precompiled header compilation, see cotire_setup_pch_file_compilation + list (LENGTH _sourceFiles _numberOfSourceFiles) + if (_numberOfSourceFiles GREATER 1) + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + list (REMOVE_AT _sourceFiles 0) + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_pch_inclusion_flags( + "${_language}" "MSVC" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # make source files depend on precompiled header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") + endif() + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + if (NOT _wholeTarget) + # for makefile based generator, we force the inclusion of the prefix header for a subset + # of the source files, if this is a multi-language target or has excluded files + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + endif() + # make source files depend on precompiled header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") + endif() +endfunction() + +function (cotire_get_first_set_property_value _propertyValueVar _type _object) + set (_properties ${ARGN}) + foreach (_property ${_properties}) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (_propertyValue) + set (${_propertyValueVar} ${_propertyValue} PARENT_SCOPE) + return() + endif() + endforeach() + set (${_propertyValueVar} "" PARENT_SCOPE) +endfunction() + +function (cotire_setup_target_pch_usage _languages _target _wholeTarget) + if (MSVC) + # for Visual Studio, precompiled header inclusion is always done on the source file level + # see cotire_setup_prefix_file_inclusion + elseif (XCODE) + # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers + # if necessary, we also generate a single prefix header which includes all language specific prefix headers + set (_prefixFiles "") + foreach (_language ${_languages}) + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + if (_prefixFile) + list (APPEND _prefixFiles "${_prefixFile}") + endif() + endforeach() + set (_cmds ${ARGN}) + list (LENGTH _prefixFiles _numberOfPrefixFiles) + if (_numberOfPrefixFiles GREATER 1) + cotire_make_prefix_file_path("" ${_target} _prefixHeader) + cotire_setup_combine_command(${_target} "${_prefixHeader}" "${_prefixFiles}" _cmds) + else() + set (_prefixHeader "${_prefixFiles}") + endif() + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}") + endif() + add_custom_command(TARGET "${_target}" + PRE_BUILD ${_cmds} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Updating target ${_target} prefix headers" VERBATIM) + # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ + set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") + set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + if (_wholeTarget) + # for makefile based generator, we force inclusion of the prefix header for all target source files + # if this is a single-language target without any excluded files + set (_language "${_languages}") + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + endif() + endif() +endfunction() + +function (cotire_setup_unity_generation_commands _language _target _targetScript _unityFiles _cmdsVar) + set (_dependencySources "") + cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) + foreach (_unityFile ${_unityFiles}) + file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") + set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) + cotire_set_cmd_to_prologue(_unityCmd) + list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetScript}" "${_unityFile}") + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript} ${_dependencySources}") + endif() + add_custom_command( + OUTPUT "${_unityFile}" + COMMAND ${_unityCmd} + DEPENDS "${_targetScript}" ${_dependencySources} + COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) + endforeach() + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) + set (_sourceFiles ${ARGN}) + list (LENGTH _unityFiles _numberOfUnityFiles) + if (_numberOfUnityFiles GREATER 1) + # create a joint unity file from all unity file segments + cotire_make_untiy_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) + cotire_setup_combine_command(${_target} "${_unityFile}" "${_unityFiles}" ${_cmdsVar}) + else() + set (_unityFile "${_unityFiles}") + endif() + file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + set (_dependencySources "") + cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) + cotire_set_cmd_to_prologue(_prefixCmd) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" "${_unityFile}") + set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_targetScript} ${_unityFile} ${_dependencySources}") + endif() + add_custom_command( + OUTPUT "${_prefixFile}" + COMMAND ${_prefixCmd} + DEPENDS "${_targetScript}" "${_unityFile}" ${_dependencySources} + COMMENT "Generating ${_language} prefix header ${_prefixFileRelPath}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_combine_command _target _joinedFile _files _cmdsVar) + file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + set (_filesRelPaths "") + foreach (_file ${_files}) + file (RELATIVE_PATH _fileRelPath "${CMAKE_BINARY_DIR}" "${_file}") + list (APPEND _filesRelPaths "${_fileRelPath}") + endforeach() + cotire_set_cmd_to_prologue(_prefixCmd) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine" "${_joinedFile}" ${_filesRelPaths}) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") + endif() + set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) + add_custom_command( + OUTPUT "${_joinedFile}" + COMMAND ${_prefixCmd} + DEPENDS ${_files} + COMMENT "Generating ${_joinedFileRelPath}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_init_cotire_target_properties _target) + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER TRUE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD TRUE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN FALSE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}") + cotire_check_is_path_relative_to("${CMAKE_BINARY_DIR}" _isRelative "${CMAKE_SOURCE_DIR}") + if (NOT _isRelative) + set_property(TARGET ${_target} APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_BINARY_DIR}") + endif() + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET) + if (NOT _isSet) + if (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}") + else() + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "") + endif() + endif() +endfunction() + +function (cotire_make_target_message _target _languages _disableMsg _targetMsgVar) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + string (REPLACE ";" " " _languagesStr "${_languages}") + string (REPLACE ";" ", " _excludedStr "${ARGN}") + set (_targetMsg "") + if (NOT _targetUsePCH AND NOT _targetAddSCU) + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build and precompiled header.") + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetUsePCH) + if (_allExcludedSourceFiles) + set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr} without precompiled header.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header.") + endif() + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetAddSCU) + if (_allExcludedSourceFiles) + set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr} without unity build.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") + endif() + else() + if (_allExcludedSourceFiles) + set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr}.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired.") + endif() + endif() + set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) +endfunction() + +function (cotire_choose_target_languages _target _targetLanguagesVar) + set (_languages ${ARGN}) + set (_allSourceFiles "") + set (_allExcludedSourceFiles "") + set (_allCotiredSourceFiles "") + set (_targetLanguages "") + get_target_property(_targetSourceFiles ${_target} SOURCES) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + set (_disableMsg "") + foreach (_language ${_languages}) + get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER) + get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE) + if (_prefixHeader OR _unityBuildFile) + message (WARNING "Target ${_target} has already been cotired.") + set (${_targetLanguagesVar} "" PARENT_SCOPE) + return() + endif() + if (_targetUsePCH AND "${_language}" STREQUAL "C" OR "${_language}" STREQUAL "CXX") + cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) + if (_disableMsg) + set (_targetUsePCH FALSE) + endif() + endif() + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (_sourceFiles OR _excludedSources OR _cotiredSources) + list (APPEND _targetLanguages ${_language}) + endif() + if (_sourceFiles) + list (APPEND _allSourceFiles ${_sourceFiles}) + endif() + if (_excludedSources) + list (APPEND _allExcludedSourceFiles ${_excludedSources}) + endif() + if (_cotiredSources) + list (APPEND _allCotiredSourceFiles ${_cotiredSources}) + endif() + endforeach() + set (_targetMsgLevel STATUS) + if (_targetUsePCH) + list (LENGTH _allSourceFiles _numberOfSources) + if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + set (_disableMsg "Too few applicable sources.") + set (_targetUsePCH FALSE) + elseif (_allCotiredSourceFiles) + cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles}) + list (REMOVE_DUPLICATES _cotireTargets) + string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}") + set (_disableMsg "Target sources already include a precompiled header for target(s) ${_cotireTargets}.") + set (_disableMsg "${_disableMsg} Set target property COTIRE_ENABLE_PRECOMPILED_HEADER to FALSE for targets ${_target},") + set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.") + set (_targetMsgLevel SEND_ERROR) + set (_targetUsePCH FALSE) + elseif (XCODE AND _allExcludedSourceFiles) + # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target + set (_disableMsg "Exclusion of source files not supported for generator Xcode.") + set (_targetUsePCH FALSE) + endif() + endif() + set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU}) + cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles}) + if (_targetMsg) + if (NOT DEFINED COTIREMSG_${_target}) + set (COTIREMSG_${_target} "") + endif() + if (COTIRE_VERBOSE OR NOT "${_targetMsgLevel}" STREQUAL "STATUS" OR + NOT "${COTIREMSG_${_target}}" STREQUAL "${_targetMsg}") + # cache message to avoid redundant messages on re-configure + set (COTIREMSG_${_target} "${_targetMsg}" CACHE INTERNAL "${_target} cotire message.") + message (${_targetMsgLevel} "${_targetMsg}") + endif() + endif() + set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) +endfunction() + +function (cotire_process_target_language _language _configurations _target _wholeTargetVar _cmdsVar) + set (${_cmdsVar} "" PARENT_SCOPE) + get_target_property(_targetSourceFiles ${_target} SOURCES) + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (NOT _sourceFiles) + return() + endif() + get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + if (NOT _maxIncludes) + set (_maxIncludes 0) + endif() + cotire_make_untiy_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_sourceFiles} ${_cotiredSources}) + if (NOT _unityFiles) + return() + endif() + set (_wholeTarget ${${_wholeTargetVar}}) + cotire_generate_target_script( + ${_language} "${_configurations}" ${_target} _targetScript ${_sourceFiles}) + set (_cmds "") + cotire_setup_unity_generation_commands( + ${_language} ${_target} "${_targetScript}" "${_unityFiles}" _cmds ${_sourceFiles} ${_cotiredSources}) + cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) + if (_prefixFile) + cotire_setup_prefix_generation_command( + ${_language} ${_target} "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_sourceFiles} ${_cotiredSources}) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + if (_targetUsePCH) + cotire_make_pch_file_path(${_language} ${_target} _pchFile) + if (_pchFile) + cotire_setup_pch_file_compilation( + ${_language} "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + if (_excludedSources) + set (_wholeTarget FALSE) + endif() + cotire_setup_prefix_file_inclusion( + ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + endif() + endif() + endif() + # mark target as cotired for language + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE "${_unityFiles}") + if (_prefixFile) + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER "${_prefixFile}") + if (_targetUsePCH AND _pchFile) + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}") + endif() + endif() + set (${_wholeTargetVar} ${_wholeTarget} PARENT_SCOPE) + set (${_cmdsVar} ${_cmds} PARENT_SCOPE) +endfunction() + +function (cotire_setup_clean_target _target) + set (_cleanTargetName "${_target}${COTIRE_CLEAN_TARGET_SUFFIX}") + if (NOT TARGET "${_cleanTargetName}") + cotire_set_cmd_to_prologue(_cmds) + get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" ABSOLUTE) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${_outputDir}" "${COTIRE_INTDIR}" "${_target}") + add_custom_target(${_cleanTargetName} COMMAND ${_cmds} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Cleaning up target ${_target} cotire generated files" VERBATIM) + cotire_init_target("${_cleanTargetName}") + endif() +endfunction() + +function (cotire_setup_pch_target _languages _configurations _target) + if ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + # for makefile based generators, we add a custom target to trigger the generation of the cotire related files + set (_dependsFiles "") + foreach (_language ${_languages}) + set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) + if (NOT MSVC) + # Visual Studio only creates precompiled header as a side effect + list(INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) + endif() + cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) + if (_dependsFile) + list (APPEND _dependsFiles "${_dependsFile}") + endif() + endforeach() + if (_dependsFiles) + set (_pchTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}") + add_custom_target("${_pchTargetName}" DEPENDS ${_dependsFiles}) + cotire_init_target("${_pchTargetName}") + cotire_add_to_pch_all_target(${_pchTargetName}) + endif() + endif() +endfunction() + +function (cotire_setup_unity_build_target _languages _configurations _target) + set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") + # determine unity target sub type + get_target_property(_targetType ${_target} TYPE) + if ("${_targetType}" STREQUAL "EXECUTABLE") + get_target_property(_isWin32 ${_target} WIN32) + get_target_property(_isMacOSX_Bundle ${_target} MACOSX_BUNDLE) + if (_isWin32) + set (_unityTargetSubType WIN32) + elseif (_isMacOSX_Bundle) + set (_unityTargetSubType MACOSX_BUNDLE) + else() + set (_unityTargetSubType "") + endif() + elseif (_targetType MATCHES "(STATIC|SHARED|MODULE)_LIBRARY") + set (_unityTargetSubType "${CMAKE_MATCH_1}") + else() + message (FATAL_ERROR "Unknown target type ${_targetType}.") + endif() + # determine unity target sources + get_target_property(_targetSourceFiles ${_target} SOURCES) + set (_unityTargetSources ${_targetSourceFiles}) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + foreach (_language ${_languages}) + get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) + if (_unityFiles) + # remove source files that are included in the unity source + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (_sourceFiles OR _cotiredSources) + list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources}) + endif() + # then add unity source file instead + list (APPEND _unityTargetSources ${_unityFiles}) + # make unity files use precompiled header if there are multiple unity files + list (LENGTH _unityFiles _numberOfUnityFiles) + if (_targetUsePCH AND _numberOfUnityFiles GREATER ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + if (_prefixFile AND _pchFile) + cotire_setup_pch_file_compilation( + ${_language} "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) + cotire_setup_prefix_file_inclusion( + ${_language} ${_target} FALSE "${_prefixFile}" "${_pchFile}" ${_unityFiles}) + endif() + endif() + endif() + endforeach() + if (COTIRE_DEBUG) + message (STATUS "add ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") + endif() + # generate unity target + if ("${_targetType}" STREQUAL "EXECUTABLE") + add_executable(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) + else() + add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) + endif() + # copy output location properties + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ + LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_ + RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_ + Fortran_MODULE_DIRECTORY) + # copy output name + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ + LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ + OUTPUT_NAME OUTPUT_NAME_ + RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_ + PREFIX _POSTFIX SUFFIX) + # copy compile stuff + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ + COMPILE_FLAGS Fortran_FORMAT + INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_) + # copy link stuff + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH + LINKER_LANGUAGE LINK_DEPENDS + LINK_FLAGS LINK_FLAGS_ + LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_ + LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ + LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC + STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ + SOVERSION VERSION) + # copy Qt stuff + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + AUTOMOC AUTOMOC_MOC_OPTIONS) + # copy cmake stuff + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) + # copy platform stuff + if (APPLE) + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST + OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) + elseif (WIN32) + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + GNUtoMS + VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_KEYWORD + VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER) + endif() + # use output name from original target + get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) + if (NOT _targetOutputName) + set_property(TARGET ${_unityTargetName} PROPERTY OUTPUT_NAME "${_target}") + endif() + # use export symbol from original target + cotire_get_target_export_symbol("${_target}" _defineSymbol) + if (_defineSymbol) + set_property(TARGET ${_unityTargetName} PROPERTY DEFINE_SYMBOL "${_defineSymbol}") + if ("${_targetType}" STREQUAL "EXECUTABLE") + set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) + endif() + endif() + cotire_init_target(${_unityTargetName}) + cotire_add_to_unity_all_target(${_unityTargetName}) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") +endfunction() + +function (cotire_target _target) + set(_options "") + set(_oneValueArgs "") + set(_multiValueArgs LANGUAGES CONFIGURATIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_LANGUAGES) + get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + endif() + if (NOT _option_CONFIGURATIONS) + if (CMAKE_CONFIGURATION_TYPES) + set (_option_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) + else() + set (_option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}") + endif() + endif() + # trivial checks + get_target_property(_imported ${_target} IMPORTED) + if (_imported) + message (WARNING "Imported target ${_target} cannot be cotired") + return() + endif() + # check if target needs to be cotired for build type + # when using configuration types, the test is performed at build time + cotire_init_cotire_target_properties(${_target}) + if (NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE AND _option_CONFIGURATIONS) + list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index) + if (_index EQUAL -1) + return() + endif() + endif() + # choose languages that apply to the target + cotire_choose_target_languages("${_target}" _targetLanguages ${_option_LANGUAGES}) + if (NOT _targetLanguages) + return() + endif() + list (LENGTH _targetLanguages _numberOfLanguages) + if (_numberOfLanguages GREATER 1) + set (_wholeTarget FALSE) + else() + set (_wholeTarget TRUE) + endif() + set (_cmds "") + foreach (_language ${_targetLanguages}) + cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" ${_target} _wholeTarget _cmd) + if (_cmd) + list (APPEND _cmds ${_cmd}) + endif() + endforeach() + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + if (_targetAddSCU) + cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + endif() + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + if (_targetUsePCH) + cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds}) + cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + endif() + get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) + if (_targetAddCleanTarget) + cotire_setup_clean_target(${_target}) + endif() +endfunction() + +function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) + if (_targetName) + file (GLOB_RECURSE _cotireFiles "${_binaryDir}/${_targetName}*.*") + else() + file (GLOB_RECURSE _cotireFiles "${_binaryDir}/*.*") + endif() + # filter files in intermediate directory + set (_filesToRemove "") + foreach (_file ${_cotireFiles}) + get_filename_component(_dir "${_file}" PATH) + get_filename_component(_dirName "${_dir}" NAME) + if ("${_dirName}" STREQUAL "${_cotireIntermediateDirName}") + list (APPEND _filesToRemove "${_file}") + endif() + endforeach() + if (_filesToRemove) + if (COTIRE_VERBOSE) + message (STATUS "removing ${_filesToRemove}") + endif() + file (REMOVE ${_filesToRemove}) + endif() +endfunction() + +function (cotire_init_target _targetName) + if (COTIRE_TARGETS_FOLDER) + set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}") + endif() + if (MSVC_IDE) + set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) + endif() +endfunction() + +function (cotire_add_to_pch_all_target _pchTargetName) + set (_targetName "${COTIRE_PCH_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + cotire_init_target("${_targetName}") + endif() + cotire_setup_clean_all_target() + add_dependencies(${_targetName} ${_pchTargetName}) +endfunction() + +function (cotire_add_to_unity_all_target _unityTargetName) + set (_targetName "${COTIRE_UNITY_BUILD_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + cotire_init_target("${_targetName}") + endif() + cotire_setup_clean_all_target() + add_dependencies(${_targetName} ${_unityTargetName}) +endfunction() + +function (cotire_setup_clean_all_target) + set (_targetName "${COTIRE_CLEAN_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + cotire_set_cmd_to_prologue(_cmds) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${CMAKE_BINARY_DIR}" "${COTIRE_INTDIR}") + add_custom_target(${_targetName} COMMAND ${_cmds} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Cleaning up all cotire generated files" VERBATIM) + cotire_init_target("${_targetName}") + endif() +endfunction() + +function (cotire) + set(_options "") + set(_oneValueArgs "") + set(_multiValueArgs LANGUAGES CONFIGURATIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + set (_targets ${_option_UNPARSED_ARGUMENTS}) + foreach (_target ${_targets}) + if (TARGET ${_target}) + cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS}) + else() + message (WARNING "${_target} is not a target") + endif() + endforeach() +endfunction() + +if (CMAKE_SCRIPT_MODE_FILE) + + # cotire is being run in script mode + # locate -P on command args + set (COTIRE_ARGC -1) + foreach (_index RANGE ${CMAKE_ARGC}) + if (COTIRE_ARGC GREATER -1) + set (COTIRE_ARGV${COTIRE_ARGC} "${CMAKE_ARGV${_index}}") + math (EXPR COTIRE_ARGC "${COTIRE_ARGC} + 1") + elseif ("${CMAKE_ARGV${_index}}" STREQUAL "-P") + set (COTIRE_ARGC 0) + endif() + endforeach() + + if (COTIRE_DEBUG) + message ("${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") + endif() + + # include target script if available + if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$") + include("${COTIRE_ARGV2}") + endif() + + if (APPLE AND "$ENV{DEVELOPER_BIN_DIR}" MATCHES ".+") + # for Xcode, override compiler executables used + if ("$ENV{GCC_VERSION}" MATCHES "clang") + set (CMAKE_C_COMPILER_ID "Clang") + set (CMAKE_CXX_COMPILER_ID "Clang") + set (CMAKE_C_COMPILER "$ENV{DEVELOPER_BIN_DIR}/clang") + set (CMAKE_CXX_COMPILER "$ENV{DEVELOPER_BIN_DIR}/clang++") + else() + set (CMAKE_C_COMPILER_ID "GNU") + set (CMAKE_CXX_COMPILER_ID "GNU") + set (CMAKE_C_COMPILER "$ENV{DEVELOPER_BIN_DIR}/cc") + set (CMAKE_CXX_COMPILER "$ENV{DEVELOPER_BIN_DIR}/g++") + endif() + elseif (WIN32) + # for MSVC, compiler IDs may not always be set correctly + if (MSVC) + set (CMAKE_C_COMPILER_ID "MSVC") + set (CMAKE_CXX_COMPILER_ID "MSVC") + endif() + endif() + + if (COTIRE_TARGET_CONFIGURATION_TYPES) + set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${COTIRE_BUILD_TYPE}}) + set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) + set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${COTIRE_BUILD_TYPE}}) + # check if target has been cotired for actual build type COTIRE_BUILD_TYPE + list (FIND COTIRE_TARGET_CONFIGURATIONS "${COTIRE_BUILD_TYPE}" _index) + if (_index GREATER -1) + set (_sources ${COTIRE_TARGET_SOURCES}) + set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) + else() + set (_sources "") + set (_sourcesDefinitions "") + endif() + else() + set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES}) + set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS}) + set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS}) + set (_sources ${COTIRE_TARGET_SOURCES}) + set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS}) + endif() + set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) + set (_targetPostUndefs ${COTIRE_TARGET_POST_UNDEFS}) + set (_sourcesPreUndefs ${COTIRE_TARGET_SOURCES_PRE_UNDEFS}) + set (_sourcesPostUndefs ${COTIRE_TARGET_SOURCES_POST_UNDEFS}) + + if (${COTIRE_ARGV1} STREQUAL "unity") + + cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) + cotire_generate_unity_source( + "${COTIRE_ARGV3}" ${_sources} + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" ${COTIRE_TARGET_UNITY_DEPENDS} + SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} + PRE_UNDEFS ${_targetPreUndefs} + POST_UNDEFS ${_targetPostUndefs} + SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} + SOURCES_POST_UNDEFS ${_sourcesPostUndefs}) + + elseif (${COTIRE_ARGV1} STREQUAL "prefix") + + set (_files "") + foreach (_index RANGE 4 ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + + cotire_generate_prefix_header( + "${COTIRE_ARGV3}" ${_files} + COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" + COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS} + IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" + INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} + IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" + INCLUDE_DIRECTORIES ${_includeDirs} + COMPILE_DEFINITIONS ${_compileDefinitions} + COMPILE_FLAGS ${_compileFlags}) + + elseif (${COTIRE_ARGV1} STREQUAL "precompile") + + set (_files "") + foreach (_index RANGE 5 ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + + cotire_precompile_prefix_header( + "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}" + COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" + COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + INCLUDE_DIRECTORIES ${_includeDirs} + COMPILE_DEFINITIONS ${_compileDefinitions} + COMPILE_FLAGS ${_compileFlags}) + + elseif (${COTIRE_ARGV1} STREQUAL "combine") + + set (_files "") + foreach (_index RANGE 2 ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + cotire_generate_unity_source(${_files}) + + elseif (${COTIRE_ARGV1} STREQUAL "cleanup") + + cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}") + + else() + message (FATAL_ERROR "Unknown command ${COTIRE_ARGV1}.") + endif() + +else() + + # cotire is being run in include mode + # set up all variable and property definitions + + unset (COTIRE_C_COMPILER_VERSION CACHE) + unset (COTIRE_CXX_COMPILER_VERSION CACHE) + + if (NOT DEFINED COTIRE_DEBUG_INIT) + if (DEFINED COTIRE_DEBUG) + set (COTIRE_DEBUG_INIT ${COTIRE_DEBUG}) + else() + set (COTIRE_DEBUG_INIT FALSE) + endif() + endif() + option (COTIRE_DEBUG "Enable cotire debugging output?" ${COTIRE_DEBUG_INIT}) + + if (NOT DEFINED COTIRE_DEBUG_INIT) + if (DEFINED COTIRE_VERBOSE) + set (COTIRE_VERBOSE_INIT ${COTIRE_VERBOSE}) + else() + set (COTIRE_VERBOSE_INIT FALSE) + endif() + endif() + option (COTIRE_VERBOSE "Enable cotire verbose output?" ${COTIRE_VERBOSE_INIT}) + + set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "inc;inl;ipp" CACHE STRING + "Ignore headers with the listed file extensions from the generated prefix header.") + + set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "" CACHE STRING + "Ignore headers from these directories when generating the prefix header.") + + set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING + "Minimum number of sources in target required to enable use of precompiled header.") + + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "" CACHE STRING + "Maximum number of source files to include in a single unity source file.") + + if (NOT COTIRE_PREFIX_HEADER_FILENAME_SUFFIX) + set (COTIRE_PREFIX_HEADER_FILENAME_SUFFIX "_prefix") + endif() + if (NOT COTIRE_UNITY_SOURCE_FILENAME_SUFFIX) + set (COTIRE_UNITY_SOURCE_FILENAME_SUFFIX "_unity") + endif() + if (NOT COTIRE_INTDIR) + set (COTIRE_INTDIR "cotire") + endif() + if (NOT COTIRE_PCH_ALL_TARGET_NAME) + set (COTIRE_PCH_ALL_TARGET_NAME "all_pch") + endif() + if (NOT COTIRE_UNITY_BUILD_ALL_TARGET_NAME) + set (COTIRE_UNITY_BUILD_ALL_TARGET_NAME "all_unity") + endif() + if (NOT COTIRE_CLEAN_ALL_TARGET_NAME) + set (COTIRE_CLEAN_ALL_TARGET_NAME "clean_cotire") + endif() + if (NOT COTIRE_CLEAN_TARGET_SUFFIX) + set (COTIRE_CLEAN_TARGET_SUFFIX "_clean_cotire") + endif() + if (NOT COTIRE_PCH_TARGET_SUFFIX) + set (COTIRE_PCH_TARGET_SUFFIX "_pch") + endif() + if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX) + set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity") + endif() + if (NOT DEFINED COTIRE_TARGETS_FOLDER) + set (COTIRE_TARGETS_FOLDER "cotire") + endif() + + # define cotire cache variables + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH" + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "The variable can be set to a semicolon separated list of include directories." + "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." + "If not defined, defaults to empty list." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS" + BRIEF_DOCS "Ignore includes with the listed file extensions from the prefix header when generating the prefix header." + FULL_DOCS + "The variable can be set to a semicolon separated list of file extensions." + "If a header file extension matches one in the list, it will be excluded from the generated prefix header." + "Includes with an extension in CMAKE__SOURCE_FILE_EXTENSIONS are always ignored." + "If not defined, defaults to inc;inl;ipp." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES" + BRIEF_DOCS "Minimum number of sources in target required to enable use of precompiled header." + FULL_DOCS + "The variable can be set to an integer > 0." + "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target." + "If not defined, defaults to 3." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES" + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "This may be set to an integer > 0." + "If a target contains more than that number of source files, cotire will create multiple unity source files for it." + "If not set, cotire will only create a single unity source file." + "Is use to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." + "Defaults to empty." + ) + + # define cotire directory properties + + define_property( + DIRECTORY PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" + BRIEF_DOCS "Modify build command of cotired targets added in this directory to make use of the generated precompiled header." + FULL_DOCS + "See target property COTIRE_ENABLE_PRECOMPILED_HEADER." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_ADD_UNITY_BUILD" + BRIEF_DOCS "Add a new target that performs a unity build for cotired targets added in this directory." + FULL_DOCS + "See target property COTIRE_ADD_UNITY_BUILD." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_ADD_CLEAN" + BRIEF_DOCS "Add a new target that cleans all cotire generated files for cotired targets added in this directory." + FULL_DOCS + "See target property COTIRE_ADD_CLEAN." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_IGNORE_PATH." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" + BRIEF_DOCS "Honor headers from these directories when generating the prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_INCLUDE_PATH." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_PRE_UNDEFS." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_POST_UNDEFS." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." + ) + + # define cotire target properties + + define_property( + TARGET PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" INHERITED + BRIEF_DOCS "Modify this target's build command to make use of the generated precompiled header." + FULL_DOCS + "If this property is set to TRUE, cotire will modify the build command to make use of the generated precompiled header." + "Irrespective of the value of this property, cotire will setup custom commands to generate the unity source and prefix header for the target." + "For makefile based generators cotire will also set up a custom target to manually invoke the generation of the precompiled header." + "The target name will be set to this target's name with the suffix _pch appended." + "Inherited from directory." + "Defaults to TRUE." + ) + + define_property( + TARGET PROPERTY "COTIRE_ADD_UNITY_BUILD" INHERITED + BRIEF_DOCS "Add a new target that performs a unity build for this target." + FULL_DOCS + "If this property is set to TRUE, cotire creates a new target of the same type that uses the generated unity source file instead of the target sources." + "Most of the relevant target properties will be copied from this target to the new unity build target." + "Target dependencies and linked libraries have to be manually set up for the new unity build target." + "The unity target name will be set to this target's name with the suffix _unity appended." + "Inherited from directory." + "Defaults to TRUE." + ) + + define_property( + TARGET PROPERTY "COTIRE_ADD_CLEAN" INHERITED + BRIEF_DOCS "Add a new target that cleans all cotire generated files for this target." + FULL_DOCS + "If this property is set to TRUE, cotire creates a new target that clean all files (unity source, prefix header, precompiled header)." + "The clean target name will be set to this target's name with the suffix _clean_cotire appended." + "Inherited from directory." + "Defaults to FALSE." + ) + + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" INHERITED + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." + "Inherited from directory." + "If not set, this property is initialized to \${CMAKE_SOURCE_DIR};\${CMAKE_BINARY_DIR}." + ) + + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" INHERITED + BRIEF_DOCS "Honor headers from these directories when generating the prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "If a header file is found in one of these directories or sub-directories, it will be included in the generated prefix header." + "If a header file is both selected by COTIRE_PREFIX_HEADER_IGNORE_PATH and COTIRE_PREFIX_HEADER_INCLUDE_PATH," + "the option which yields the closer relative path match wins." + "Inherited from directory." + "If not set, this property is initialized to the empty list." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file before each target source file." + "Inherited from directory." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" INHERITED + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each target source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file after each target source file." + "Inherited from directory." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" INHERITED + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "This may be set to an integer > 0." + "If a target contains more than that number of source files, cotire will create multiple unity build files for it." + "If not set, cotire will only create a single unity source file." + "Inherited from directory." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE__UNITY_SOURCE" + BRIEF_DOCS "Read-only property. The generated unity source file(s)." + FULL_DOCS + "cotire sets this property to the path of the generated single computation unit source file for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE__PREFIX_HEADER" + BRIEF_DOCS "Read-only property. The generated prefix header file." + FULL_DOCS + "cotire sets this property to the full path of the generated language prefix header for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE__PRECOMPILED_HEADER" + BRIEF_DOCS "Read-only property. The generated precompiled header file." + FULL_DOCS + "cotire sets this property to the full path of the generated language precompiled header binary for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_TARGET_NAME" + BRIEF_DOCS "Read-only property. The name of the generated unity build target corresponding to this target." + FULL_DOCS + "cotire sets this property to the name the generated unity build target for this target." + "Defaults to empty string." + ) + + # define cotire source properties + + define_property( + SOURCE PROPERTY "COTIRE_EXCLUDED" + BRIEF_DOCS "Do not modify source file's build command." + FULL_DOCS + "If this property is set to TRUE, the source file's build command will not be modified to make use of the precompiled header." + "The source file will also be excluded from the generated unity source file." + "Source files that have their COMPILE_FLAGS property set will be excluded by default." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_DEPENDENCY" + BRIEF_DOCS "Add this source file to dependencies of the automatically generated prefix header file." + FULL_DOCS + "If this property is set to TRUE, the source file is added to dependencies of the generated prefix header file." + "If the file is modified, cotire will re-generate the prefix header source upon build." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of this source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file before this file is included." + "Defaults to empty string." + ) + + define_property( + SOURCE PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of this source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file after this file is included." + "Defaults to empty string." + ) + + define_property( + SOURCE PROPERTY "COTIRE_START_NEW_UNITY_SOURCE" + BRIEF_DOCS "Start a new unity source file which includes this source file as the first one." + FULL_DOCS + "If this property is set to TRUE, cotire will complete the current unity file and start a new one." + "The new unity source file will include this source file as the first one." + "This property essentially works as a separator for unity source files." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_TARGET" + BRIEF_DOCS "Read-only property. Mark this source file as cotired for the given target." + FULL_DOCS + "cotire sets this property to the name of target, that the source file's build command has been altered for." + "Defaults to empty string." + ) + +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a522c9a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +# cotire example project + +cmake_minimum_required(VERSION 2.8.5) + +project (CotireExample) + +set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") + +include(cotire) + +add_subdirectory(src) diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..52b21a8 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,3 @@ +## 1.0.0 (2012-03-11) + +* First release diff --git a/MANUAL.md b/MANUAL.md new file mode 100644 index 0000000..03a17bd --- /dev/null +++ b/MANUAL.md @@ -0,0 +1,403 @@ +cotire manual +============= + +Cotire (compile time reducer) is a CMake module that speeds up the build process of CMake based +build systems by fully automating techniques as [precompiled header][pch] usage and +[single compilation unit][scu] builds for C and C++. + +motivation +---------- + +Cotire was born out of a dissatisfaction with the existing CMake solutions for adding +[precompiled header][1260] support and [unity build][gmixer] support to CMake based build systems. +The design of cotire tries to adhere to the following principles: + +#### as automatic as possible + +[Precompiled header][pch] and [unity builds][scu] are good ideas in principle, but in reality +they do not work if the burdon of maintaining the required additional source files (a +[prefix header][pfh] and a unity source file) is put on the developer. A modern build system +like CMake provides enough context information to have the build system generate and update +these files automatically. + +#### non-intrusive + +The configuration of precompiled headers usage and single computation unit builds belongs to the +build system and not in the source code. Nobody wants to litter one's source files with `hdrstop` +pragmas or be forced to add an include directive to every file. The same source code should build +properly when a precompiled header isn't used and should build faster when a precompiled header +is used. + +#### minimal interface + +Maintaining a build system over time is enough work and the CMake language may often get in your +way. Thus the solution should only add few public CMake functions. It should be easy to integrate +it into an existing CMake based build system and it should be just as easy to remove it again. + +#### lazy file creation + +The additional source files needed for precompiled header support and unity build support should +only be created when they are required for the compilation of a target. Thus the solution should +not create these files upon configuring the project, but should set up custom build commands for +the creation of these files that only kick in when the files are required to exist by the build +process. + +#### cross-platform + +C/C++ Compilers and IDEs on different platforms vary widely in how the implement precompiled +header support. The solution should hide these implementation details and present a uniform +interface to the developer on all supported platforms. + +cotire basic usage +------------------ + +Cotire consists of a single CMake module file, which can be easily added to an existing CMake +project. + +The file `CMake/cotire.cmake` needs to be copied to the module directory of a CMake project. In the +top-level `CMakeList.txt` file, the module directory needs to be added to the CMake module search +path: + + set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") + +To use cotire in a CMake project, one adds the following include directive to the beginning of the +top-level `CMakeList.txt`: + + include(cotire) + +To speed the build process of a CMake library or executable target, the `cotire` function is +applied to a CMake target. From the example project that ships with cotire: + + add_executable(example main.cpp example.cpp log.cpp log.h example.h) + ... + cotire(example) + +Cotire looks at the properties of the target provided by CMake (e.g., target type, source files, +compile flags, preprocessor defines, include directories, ...) and modifies the target's build +process in the following way: + +1. cotire adds a custom build rule to produce a unity source file from target's sources. +2. cotire adds a custom build rule to produce a prefix header file by tracking the header files + included by the target's sources. +3. cotire adds a custom build rule to produce a precompiled header from the prefix header. +4. cotire modifies the target's compile flags to make use of the generated precompiled header. +5. cotire adds a couple of new targets. + +For makefile based build systems, running `make help` in the terminal reveals the new targets: + + $ make help + ... + ... all_pch + ... all_unity + ... clean_cotire + ... example + ... example_pch + ... example_unity + +The `example_pch` target triggers the compilation of the precompiled header and as a side effect +the generation of the unity source and the prefix header. The target `clean_cotire` cleans up all +files generated by cotire. The `example_unity` target produces the same output as the original +`example` target, but does so by performing a unity build. The `all_pch` and `all_unity` serve as +pool targets for all cotired project targets. + +The `example_unity` target inherits all build settings from the original target `example` except +for linked libraries and target dependencies. To get a linkable unity target, the required +libraries have to be added manually to the unity target with `target_link_libraries`. + +cotire generated files +---------------------- + +For a target that has been cotired, three files will be generated as part of the build process: + +### the unity source + +The unity source file is generated from the target by querying the target's `SOURCES` property. +It consists of preprocessor include directives for each of the target source files. The files +are included in the same order that is used in the CMake `add_executable` or `add_library` call. +Header files are omitted. + +This is a unity source generated for the example project under Mac OS X: + + #ifdef __cplusplus + #include "/Users/sakra/Documents/cotire/src/main.cpp" + #include "/Users/sakra/Documents/cotire/src/example.cpp" + #include "/Users/sakra/Documents/cotire/src/log.cpp" + #endif + +The unity source file uses absolute paths to include the target's source file. The file is not +intended to be portable across different build folders or machines. It is an intermediate file +tied to the build folder that is automatically recreated by the build system if it is missing. + +### the prefix header + +The prefix header is produced from the unity source file by running the unity file through the +preprocessor and keeping track of each header file used (this is done by using option `-H` with +GCC / Clang and `/showIncludes` with Visual Studio C++). The path of each used header file is +compared against an exclude directory list and an include directory list to decide if the header +file should be added to the prefix header. + +By default the include directory list is empty and the exclude directory list is initialized to +`"${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}"`. This default setting guarantees that project headers +which are likely to be changed frequently are not added to the prefix header. + +Upon generation of the prefix header cotire makes sure that target compile options, include path +settings and preprocessor defines (e.g., `NDEBUG`) that affect the outcome of the preprocessor +are correctly set up. + +Generating the prefix header from the unity source is much faster than running each individual +target source file through the preprocessor, because the coalesced unity source will make the +preprocessor process most header files only once. + +This is a prefix header produced for the example project with Visual Studio 2008 under Windows: + + #ifdef __cplusplus + #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string" + #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\algorithm" + #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iostream" + #endif + +Generating the prefix file under Ubuntu Linux with GCC 4.6 yields the following result: + + #ifdef __cplusplus + #include "/usr/include/c++/4.6/string" + #include "/usr/include/c++/4.6/algorithm" + #include "/usr/include/c++/4.6/iterator" + #include "/usr/include/c++/4.6/iostream" + #endif + +Using Clang 3.1 under Mac OS X 10.7 this is the resulting prefix header: + + #ifdef __cplusplus + #include "/usr/include/c++/4.2.1/string" + #include "/usr/include/c++/4.2.1/iostream" + #include "/usr/include/c++/4.2.1/iterator" + #endif + +Cotire attempts to produce a minimal list of header files by omitting header files indirectly +included by a header that is already part of the prefix header. Header files with nonstandard +file extensions like `.inl`, `.inc` of `.ipp` are omitted by default. + +The generated prefix file includes the selected header files by their absolute paths. This speeds +up the precompiling of the prefix header because the compiler does not have to search for header +files in include directories again. + +The prefix header is tailored to the CMake target that it is generated for and cannot be re-used +for a different CMake target. It is tied to the compiler environment of the local machine and +is not portable across different compilers or machines. It is automatically recreated by the +build system if it goes missing. + +### the precompiled header + +The precompiled header is produced from the generated prefix header by using the proprietary +precompiling mechanism depending on the compiler used. For GCC and Clang cotire sets up a custom +build rule and generates the precompiled header as described in the documentation for +[GCC][gcc_pch] and [Clang][clang_pch]. Cotire then modifies the `COMPILE_FLAGS` property of the +target to force the inclusion of the prefix header. + +Visual Studio C++ uses a [different approach][msvc_pch] to pre-compiling. It requires a host +source file to generate the precompiled header as a side effect of producing an object file. +Cotire modifies the `COMPILE_FLAGS` of the first target source file to [generate][msvc_pch_create] +the precompiled header and then modifies the `COMPILE_FLAGS` of the remaining target source files +to [include][msvc_pch_use] the generated precompiled header. + +For Xcode projects generated with CMake, cotire completely hands off the pre-compilation of +the prefix header and the inclusion of the precompiled header to the IDE. Cotire attaches a +pre-build action to the target which generates the unity source file and the prefix header. +Cotire then modifies Xcode attributes of the generated Xcode project to have Xcode precompile the +the generated prefix header with the Xcode build steps `ProcessPCH` for C sources and +`ProcessPCH++` for C++ sources. + +For precompiled headers creation flags must match use flags exactly. Cotire uses the same flags, +include directories and preprocessor defines that are used for the compilation of source files +for the generation of the precompiled header. Thus the resulting precompiled header binary is only +usable for the target and cannot be re-used for a different CMake target. + +cotire advanced usage +--------------------- + +### mixed-language targets + +Cotire is able to speed up the build process of mixed language targets, consisting of both C and +C++ sources. It generates a separate set of unity source files, prefix headers and precompiled +headers for both languages and modifies the `COMPILE_FLAGS` of each target source file to include +the correct precompiled header depending on the compilation language of the source file. + +### obtaining the names of the generated files and targets + +For a cotired target the target properties `COTIRE__UNITY_SOURCE`, +`COTIRE__PREFIX_HEADER`, `COTIRE__PRECOMPILED_HEADER` will be set to the paths of the +generated files (`` can be set to `CXX` or `C`). The target property +`COTIRE_UNITY_TARGET_NAME` will be set to the name of the generated unity target. + +If a source file's `COMPILE_FLAGS` are modified by cotire, it sets the source file property +`COTIRE_TARGET` to the name of the target, that the source file's build command has been +altered for. + +### restricting cotire to certain build configurations + +To restrict the cotire related modifications to the build process to certain build configurations, +the `CONFIGURATIONS` parameter can be added to the `cotire` call. + + cotire(example CONFIGURATIONS Release MinSizeRel) + +For single build type builds the selected configuration will be checked at configure time, for +multi-configuration builds the check will be done at build time. + +It is recommended to have at least one build configuration that does not make use of cotire to +ensure that the project builds properly without cotire. + +### disabling precompiled headers and unity builds + +If the target's build process should not be modified to make us of the generated precompiled +header, the target property `COTIRE_ENABLE_PRECOMPILED_HEADER` can be set to `FALSE`: + + set_target_properties(example PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) + cotire(example) + +If a unity build target should not be added by cotire, the target property +`COTIRE_ADD_UNITY_BUILD` can be set to `FALSE`: + + set_target_properties(example PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) + cotire(example) + +Both properties default to TRUE. If both are set to FALSE, cotire will only set up custom build +rules for the generation of the unity source and the prefix header. + +The properties `COTIRE_ENABLE_PRECOMPILED_HEADER` and `COTIRE_ADD_UNITY_BUILD` can also be set on +directories. A target inherits the property value from its enclosing directory. + +### disabling precompiled headers for small targets + +The cache variable `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` can be set to the minimum number of +source files required to enable the use of precompiled header. It defaults to 3. + +### configuring the generation of the prefix header + +There are multiple target properties which affect the generation of the prefix header: + +* `COTIRE_PREFIX_HEADER_IGNORE_PATH` can be set to a semicolon separated list of directories. If a +header file is found in one of these directories or sub-directories, it will be excluded from the +generated prefix header. + +* `COTIRE_PREFIX_HEADER_INCLUDE_PATH` can be set to a semicolon separated list of directories. If +a header file is included from one of these directories or sub-directories, it will be included +in the generated prefix header. + +If a header file is matched by both `COTIRE_PREFIX_HEADER_IGNORE_PATH` and +`COTIRE_PREFIX_HEADER_INCLUDE_PATH`, the option which yields the closer relative path match wins. +For example, if third-party libraries are part of the source tree in a directory called `Libs`, +the following setting will make cotire select header files from the third-party directory, but +ignore other project related headers in `CMAKE_SOURCE_DIR`: + + set_target_properties(example PROPERTIES + COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}" + COTIRE_PREFIX_HEADER_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/Libs") + +The properties `COTIRE_PREFIX_HEADER_IGNORE_PATH` and `COTIRE_PREFIX_HEADER_INCLUDE_PATH` can +also be set on directories. + +The following cache variables also affect the selection of prefix headers. + +* Directory paths in `COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH` will be added to the list of +ignored directories when the prefix header file is created. + +* `COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS` can be used to ignore header files by file +extension. It defaults to the CMake list `inc;inl;ipp`. + +During development changes to the project source files may affect the list of header files that +should be selected for inclusion in the prefix header (e.g., a standard include may be added or +removed from a target source file). Cotire does not automatically recreate the prefix header, +when a target source file is changed, because this would always trigger a re-compilation of the +precompiled header and would result in a rebuild of the whole target. To make the prefix header +creation dependent on changes to certain target source files, the source file property +`COTIRE_DEPENDENCY` can be set to `TRUE` for those files. + +### configuring the generation of the unity source + +By default cotire adds all target source file to the generated unity source. In most cases a +unity build will not work out of the box, because unity builds [break][EoUB] the use of some C +and C++ language features. Unity build problems can be tackled in the following way: + +* Change the order of the source files in the `add_executable` or `add_library` calls. +Problematic source files should be moved towards the end. + +* Set the source file property `COTIRE_EXCLUDED` on problematic source files. The source file +will not be included in the unity source file and will be compiled separately when the unity build +is performed. + +* If the unity source file is too large and the compilation process runs into a compiler limit, +the target property `COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES` can be set. If the target +contains more than that number of source files, cotire will create multiple unity source files +for it. Each unity source file is compiled separately when the unity build is performed. +The property is initialized by value of the cache variable +`COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES`. + +* Another way to break up a large unity source file is to set the source file property +`COTIRE_START_NEW_UNITY_SOURCE` to `TRUE` on selected target source files. If cotire encounters +this property, it will complete the current unity file and start a new one. The new unity source +file will include the source file as the first one. This property essentially works as a separator +for unity source files. + +### fixing macro definition clashes + +Many unity build problems stem from macro definitions leaking into other target source files, +where they may conflict with other definitions of the same name. Cotire adds the properties +`COTIRE_UNITY_SOURCE_PRE_UNDEFS` and `COTIRE_UNITY_SOURCE_POST_UNDEFS` to fix macro definition +clashes. + +As an example, if these properties are set on a source file of the example project: + + set_source_files_properties (log.cpp PROPERTIES + COTIRE_UNITY_SOURCE_PRE_UNDEFS "max;min" + COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") + +This will make cotire add #undefs to the generated unity source file. + + #ifdef __cplusplus + #include "/Users/sakra/Documents/cotire/src/main.cpp" + #undef min + #undef max + #include "/Users/sakra/Documents/cotire/src/example.cpp" + #undef DEBUG_TYPE + #include "/Users/sakra/Documents/cotire/src/log.cpp" + #endif + +The properties `COTIRE_UNITY_SOURCE_PRE_UNDEFS` and `COTIRE_UNITY_SOURCE_POST_UNDEFS` can also be +set on targets. Cotire will add #undefs for each source file in the unity source then. + +### enabling verbose builds + +The cache variable `COTIRE_VERBOSE` can be set to `TRUE` to see all compile commands used when +generating the cotire related files. Cotire will also print the contents of the generated unity +source and the prefix header for verbose builds. `COTIRE_VERBOSE` defaults to `FALSE`. +When using a Makefile generator `COTIRE_VERBOSE` defaults to the value of the makefile variable +`VERBOSE` (i.e., `make VERBOSE=1`). + +cotire usage restrictions +------------------------- + +### using source files for multiple targets + +When the same set of source files is used for different targets (e.g., for producing a static +and a shared library variant from the same sources), using a precompiled header may not work. +Under certain circumstances, cotire cannot enable the precompiled header usage by changing the +`COMPILE_FLAGS` property of the whole target, but must set the `COMPILE_FLAGS` properties of +individual target source files instead. This will break the usage of the source file for +multiple targets. + +### multi-architecture builds under Mac OS X + +Neither GCC nor Clang support the use of precompiled headers when performing a Mac OS X +multi-architecture build (e.g., using option `-DCMAKE_OSX_ARCHITECTURES=i386;x86_64`). + +[1260]:http://www.cmake.org/Bug/view.php?id=1260 +[gmixer]:http://www.gmixer.com/archives/46 +[gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html +[clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders +[msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx +[msvc_pch_create]:http://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx +[msvc_pch_use]:http://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx +[EoUB]:http://leewinder.co.uk/blog/?p=394 +[pch]:http://en.wikipedia.org/wiki/Precompiled_header +[scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit +[pfh]:http://en.wikipedia.org/wiki/Prefix_header diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ab7b90 --- /dev/null +++ b/README.md @@ -0,0 +1,116 @@ +cotire +====== + +Cotire (compile time reducer) is a CMake module that speeds up the build process of CMake based +build systems by fully automating techniques as [precompiled header][pch] usage and +[single compilation unit][scu] builds for C and C++. + +features +-------- + +* Non-intrusive. Requires no source code modification and only minimal changes to CMake list files. +* Automatically generates a single compilation unit (aka unity source file) for a CMake target. +* Automatically generates a [prefix header][pfh] by tracking includes used by a CMake target. +* Automatically precompiles prefix header and applies resulting precompiled header to a CMake target. +* Supports C/C++ compilers Clang, GCC and Visual Studio C++. +* Supports mixed language CMake targets. +* Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds. +* Compatible with CMake single build type and CMake multi-configuration builds. +* Compatible with most CMake generators. +* Compatible with parallel builds (make -j, Visual Studio, Xcode). +* Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). +* Compatible with CMake's [cross-compiling][ccrc] support. +* Tested with Windows, Linux and OS X. +* MIT licensed. + +requirements +------------ + +* [CMake 2.8.5][cmk] or newer. The executable `cmake` should be on the system path. +* [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. +* [GCC][gcc] under Linux. +* [Xcode][xcdt] developer tools package under OS X. This includes [Clang][clang]. + +installation +------------ + +Copy the file `CMake/cotire.cmake` to the module directory of your CMake project. In the +top-level `CMakeList.txt` file, add the module directory to the CMake module search path: + + set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") + +usage +----- + +To use cotire in your CMake project, add the following include directive to the beginning of the +top-level `CMakeList.txt`: + + include(cotire) + +To speed the build process of a CMake library or executable target, just apply the `cotire` function +to the target: + + add_executable(MyExecutable ${MyExecutableSources}) + target_link_libraries(MyExecutable ${MyExecutableLibraries}) + cotire(MyExecutable) + +Cotire looks at the properties of the target provided by CMake (e.g., target type, source files, +compile flags, preprocessor defines, include directories, ...) and sets up custom commands that +will generate a unity source file, a prefix header and a precompiled header at build time +specially tailored to the target. + +For the generation of the prefix header, cotire will automatically choose headers used by the +target that are outside of the project directory and thus are likely to change infrequently. +The precompiled prefix header is then applied to the target to speed up the compilation process. + +As a side effect, cotire generates a new target named `MyExecutable_unity`, which lets you perform +a unity build for the original target. The unity target inherits all build settings from the +original target except for linked libraries and target dependencies. To get a workable unity +target, add another `target_link_libraries` call: + + cotire(MyExecutable) + target_link_libraries(MyExecutable_unity ${MyExecutableLibraries}) + +For Makefile based generators you can then invoke a unity build that produces the same output as +the original target, but does so much faster by entering: + + $ make MyExecutable_unity + +See the advanced usage section of the cotire manual for information on how to configure the cotire +process (e.g., how to apply cotire to a certain build configuration only). + +speedup +------- + +Depending on factors like hardware, compiler, the number of files in the target and the complexity +of the C/C++ code, the build process of targets that use a cotire generated precompiled header +will be sped up from 10 to 40 percent. Using precompiled headers however is not without +[issues][PCHH] and may not work for some programs. + +A unity build may be up to 90 percent faster than the one file at a time build of the original +target. Single compilation unit builds however are very unlikely to work without source code +modifications, because they [break][EoUB] the use of some C and C++ language features. + +Generally, modern C++ code which makes heavy use of header-only libraries will profit the most from +cotiring. + +limitations +----------- + +* CMake configure time will increase for cotired targets. +* The size of the CMake build folder will increase, because precompiled headers are large binaries. +* It is not possible to share precompiled headers generated by cotire between CMake targets. + +[ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling +[cgwn]:http://www.cygwin.com/ +[clang]:http://clang.llvm.org/ +[cmk]:http://www.cmake.org/cmake/resources/software.html +[gcc]:http://gcc.gnu.org/ +[mingw]:http://www.mingw.org/ +[pch]:http://en.wikipedia.org/wiki/Precompiled_header +[pfh]:http://en.wikipedia.org/wiki/Prefix_header +[scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit +[vslstd]:http://msdn.microsoft.com/vstudio/ +[xcdt]:http://developer.apple.com/tools/xcode/ +[PCHH]:http://gcc.gnu.org/wiki/PCHHaters +[EoUB]:http://leewinder.co.uk/blog/?p=394 diff --git a/license b/license new file mode 100644 index 0000000..6495439 --- /dev/null +++ b/license @@ -0,0 +1,22 @@ +Copyright (c) 2012 Sascha Kratky + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ce6c105 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,28 @@ +# cotire example project + +add_executable(example main.cpp example.cpp log.cpp log.h example.h) + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall") +endif() + +cotire(example) + +# cotire sets the following properties +get_target_property(_unitySource example COTIRE_CXX_UNITY_SOURCE) +get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) +get_target_property(_precompiledHeader example COTIRE_CXX_PRECOMPILED_HEADER) +get_target_property(_unityTargetName example COTIRE_UNITY_TARGET_NAME) + +if (_unitySource) + message(STATUS "example unity source: ${_unitySource}") +endif() +if (_prefixHeader) + message(STATUS "example prefix header: ${_prefixHeader}") +endif() +if (_precompiledHeader) + message(STATUS "example precompiled header: ${_precompiledHeader}") +endif() +if (TARGET ${_unityTargetName}) + message(STATUS "example unity target: ${_unityTargetName}") +endif() diff --git a/src/example.cpp b/src/example.cpp new file mode 100644 index 0000000..a857315 --- /dev/null +++ b/src/example.cpp @@ -0,0 +1,24 @@ +// cotire example project + +#include "example.h" + +#ifndef NDEBUG +#include +#include +#endif + +namespace example { + +std::string get_message() { + char msg_chrs[] = { 'C', 'o', 't', 'i', 'r', 'e', 'd', '!' }; +#ifdef NDEBUG + return std::string(&msg_chrs[0], &msg_chrs[sizeof(msg_chrs)]); +#else + std::string msg; + msg.reserve(sizeof(msg_chrs)); + std::copy(msg_chrs, msg_chrs + sizeof(msg_chrs), std::back_inserter(msg)); + return msg; +#endif +} + +} diff --git a/src/example.h b/src/example.h new file mode 100644 index 0000000..0fe3e23 --- /dev/null +++ b/src/example.h @@ -0,0 +1,10 @@ +// cotire example project + +#include + +namespace example { + +std::string get_message(); + +} + diff --git a/src/log.cpp b/src/log.cpp new file mode 100644 index 0000000..714714f --- /dev/null +++ b/src/log.cpp @@ -0,0 +1,17 @@ +// cotire example project + +#include "log.h" + +#include + +namespace log { + +void error(const std::string& msg) { + std::cerr << msg << std::endl; +} + +void info(const std::string& msg) { + std::cout << msg << std::endl; +} + +} diff --git a/src/log.h b/src/log.h new file mode 100644 index 0000000..37919b4 --- /dev/null +++ b/src/log.h @@ -0,0 +1,10 @@ +// cotire example project + +#include + +namespace log { + +void error(const std::string& msg); +void info(const std::string& msg); + +} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..1376d19 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,12 @@ +// cotire example project main + +#include + +#include "example.h" +#include "log.h" + +int main(int argc, char** argv) +{ + std::string msg = example::get_message(); + log::info(msg); +} From 1470429b234e8cde0db9652aed14fee71a283353 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 12 Mar 2012 21:20:05 +0100 Subject: [PATCH 002/169] fix docu typos --- MANUAL.md | 4 ++-- README.md | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index 03a17bd..e3d4eac 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -76,7 +76,7 @@ Cotire looks at the properties of the target provided by CMake (e.g., target typ compile flags, preprocessor defines, include directories, ...) and modifies the target's build process in the following way: -1. cotire adds a custom build rule to produce a unity source file from target's sources. +1. cotire adds a custom build rule to produce a unity source file from the target's sources. 2. cotire adds a custom build rule to produce a prefix header file by tracking the header files included by the target's sources. 3. cotire adds a custom build rule to produce a precompiled header from the prefix header. @@ -260,7 +260,7 @@ If a unity build target should not be added by cotire, the target property set_target_properties(example PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) cotire(example) -Both properties default to TRUE. If both are set to FALSE, cotire will only set up custom build +Both properties default to `TRUE`. If both are set to `FALSE`, cotire will only set up custom build rules for the generation of the unity source and the prefix header. The properties `COTIRE_ENABLE_PRECOMPILED_HEADER` and `COTIRE_ADD_UNITY_BUILD` can also be set on diff --git a/README.md b/README.md index 6ab7b90..5c934ca 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ top-level `CMakeList.txt`: include(cotire) -To speed the build process of a CMake library or executable target, just apply the `cotire` function -to the target: +To speed the build process of a CMake library or executable target, just apply the `cotire` +function to the target: add_executable(MyExecutable ${MyExecutableSources}) target_link_libraries(MyExecutable ${MyExecutableLibraries}) @@ -76,8 +76,8 @@ the original target, but does so much faster by entering: $ make MyExecutable_unity -See the advanced usage section of the cotire manual for information on how to configure the cotire -process (e.g., how to apply cotire to a certain build configuration only). +See the advanced usage section of the [cotire manual](MANUAL.md) for information on how to +configure the cotire process (e.g., how to apply cotire to a certain build configuration only). speedup ------- From 86b33734cdffd970137552546e75f00912892c77 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 12 Mar 2012 21:22:16 +0100 Subject: [PATCH 003/169] fix relative link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c934ca..775aecd 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ the original target, but does so much faster by entering: $ make MyExecutable_unity -See the advanced usage section of the [cotire manual](MANUAL.md) for information on how to +See the advanced usage section of the [cotire manual](cotire/MANUAL.md) for information on how to configure the cotire process (e.g., how to apply cotire to a certain build configuration only). speedup From d3d4c4423a7762d1b0ab1f1f4e183f38b21e2143 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 13 Mar 2012 17:28:28 +0100 Subject: [PATCH 004/169] fix manual link --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 775aecd..cb1fcc6 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ the original target, but does so much faster by entering: $ make MyExecutable_unity -See the advanced usage section of the [cotire manual](cotire/MANUAL.md) for information on how to +See the advanced usage section of the [cotire manual][manual] for information on how to configure the cotire process (e.g., how to apply cotire to a certain build configuration only). speedup @@ -106,6 +106,7 @@ limitations [clang]:http://clang.llvm.org/ [cmk]:http://www.cmake.org/cmake/resources/software.html [gcc]:http://gcc.gnu.org/ +[manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md [mingw]:http://www.mingw.org/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [pfh]:http://en.wikipedia.org/wiki/Prefix_header From 1c88ad5148d9722e449cc76fae4a51b052d2b7ed Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 14 Mar 2012 22:28:03 +0100 Subject: [PATCH 005/169] manual fixes --- MANUAL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index e3d4eac..5af7e05 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -9,8 +9,8 @@ motivation ---------- Cotire was born out of a dissatisfaction with the existing CMake solutions for adding -[precompiled header][1260] support and [unity build][gmixer] support to CMake based build systems. -The design of cotire tries to adhere to the following principles: +[precompiled header][1260] support and [unity build][kde4macros] support to CMake based build +systems. The design of cotire tries to adhere to the following principles: #### as automatic as possible @@ -391,7 +391,7 @@ Neither GCC nor Clang support the use of precompiled headers when performing a M multi-architecture build (e.g., using option `-DCMAKE_OSX_ARCHITECTURES=i386;x86_64`). [1260]:http://www.cmake.org/Bug/view.php?id=1260 -[gmixer]:http://www.gmixer.com/archives/46 +[kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake [gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx From 13c30c2607e855bbf84796e31c5fc3dd8b6484f8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 15 Mar 2012 20:12:28 +0100 Subject: [PATCH 006/169] cotire 1.0.1 * Cotire manual corrections. * Add prefix header to the generated unity build target. --- CMake/cotire.cmake | 4 +++- HISTORY.md | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ff3beee..e1696df 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.1") include(CMakeParseArguments) @@ -1941,6 +1941,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) ${_language} "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) cotire_setup_prefix_file_inclusion( ${_language} ${_target} FALSE "${_prefixFile}" "${_pchFile}" ${_unityFiles}) + # add the prefix header to unity target sources + list (APPEND _unityTargetSources "${_prefixFile}") endif() endif() endif() diff --git a/HISTORY.md b/HISTORY.md index 52b21a8..3c1459a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.0.1 (2012-03-15) + +* Cotire manual corrections. +* Add prefix header to the generated unity build target. + ## 1.0.0 (2012-03-11) -* First release +* First release. From d0b16cdd50a28e64101a9f0913966356588be95c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Mar 2012 19:55:25 +0100 Subject: [PATCH 007/169] Fix manual mistake --- MANUAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANUAL.md b/MANUAL.md index 5af7e05..070fceb 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -347,7 +347,7 @@ clashes. As an example, if these properties are set on a source file of the example project: - set_source_files_properties (log.cpp PROPERTIES + set_source_files_properties (example.cpp PROPERTIES COTIRE_UNITY_SOURCE_PRE_UNDEFS "max;min" COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") From 75a22eb479b66a693ed68a111290f311d81d29e0 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Mar 2012 20:55:55 +0100 Subject: [PATCH 008/169] cotire 1.0.2 * Fix Xcode 4.3 compatibility. * Cotire manual corrections. --- CMake/cotire.cmake | 17 ++--------------- HISTORY.md | 5 +++++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e1696df..349b59f 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.2") include(CMakeParseArguments) @@ -2183,20 +2183,7 @@ if (CMAKE_SCRIPT_MODE_FILE) include("${COTIRE_ARGV2}") endif() - if (APPLE AND "$ENV{DEVELOPER_BIN_DIR}" MATCHES ".+") - # for Xcode, override compiler executables used - if ("$ENV{GCC_VERSION}" MATCHES "clang") - set (CMAKE_C_COMPILER_ID "Clang") - set (CMAKE_CXX_COMPILER_ID "Clang") - set (CMAKE_C_COMPILER "$ENV{DEVELOPER_BIN_DIR}/clang") - set (CMAKE_CXX_COMPILER "$ENV{DEVELOPER_BIN_DIR}/clang++") - else() - set (CMAKE_C_COMPILER_ID "GNU") - set (CMAKE_CXX_COMPILER_ID "GNU") - set (CMAKE_C_COMPILER "$ENV{DEVELOPER_BIN_DIR}/cc") - set (CMAKE_CXX_COMPILER "$ENV{DEVELOPER_BIN_DIR}/g++") - endif() - elseif (WIN32) + if (WIN32) # for MSVC, compiler IDs may not always be set correctly if (MSVC) set (CMAKE_C_COMPILER_ID "MSVC") diff --git a/HISTORY.md b/HISTORY.md index 3c1459a..541fea5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.0.2 (2012-03-16) + +* Fix Xcode 4.3 compatibility. +* Cotire manual corrections. + ## 1.0.1 (2012-03-15) * Cotire manual corrections. From 7d5e8f79a030c080a3680e2a3597c0abb452af6b Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 23 Mar 2012 19:19:27 +0100 Subject: [PATCH 009/169] cotire 1.0.3 * CMake 2.8.8 compatibility --- CMake/cotire.cmake | 25 ++++++++++++++++++------- HISTORY.md | 7 ++++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 349b59f..319e284 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.3") include(CMakeParseArguments) @@ -55,10 +55,15 @@ function (cotire_determine_compiler_version _language _versionPrefix) ${_versionPrefix}_VERSION "${_versionLine}") endif() else() - # assume GCC like command line interface - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} "-dumpversion" - OUTPUT_VARIABLE ${_versionPrefix}_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) + # use CMake's predefined compiler version variable (available since CMake 2.8.8) + if (DEFINED CMAKE_${_language}_COMPILER_VERSION) + set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") + else() + # assume GCC like command line interface + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} "-dumpversion" + OUTPUT_VARIABLE ${_versionPrefix}_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) + endif() endif() if (${_versionPrefix}_VERSION) set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" CACHE INTERNAL "${_language} compiler version") @@ -1732,6 +1737,7 @@ function (cotire_choose_target_languages _target _targetLanguagesVar) set (_allExcludedSourceFiles "") set (_allCotiredSourceFiles "") set (_targetLanguages "") + get_target_property(_targetType ${_target} TYPE) get_target_property(_targetSourceFiles ${_target} SOURCES) get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) @@ -1786,6 +1792,10 @@ function (cotire_choose_target_languages _target _targetLanguagesVar) # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target set (_disableMsg "Exclusion of source files not supported for generator Xcode.") set (_targetUsePCH FALSE) + elseif (XCODE AND "${_targetType}" STREQUAL "OBJECT_LIBRARY") + # for Xcode, we cannot apply the required PRE_BUILD action to generate the prefix header to an OBJECT_LIBRARY target + set (_disableMsg "Required PRE_BUILD action not supported for OBJECT_LIBRARY targets for generator Xcode.") + set (_targetUsePCH FALSE) endif() endif() set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) @@ -1909,10 +1919,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() set (_unityTargetSubType "") endif() - elseif (_targetType MATCHES "(STATIC|SHARED|MODULE)_LIBRARY") + elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") set (_unityTargetSubType "${CMAKE_MATCH_1}") else() - message (FATAL_ERROR "Unknown target type ${_targetType}.") + message (WARNING "Unknown target type ${_targetType}.") + return() endif() # determine unity target sources get_target_property(_targetSourceFiles ${_target} SOURCES) diff --git a/HISTORY.md b/HISTORY.md index 541fea5..095e59e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,11 @@ +## 1.0.3 (2012-03-23) + +* handle OBJECT_LIBRARY targets introduced in CMake 2.8.8. +* use predefined compiler version variable, if available. + ## 1.0.2 (2012-03-16) -* Fix Xcode 4.3 compatibility. +* fix Xcode 4.3 compatibility. * Cotire manual corrections. ## 1.0.1 (2012-03-15) From 0aac2f96e39ca1a19aacc11cbe47dae4fad28618 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 24 Mar 2012 10:03:01 +0100 Subject: [PATCH 010/169] cotire 1.0.4 * honor target property INCLUDE_DIRECTORIES --- CMake/cotire.cmake | 13 +++++++++++-- HISTORY.md | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 319e284..ed44786 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.3") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.4") include(CMakeParseArguments) @@ -351,6 +351,13 @@ function (cotire_get_target_include_directories _config _language _directory _ta endif() # target include directories get_directory_property(_dirs DIRECTORY "${_directory}" INCLUDE_DIRECTORIES) + if (_target) + get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + list (REMOVE_DUPLICATES _dirs) + endif() + endif() list (LENGTH _includeDirs _projectInsertIndex) foreach (_dir ${_dirs}) if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE) @@ -1984,6 +1991,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ COMPILE_FLAGS Fortran_FORMAT + INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_) # copy link stuff cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} @@ -2010,7 +2018,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_KEYWORD - VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER) + VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER + VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES) endif() # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) diff --git a/HISTORY.md b/HISTORY.md index 095e59e..717f12a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.0.4 (2012-03-24) + +* honor target property INCLUDE_DIRECTORIES introduced in CMake 2.8.8. + ## 1.0.3 (2012-03-23) * handle OBJECT_LIBRARY targets introduced in CMake 2.8.8. From 9a7e7518ca1e43be075d5559716c28f00c0b5ee2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 25 Mar 2012 11:44:34 +0200 Subject: [PATCH 011/169] Add patch files for open source packages --- Patches/README.md | 24 ++ Patches/bullet-2.80-rev2531.patch | 389 ++++++++++++++++++++++++++++++ Patches/clang-3.0.src.patch | 35 +++ Patches/clapack-3.2.1-CMAKE.patch | 93 +++++++ Patches/cmake-2.8.7.patch | 218 +++++++++++++++++ Patches/cminpack-1.1.4.patch | 18 ++ Patches/hdf5-1.8.8.patch | 118 +++++++++ Patches/libpng-1.5.9.patch | 38 +++ Patches/llvm-3.0.src.patch | 58 +++++ Patches/yaml-cpp.patch | 37 +++ Patches/zlib-1.2.6.patch | 23 ++ README.md | 3 + 12 files changed, 1054 insertions(+) create mode 100644 Patches/README.md create mode 100644 Patches/bullet-2.80-rev2531.patch create mode 100644 Patches/clang-3.0.src.patch create mode 100644 Patches/clapack-3.2.1-CMAKE.patch create mode 100644 Patches/cmake-2.8.7.patch create mode 100644 Patches/cminpack-1.1.4.patch create mode 100644 Patches/hdf5-1.8.8.patch create mode 100644 Patches/libpng-1.5.9.patch create mode 100644 Patches/llvm-3.0.src.patch create mode 100644 Patches/yaml-cpp.patch create mode 100644 Patches/zlib-1.2.6.patch diff --git a/Patches/README.md b/Patches/README.md new file mode 100644 index 0000000..fb54cfe --- /dev/null +++ b/Patches/README.md @@ -0,0 +1,24 @@ +This directory contains patch files to enable cotire for some popular open sources packages that +use CMake as a build system. + +For example, to apply Cotire to LLVM 3.0, first copy `cotire.cmake` to a directory on the CMake +module search path (e.g., `llvm-3.0.src/cmake/modules`). + +Then apply the corresponding patch: + + $ cd /path/to/llvm-3.0.src + $ patch -p1 < /path/to/llvm-3.0.src.patch + +Then proceed with an out-of-source Cmake build: + + $ mkdir build; cd build + $ cmake .. + -- The C compiler identification is GNU 4.2.1 + -- The CXX compiler identification is Clang 3.1.0 + ... + $ make + [ 0%] Generating C unity source lib/Support/cotire/LLVMSupport_C_unity.c + [ 0%] Generating CXX unity source lib/Support/cotire/LLVMSupport_CXX_unity.cxx + [ 0%] Generating CXX prefix header lib/Support/cotire/LLVMSupport_CXX_prefix.hxx + [ 0%] Building CXX precompiled header lib/Support/cotire/LLVMSupport_CXX_prefix.hxx.gch + ... diff --git a/Patches/bullet-2.80-rev2531.patch b/Patches/bullet-2.80-rev2531.patch new file mode 100644 index 0000000..ac5a217 --- /dev/null +++ b/Patches/bullet-2.80-rev2531.patch @@ -0,0 +1,389 @@ +diff -rupN bullet-2.80-rev2531/CMakeLists.txt bullet-2.80-rev2531.cotire/CMakeLists.txt +--- bullet-2.80-rev2531/CMakeLists.txt 2012-03-03 04:15:04.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/CMakeLists.txt 2012-03-24 20:40:40.000000000 +0100 +@@ -11,6 +11,7 @@ IF(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + ENDIF(COMMAND cmake_policy) + ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") + + IF (NOT CMAKE_BUILD_TYPE) + # SET(CMAKE_BUILD_TYPE "Debug") +diff -rupN bullet-2.80-rev2531/Demos/OpenGL/CMakeLists.txt bullet-2.80-rev2531.cotire/Demos/OpenGL/CMakeLists.txt +--- bullet-2.80-rev2531/Demos/OpenGL/CMakeLists.txt 2011-09-13 03:52:42.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/Demos/OpenGL/CMakeLists.txt 2012-03-24 20:35:19.000000000 +0100 +@@ -65,3 +65,7 @@ IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (INSTALL_EXTRA_LIBS) + ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) ++ ++if (COMMAND cotire) ++ cotire(OpenGLSupport) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/ConvexDecomposition/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/ConvexDecomposition/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/ConvexDecomposition/CMakeLists.txt 2010-09-18 02:24:50.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/Extras/ConvexDecomposition/CMakeLists.txt 2012-03-24 20:35:36.000000000 +0100 +@@ -62,3 +62,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_EXTRA_LIBS) ++ ++if (COMMAND cotire) ++ cotire(ConvexDecomposition) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/GIMPACTUtils/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/GIMPACTUtils/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/GIMPACTUtils/CMakeLists.txt 2010-09-18 02:24:50.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/Extras/GIMPACTUtils/CMakeLists.txt 2012-03-24 20:35:42.000000000 +0100 +@@ -35,3 +35,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_EXTRA_LIBS) ++ ++if (COMMAND cotire) ++ cotire(GIMPACTUtils) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/HACD/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/HACD/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/HACD/CMakeLists.txt 2011-07-07 02:28:15.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/Extras/HACD/CMakeLists.txt 2012-03-24 20:36:03.000000000 +0100 +@@ -49,3 +49,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_EXTRA_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(HACD) + ++endif() + +diff -rupN bullet-2.80-rev2531/Extras/PhysicsEffects/src/base_level/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/base_level/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/PhysicsEffects/src/base_level/CMakeLists.txt 2012-03-05 05:59:58.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/base_level/CMakeLists.txt 2012-03-24 20:36:29.000000000 +0100 +@@ -75,3 +75,7 @@ ADD_LIBRARY(PfxBaseLevel ${PfxBaseLevel_ + + + SET_TARGET_PROPERTIES(PfxBaseLevel PROPERTIES VERSION ${BULLET_VERSION}) + + SET_TARGET_PROPERTIES(PfxBaseLevel PROPERTIES SOVERSION ${BULLET_VERSION}) + ++ + ++if (COMMAND cotire) + ++ cotire(PfxBaseLevel) + ++endif() + +diff -rupN bullet-2.80-rev2531/Extras/PhysicsEffects/src/low_level/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/low_level/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/PhysicsEffects/src/low_level/CMakeLists.txt 2012-03-05 05:59:58.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/low_level/CMakeLists.txt 2012-03-24 20:36:39.000000000 +0100 +@@ -27,3 +27,7 @@ ADD_LIBRARY(PfxLowLevel ${PfxLowLevel_SR + + + SET_TARGET_PROPERTIES(PfxLowLevel PROPERTIES VERSION ${BULLET_VERSION}) + + SET_TARGET_PROPERTIES(PfxLowLevel PROPERTIES SOVERSION ${BULLET_VERSION}) + ++ + ++if (COMMAND cotire) + ++ cotire(PfxLowLevel) + ++endif() + +diff -rupN bullet-2.80-rev2531/Extras/PhysicsEffects/src/util/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/util/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/PhysicsEffects/src/util/CMakeLists.txt 2012-03-05 05:59:58.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/PhysicsEffects/src/util/CMakeLists.txt 2012-03-24 20:36:47.000000000 +0100 +@@ -18,3 +18,7 @@ ADD_LIBRARY(PfxUtil ${PfxUtil_SRCS} ${Pf + + + SET_TARGET_PROPERTIES(PfxUtil PROPERTIES VERSION ${BULLET_VERSION}) + + SET_TARGET_PROPERTIES(PfxUtil PROPERTIES SOVERSION ${BULLET_VERSION}) + ++ + ++if (COMMAND cotire) + ++ cotire(PfxUtil) + ++endif() + +diff -rupN bullet-2.80-rev2531/Extras/Serialize/BlenderSerialize/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/Serialize/BlenderSerialize/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/Serialize/BlenderSerialize/CMakeLists.txt 2010-03-06 16:23:36.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/Serialize/BlenderSerialize/CMakeLists.txt 2012-03-24 20:36:55.000000000 +0100 +@@ -5,3 +5,7 @@ ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Seri + ) + + ADD_LIBRARY(BlenderSerialize dna249.cpp dna249-64bit.cpp bBlenderFile.cpp bBlenderFile.h bMain.cpp bMain.h ) ++ ++if (COMMAND cotire) ++ cotire(BlenderSerialize) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/Serialize/BulletFileLoader/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/Serialize/BulletFileLoader/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/Serialize/BulletFileLoader/CMakeLists.txt 2012-02-29 05:43:51.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/Serialize/BulletFileLoader/CMakeLists.txt 2012-03-24 20:37:05.000000000 +0100 +@@ -47,3 +47,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_EXTRA_LIBS) ++ ++if (COMMAND cotire) ++ cotire(BulletFileLoader) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/Serialize/BulletWorldImporter/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/Serialize/BulletWorldImporter/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/Serialize/BulletWorldImporter/CMakeLists.txt 2012-02-29 05:43:51.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/Serialize/BulletWorldImporter/CMakeLists.txt 2012-03-24 20:37:15.000000000 +0100 +@@ -36,3 +36,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_EXTRA_LIBS) ++ ++if (COMMAND cotire) ++ cotire(BulletWorldImporter) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/Serialize/makesdna/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/Serialize/makesdna/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/Serialize/makesdna/CMakeLists.txt 2010-03-06 16:23:36.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/Serialize/makesdna/CMakeLists.txt 2012-03-24 20:37:26.000000000 +0100 +@@ -35,3 +35,7 @@ SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/sr + ADD_LIBRARY(BulletDNA ${SRC} ${INC_FILES}) + + MESSAGE(STATUS "Configuring makesdna") ++ ++if (COMMAND cotire) ++ cotire(BulletDNA) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/glui/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/glui/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/glui/CMakeLists.txt 2010-03-06 16:23:36.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/glui/CMakeLists.txt 2012-03-24 20:35:51.000000000 +0100 +@@ -64,3 +64,7 @@ arcball.cpp glui_button.cpp glui_fil + IF (BUILD_SHARED_LIBS) + TARGET_LINK_LIBRARIES(GLUI ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) + ENDIF (BUILD_SHARED_LIBS) ++ ++if (COMMAND cotire) ++ cotire(GLUI) ++endif() +diff -rupN bullet-2.80-rev2531/Extras/iff/CMakeLists.txt bullet-2.80-rev2531.cotire/Extras/iff/CMakeLists.txt +--- bullet-2.80-rev2531/Extras/iff/CMakeLists.txt 2010-03-06 16:23:36.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/Extras/iff/CMakeLists.txt 2012-03-24 20:36:12.000000000 +0100 +@@ -9,3 +9,7 @@ iffw.cpp + ) + + #SUBDIRS( BulletIffConverter ) ++ ++if (COMMAND cotire) ++ cotire(Iff) ++endif() +diff -rupN bullet-2.80-rev2531/UnitTests/cppunit/CMakeLists.txt bullet-2.80-rev2531.cotire/UnitTests/cppunit/CMakeLists.txt +--- bullet-2.80-rev2531/UnitTests/cppunit/CMakeLists.txt 2010-07-24 00:09:57.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/UnitTests/cppunit/CMakeLists.txt 2012-03-24 20:39:51.000000000 +0100 +@@ -71,4 +71,8 @@ ADD_LIBRARY(cppunit + + src/cppunit/XmlDocument.cpp + + src/cppunit/XmlElement.cpp + + + +-) +\ No newline at end of file ++) + ++ + ++if (COMMAND cotire) + ++ cotire(cppunit) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletCollision/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletCollision/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletCollision/CMakeLists.txt 2012-02-29 06:19:22.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletCollision/CMakeLists.txt 2012-03-24 20:37:38.000000000 +0100 +@@ -277,3 +277,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/Bulle + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) ++ ++if (COMMAND cotire) ++ cotire(BulletCollision) ++endif() +diff -rupN bullet-2.80-rev2531/src/BulletDynamics/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletDynamics/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletDynamics/CMakeLists.txt 2011-09-15 20:47:13.000000000 +0200 ++++ bullet-2.80-rev2531.cotire/src/BulletDynamics/CMakeLists.txt 2012-03-24 20:43:34.000000000 +0100 +@@ -110,3 +110,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/Bulle + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) ++ ++if (COMMAND cotire) ++ cotire(BulletDynamics) ++endif() +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/CMakeLists.txt 2012-02-29 06:19:22.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/CMakeLists.txt 2012-03-24 20:37:58.000000000 +0100 +@@ -121,3 +121,6 @@ PATTERN "*.h" PATTERN ".svn" EXCLUDE PA + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) + ++if (COMMAND cotire) ++ cotire(BulletMultiThreaded) ++endif() +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/CMakeLists.txt 2011-11-11 20:00:26.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/CMakeLists.txt 2012-03-24 20:38:09.000000000 +0100 +@@ -81,3 +81,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_DX11) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD/CMakeLists.txt 2011-12-20 19:03:24.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD/CMakeLists.txt 2012-03-24 20:38:22.000000000 +0100 +@@ -60,3 +60,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_OpenCL_AMD) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple/CMakeLists.txt 2011-11-11 20:00:26.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple/CMakeLists.txt 2012-03-24 20:38:38.000000000 +0100 +@@ -75,3 +75,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_OpenCL_Apple) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel/CMakeLists.txt 2011-12-20 19:03:24.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel/CMakeLists.txt 2012-03-24 20:38:51.000000000 +0100 +@@ -80,3 +80,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_OpenCL_Intel) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/CMakeLists.txt 2011-11-11 20:00:26.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/CMakeLists.txt 2012-03-24 20:39:00.000000000 +0100 +@@ -73,3 +73,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_OpenCL_Mini) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia/CMakeLists.txt 2011-12-20 19:03:24.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia/CMakeLists.txt 2012-03-24 20:39:08.000000000 +0100 +@@ -79,3 +79,7 @@ IF (INSTALL_LIBS) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + ++ + ++if (COMMAND cotire) + ++ cotire(BulletSoftBodySolvers_OpenCL_NVidia) + ++endif() + +diff -rupN bullet-2.80-rev2531/src/BulletSoftBody/CMakeLists.txt bullet-2.80-rev2531.cotire/src/BulletSoftBody/CMakeLists.txt +--- bullet-2.80-rev2531/src/BulletSoftBody/CMakeLists.txt 2010-12-01 06:55:08.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/BulletSoftBody/CMakeLists.txt 2012-03-24 20:39:20.000000000 +0100 +@@ -63,3 +63,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) ++ ++if (COMMAND cotire) ++ cotire(BulletSoftBody) ++endif() +diff -rupN bullet-2.80-rev2531/src/LinearMath/CMakeLists.txt bullet-2.80-rev2531.cotire/src/LinearMath/CMakeLists.txt +--- bullet-2.80-rev2531/src/LinearMath/CMakeLists.txt 2011-11-11 21:11:03.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/LinearMath/CMakeLists.txt 2012-03-24 20:39:28.000000000 +0100 +@@ -64,3 +64,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) ++ ++if (COMMAND cotire) ++ cotire(LinearMath) ++endif() +diff -rupN bullet-2.80-rev2531/src/MiniCL/CMakeLists.txt bullet-2.80-rev2531.cotire/src/MiniCL/CMakeLists.txt +--- bullet-2.80-rev2531/src/MiniCL/CMakeLists.txt 2012-02-29 06:19:22.000000000 +0100 ++++ bullet-2.80-rev2531.cotire/src/MiniCL/CMakeLists.txt 2012-03-24 20:39:38.000000000 +0100 +@@ -64,3 +64,6 @@ PATTERN "*.h" PATTERN ".svn" EXCLUDE PA + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + + ENDIF (INSTALL_LIBS) + + + ++if (COMMAND cotire) + ++ cotire(MiniCL) + ++endif() + diff --git a/Patches/clang-3.0.src.patch b/Patches/clang-3.0.src.patch new file mode 100644 index 0000000..9a4d5be --- /dev/null +++ b/Patches/clang-3.0.src.patch @@ -0,0 +1,35 @@ +diff -rupN clang-3.0.src/CMakeLists.txt clang-3.0.src.cotire/CMakeLists.txt +--- clang-3.0.src/CMakeLists.txt 2011-10-06 15:03:08.000000000 +0200 ++++ clang-3.0.src.cotire/CMakeLists.txt 2012-03-24 14:04:10.000000000 +0100 +@@ -36,6 +36,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + include(TableGen) + include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") + include(HandleLLVMOptions) ++ include(cotire) + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + +@@ -206,6 +207,11 @@ macro(add_clang_library name) + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") ++ if (COMMAND cotire) ++ if (NOT "${name}" MATCHES "libclang") ++ cotire(${name}) ++ endif() ++ endif() + endmacro(add_clang_library) + + macro(add_clang_executable name) +diff -rupN clang-3.0.src/tools/libclang/CMakeLists.txt clang-3.0.src.cotire/tools/libclang/CMakeLists.txt +--- clang-3.0.src/tools/libclang/CMakeLists.txt 2011-10-06 09:00:54.000000000 +0200 ++++ clang-3.0.src.cotire/tools/libclang/CMakeLists.txt 2012-03-24 14:05:02.000000000 +0100 +@@ -70,3 +70,8 @@ if( NOT BUILD_SHARED_LIBS AND NOT WIN32 + PROPERTIES + OUTPUT_NAME "libclang") + endif() ++ ++if (COMMAND cotire) ++ cotire(libclang) ++ cotire(${LIBCLANG_STATIC_TARGET_NAME}) ++endif() diff --git a/Patches/clapack-3.2.1-CMAKE.patch b/Patches/clapack-3.2.1-CMAKE.patch new file mode 100644 index 0000000..61dfafe --- /dev/null +++ b/Patches/clapack-3.2.1-CMAKE.patch @@ -0,0 +1,93 @@ +diff -rupN clapack-3.2.1-CMAKE/BLAS/SRC/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/BLAS/SRC/CMakeLists.txt +--- clapack-3.2.1-CMAKE/BLAS/SRC/CMakeLists.txt 2009-08-14 22:16:25.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/BLAS/SRC/CMakeLists.txt 2012-03-24 19:59:26.000000000 +0100 +@@ -141,3 +141,13 @@ if(UNIX) + target_link_libraries(blas m) + endif() + target_link_libraries(blas f2c) ++ ++if (COMMAND cotire) ++ cotire(blas) ++ if (TARGET blas_unity) ++ if(UNIX) ++ target_link_libraries(blas_unity m) ++ endif() ++ target_link_libraries(blas_unity f2c_unity) ++ endif() ++endif() +diff -rupN clapack-3.2.1-CMAKE/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/CMakeLists.txt +--- clapack-3.2.1-CMAKE/CMakeLists.txt 2009-08-10 20:46:33.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/CMakeLists.txt 2012-03-24 19:56:58.000000000 +0100 +@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6) + project(CLAPACK C) + enable_testing() + include(CTest) ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") + + if(WIN32 AND NOT CYGWIN) + set(SECOND_SRC ${CLAPACK_SOURCE_DIR}/INSTALL/winsecond.c) +diff -rupN clapack-3.2.1-CMAKE/F2CLIBS/libf2c/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/F2CLIBS/libf2c/CMakeLists.txt +--- clapack-3.2.1-CMAKE/F2CLIBS/libf2c/CMakeLists.txt 2009-08-10 20:06:06.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/F2CLIBS/libf2c/CMakeLists.txt 2012-03-24 19:58:41.000000000 +0100 +@@ -60,3 +60,6 @@ include_directories(${CLAPACK_SOURCE_DIR + include_directories(${CLAPACK_BINARY_DIR}/F2CLIBS/libf2c) + add_library(f2c ${OFILES} ${CMAKE_CURRENT_BINARY_DIR}/arith.h) + set_property(TARGET f2c PROPERTY PREFIX lib) ++if (COMMAND cotire) ++ cotire(f2c) ++endif() +diff -rupN clapack-3.2.1-CMAKE/SRC/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/SRC/CMakeLists.txt +--- clapack-3.2.1-CMAKE/SRC/CMakeLists.txt 2009-08-10 19:47:54.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/SRC/CMakeLists.txt 2012-03-24 19:59:20.000000000 +0100 +@@ -378,3 +378,9 @@ endif() + add_library(lapack ${ALLOBJ} ${ALLXOBJ}) + target_link_libraries(lapack blas) + ++if (COMMAND cotire) ++ cotire(lapack) ++ if (TARGET lapack_unity) ++ target_link_libraries(lapack_unity blas_unity) ++ endif() ++endif() +diff -rupN clapack-3.2.1-CMAKE/TESTING/EIG/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/TESTING/EIG/CMakeLists.txt +--- clapack-3.2.1-CMAKE/TESTING/EIG/CMakeLists.txt 2009-08-10 19:47:54.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/TESTING/EIG/CMakeLists.txt 2012-03-24 20:07:55.000000000 +0100 +@@ -120,6 +120,12 @@ set(ZEIGTST zchkee.c + macro(add_eig_executable name ) + add_executable(${name} ${ARGN}) + target_link_libraries(${name} tmglib lapack ) ++ if (COMMAND cotire) ++ cotire(${name}) ++ if (TARGET ${name}_unity) ++ target_link_libraries(${name}_unity tmglib lapack ) ++ endif() ++ endif() + endmacro(add_eig_executable) + + add_eig_executable(xeigtsts ${SEIGTST} ${SCIGTST} ${AEIGTST} +diff -rupN clapack-3.2.1-CMAKE/TESTING/LIN/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/TESTING/LIN/CMakeLists.txt +--- clapack-3.2.1-CMAKE/TESTING/LIN/CMakeLists.txt 2009-08-10 20:06:06.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/TESTING/LIN/CMakeLists.txt 2012-03-24 20:08:13.000000000 +0100 +@@ -190,6 +190,12 @@ set(ZLINTSTRFP zchkrfp.c zdrvrfp.c zdrv + macro(add_lin_executable name ) + add_executable(${name} ${ARGN}) + target_link_libraries(${name} tmglib lapack) ++ if (COMMAND cotire) ++ cotire(${name}) ++ if (TARGET ${name}_unity) ++ target_link_libraries(${name}_unity tmglib lapack ) ++ endif() ++ endif() + endmacro(add_lin_executable) + + add_lin_executable(xlintsts ${ALINTST} ${SCLNTST} ${SLINTST} +diff -rupN clapack-3.2.1-CMAKE/TESTING/MATGEN/CMakeLists.txt clapack-3.2.1-CMAKE.cotire/TESTING/MATGEN/CMakeLists.txt +--- clapack-3.2.1-CMAKE/TESTING/MATGEN/CMakeLists.txt 2009-08-10 19:47:54.000000000 +0200 ++++ clapack-3.2.1-CMAKE.cotire/TESTING/MATGEN/CMakeLists.txt 2012-03-24 20:05:19.000000000 +0100 +@@ -67,3 +67,6 @@ if(BUILD_COMPLEX16) + endif() + add_library(tmglib ${ALLOBJ} ) + ++if (COMMAND cotire) ++ cotire(tmglib) ++endif() diff --git a/Patches/cmake-2.8.7.patch b/Patches/cmake-2.8.7.patch new file mode 100644 index 0000000..d80a223 --- /dev/null +++ b/Patches/cmake-2.8.7.patch @@ -0,0 +1,218 @@ +diff -rupN cmake-2.8.7/CMakeLists.txt cmake-2.8.7.cotire/CMakeLists.txt +--- cmake-2.8.7/CMakeLists.txt 2011-12-30 17:49:56.000000000 +0100 ++++ cmake-2.8.7.cotire/CMakeLists.txt 2012-03-24 14:41:40.000000000 +0100 +@@ -13,6 +13,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FAT + SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required + PROJECT(CMake) + ++include(Modules/cotire.cmake) ++ + IF(CMAKE_BOOTSTRAP) + # Running from bootstrap script. Set local variable and remove from cache. + SET(CMAKE_BOOTSTRAP 1) +diff -rupN cmake-2.8.7/Source/CMakeLists.txt cmake-2.8.7.cotire/Source/CMakeLists.txt +--- cmake-2.8.7/Source/CMakeLists.txt 2011-12-30 17:49:56.000000000 +0100 ++++ cmake-2.8.7.cotire/Source/CMakeLists.txt 2012-02-24 22:35:58.000000000 +0100 +@@ -364,6 +364,9 @@ TARGET_LINK_LIBRARIES(CMakeLib cmsys + IF(APPLE) + TARGET_LINK_LIBRARIES(CMakeLib "-framework CoreFoundation") + ENDIF(APPLE) ++if (COMMAND cotire) ++cotire(CMakeLib) ++endif() + + # On some platforms we need the rpcrt4 library for the VS 7 generators. + IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) +@@ -433,6 +436,9 @@ SET(CTEST_SRCS cmCTest.cxx + # Build CTestLib + ADD_LIBRARY(CTestLib ${CTEST_SRCS}) + TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES}) ++if (COMMAND cotire) ++cotire(CTestLib) ++endif() + + # + # Sources for CPack +@@ -477,6 +483,9 @@ ENDIF(APPLE) + # Build CPackLib + ADD_LIBRARY(CPackLib ${CPACK_SRCS}) + TARGET_LINK_LIBRARIES(CPackLib CMakeLib) ++if (COMMAND cotire) ++cotire(CPackLib) ++endif() + + IF(APPLE) + ADD_EXECUTABLE(cmakexbuild cmakexbuild.cxx) +@@ -485,11 +494,17 @@ IF(APPLE) + CPack/OSXScriptLauncher.cxx) + TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys) + TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework CoreFoundation") ++if (COMMAND cotire) ++cotire(cmakexbuild) ++endif() + ENDIF(APPLE) + + # Build CMake executable + ADD_EXECUTABLE(cmake cmakemain.cxx) + TARGET_LINK_LIBRARIES(cmake CMakeLib) ++if (COMMAND cotire) ++cotire(cmake) ++endif() + + # Build special executable for running programs on Windows 98 + IF(WIN32) +@@ -503,10 +518,16 @@ ENDIF(WIN32) + # Build CTest executable + ADD_EXECUTABLE(ctest ctest.cxx) + TARGET_LINK_LIBRARIES(ctest CTestLib) ++if (COMMAND cotire) ++cotire(ctest) ++endif() + + # Build CPack executable + ADD_EXECUTABLE(cpack CPack/cpack.cxx) + TARGET_LINK_LIBRARIES(cpack CPackLib) ++if (COMMAND cotire) ++cotire(cpack) ++endif() + + # Curses GUI + IF(BUILD_CursesDialog) +diff -rupN cmake-2.8.7/Source/CursesDialog/CMakeLists.txt cmake-2.8.7.cotire/Source/CursesDialog/CMakeLists.txt +--- cmake-2.8.7/Source/CursesDialog/CMakeLists.txt 2011-12-30 17:49:57.000000000 +0100 ++++ cmake-2.8.7.cotire/Source/CursesDialog/CMakeLists.txt 2012-02-22 20:41:03.000000000 +0100 +@@ -33,5 +33,7 @@ INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PAT + ADD_EXECUTABLE(ccmake ${CURSES_SRCS} ) + TARGET_LINK_LIBRARIES(ccmake CMakeLib) + TARGET_LINK_LIBRARIES(ccmake cmForm) +- ++if (COMMAND cotire) ++cotire(ccmake) ++endif() + INSTALL_TARGETS(/bin ccmake) +diff -rupN cmake-2.8.7/Source/CursesDialog/form/CMakeLists.txt cmake-2.8.7.cotire/Source/CursesDialog/form/CMakeLists.txt +--- cmake-2.8.7/Source/CursesDialog/form/CMakeLists.txt 2011-12-30 17:49:57.000000000 +0100 ++++ cmake-2.8.7.cotire/Source/CursesDialog/form/CMakeLists.txt 2012-02-24 21:30:47.000000000 +0100 +@@ -64,3 +64,6 @@ TARGET_LINK_LIBRARIES(cmForm ${CURSES_LI + IF(CURSES_EXTRA_LIBRARY) + TARGET_LINK_LIBRARIES(cmForm ${CURSES_EXTRA_LIBRARY}) + ENDIF(CURSES_EXTRA_LIBRARY) ++if (COMMAND cotire) ++cotire(cmForm) ++endif() +diff -rupN cmake-2.8.7/Source/kwsys/CMakeLists.txt cmake-2.8.7.cotire/Source/kwsys/CMakeLists.txt +--- cmake-2.8.7/Source/kwsys/CMakeLists.txt 2011-12-30 17:49:57.000000000 +0100 ++++ cmake-2.8.7.cotire/Source/kwsys/CMakeLists.txt 2012-03-24 15:03:17.000000000 +0100 +@@ -926,6 +926,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) + ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) ++if (COMMAND cotire) ++cotire(${KWSYS_NAMESPACE}TestDynload) ++endif() + ENDIF(KWSYS_USE_DynamicLoader) + CREATE_TEST_SOURCELIST( + KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx +@@ -934,6 +937,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) + ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE}) ++if (COMMAND cotire) ++cotire(${KWSYS_NAMESPACE}TestsCxx) ++endif() + SET(TEST_SYSTEMTOOLS_BIN_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin") + SET(TEST_SYSTEMTOOLS_SRC_FILE +diff -rupN cmake-2.8.7/Utilities/cmbzip2/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmbzip2/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmbzip2/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmbzip2/CMakeLists.txt 2012-02-22 20:45:26.000000000 +0100 +@@ -2,3 +2,6 @@ project(bzip2) + add_definitions(-D_FILE_OFFSET_BITS=64) + add_library(cmbzip2 + blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c) ++if (COMMAND cotire) ++cotire(cmbzip2) ++endif() +\ No newline at end of file +diff -rupN cmake-2.8.7/Utilities/cmcompress/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmcompress/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmcompress/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmcompress/CMakeLists.txt 2012-02-22 20:45:29.000000000 +0100 +@@ -3,3 +3,6 @@ PROJECT(CMCompress) + ADD_LIBRARY(cmcompress cmcompress.c) + + INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmcompress) ++if (COMMAND cotire) ++cotire(cmcompress) ++endif() +\ No newline at end of file +diff -rupN cmake-2.8.7/Utilities/cmcurl/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmcurl/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmcurl/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmcurl/CMakeLists.txt 2012-02-22 20:43:57.000000000 +0100 +@@ -706,6 +706,9 @@ IF(CMAKE_BUILD_CURL_SHARED) + RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR}) + INSTALL_TARGETS(/bin cmcurl) + ENDIF(CMAKE_BUILD_CURL_SHARED) ++if (COMMAND cotire) ++cotire(cmcurl) ++endif() + + OPTION(CURL_TESTING "Do libCurl testing" OFF) + IF(CURL_TESTING) +diff -rupN cmake-2.8.7/Utilities/cmexpat/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmexpat/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmexpat/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmexpat/CMakeLists.txt 2012-02-22 20:45:40.000000000 +0100 +@@ -32,3 +32,6 @@ CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/exp + + ADD_LIBRARY(cmexpat ${expat_SRCS}) + INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmexpat) ++if (COMMAND cotire) ++cotire(cmexpat) ++endif() +\ No newline at end of file +diff -rupN cmake-2.8.7/Utilities/cmlibarchive/libarchive/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmlibarchive/libarchive/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmlibarchive/libarchive/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmlibarchive/libarchive/CMakeLists.txt 2012-02-22 20:45:55.000000000 +0100 +@@ -116,6 +116,9 @@ IF(BUILD_ARCHIVE_WITHIN_CMAKE) + # and call the library cmlibarchive + ADD_LIBRARY(cmlibarchive STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(cmlibarchive ${ADDITIONAL_LIBS}) ++if (COMMAND cotire) ++cotire(cmlibarchive) ++endif() + ELSE() + # Libarchive is a shared library + ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) +@@ -123,7 +126,10 @@ ELSE() + SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) + SET_TARGET_PROPERTIES(archive PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +- ++if (COMMAND cotire) ++cotire(archive) ++endif() ++ + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS +@@ -134,6 +140,9 @@ ELSE() + IF(NOT WIN32 OR CYGWIN) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN) ++if (COMMAND cotire) ++cotire(archive_static) ++endif() + + # How to install the libraries + INSTALL(TARGETS archive archive_static +diff -rupN cmake-2.8.7/Utilities/cmzlib/CMakeLists.txt cmake-2.8.7.cotire/Utilities/cmzlib/CMakeLists.txt +--- cmake-2.8.7/Utilities/cmzlib/CMakeLists.txt 2011-12-30 17:49:58.000000000 +0100 ++++ cmake-2.8.7.cotire/Utilities/cmzlib/CMakeLists.txt 2012-02-22 20:42:30.000000000 +0100 +@@ -39,5 +39,7 @@ ENDFOREACH(name) + + + ADD_LIBRARY(cmzlib ${ZLIB_SRCS}) +- ++if (COMMAND cmzlib) ++cotire(cmzlib) ++endif() + INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmzlib) diff --git a/Patches/cminpack-1.1.4.patch b/Patches/cminpack-1.1.4.patch new file mode 100644 index 0000000..23fdee5 --- /dev/null +++ b/Patches/cminpack-1.1.4.patch @@ -0,0 +1,18 @@ +diff -rupN cminpack-1.1.4/CMakeLists.txt cminpack-1.1.4.cotire/CMakeLists.txt +--- cminpack-1.1.4/CMakeLists.txt 2011-04-15 08:51:13.000000000 +0200 ++++ cminpack-1.1.4.cotire/CMakeLists.txt 2012-03-24 20:21:19.000000000 +0100 +@@ -6,6 +6,7 @@ project (CMINPACK) + string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + + include(${PROJECT_SOURCE_DIR}/cmake/cminpack_utils.cmake) ++include(${PROJECT_SOURCE_DIR}/cmake/cotire.cmake) + # Set version and OS-specific settings + set(CMINPACK_VERSION 1.0.90 CACHE STRING "CMinpack version") + DISSECT_VERSION() +@@ -70,3 +71,6 @@ endif (USE_FPIC AND NOT SHARED_LIBS) + + set_target_properties(cminpack PROPERTIES VERSION ${CMINPACK_VERSION}) + ++if (COMMAND cotire) ++ cotire(cminpack) ++endif() diff --git a/Patches/hdf5-1.8.8.patch b/Patches/hdf5-1.8.8.patch new file mode 100644 index 0000000..d0ed54b --- /dev/null +++ b/Patches/hdf5-1.8.8.patch @@ -0,0 +1,118 @@ +diff -rupN hdf5-1.8.8/CMakeLists.txt hdf5-1.8.8.cotire/CMakeLists.txt +--- hdf5-1.8.8/CMakeLists.txt 2011-11-07 23:11:41.000000000 +0100 ++++ hdf5-1.8.8.cotire/CMakeLists.txt 2012-03-24 17:30:29.000000000 +0100 +@@ -200,6 +200,7 @@ SET (HDF5_PACKAGE_BUGREPORT "help@hdfgro + #----------------------------------------------------------------------------- + INCLUDE (${HDF5_RESOURCES_DIR}/HDFMacros.cmake) + INCLUDE (${HDF5_RESOURCES_DIR}/HDF5Macros.cmake) ++INCLUDE (${HDF5_RESOURCES_DIR}/cotire.cmake) + + #----------------------------------------------------------------------------- + # Setup output Directories +diff -rupN hdf5-1.8.8/c++/src/CMakeLists.txt hdf5-1.8.8.cotire/c++/src/CMakeLists.txt +--- hdf5-1.8.8/c++/src/CMakeLists.txt 2011-11-07 23:11:40.000000000 +0100 ++++ hdf5-1.8.8.cotire/c++/src/CMakeLists.txt 2012-03-24 17:29:43.000000000 +0100 +@@ -85,6 +85,9 @@ ADD_LIBRARY (${HDF5_CPP_LIB_TARGET} ${LI + TARGET_LINK_LIBRARIES (${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIB_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_CPP_LIB_TARGET} ${HDF5_CPP_LIB_NAME} ${LIB_TYPE}) ++if (COMMAND cotire) ++cotire(${HDF5_CPP_LIB_TARGET}) ++endif() + + #----------------------------------------------------------------------------- + # Add file(s) to CMake Install +diff -rupN hdf5-1.8.8/fortran/src/CMakeLists.txt hdf5-1.8.8.cotire/fortran/src/CMakeLists.txt +--- hdf5-1.8.8/fortran/src/CMakeLists.txt 2011-11-07 23:11:41.000000000 +0100 ++++ hdf5-1.8.8.cotire/fortran/src/CMakeLists.txt 2012-03-24 17:30:02.000000000 +0100 +@@ -118,6 +118,9 @@ ADD_LIBRARY (${HDF5_F90_C_LIB_TARGET} ${ + TARGET_LINK_LIBRARIES (${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_NAME} ${LIB_TYPE}) ++if (COMMAND cotire) ++cotire(${HDF5_F90_C_LIB_TARGET}) ++endif() + + #----------------------------------------------------------------------------- + # Fortran 2003 standard +@@ -221,6 +224,7 @@ SET_TARGET_PROPERTIES (${HDF5_F90_LIB_TA + TARGET_LINK_LIBRARIES (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} ${LIB_TYPE}) ++cotire(${HDF5_F90_LIB_TARGET}) + + #----------------------------------------------------------------------------- + # Add file(s) to CMake Install +diff -rupN hdf5-1.8.8/hl/c++/src/CMakeLists.txt hdf5-1.8.8.cotire/hl/c++/src/CMakeLists.txt +--- hdf5-1.8.8/hl/c++/src/CMakeLists.txt 2011-11-07 23:11:39.000000000 +0100 ++++ hdf5-1.8.8.cotire/hl/c++/src/CMakeLists.txt 2012-03-24 17:29:52.000000000 +0100 +@@ -18,6 +18,9 @@ TARGET_LINK_LIBRARIES ( + ) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIB_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_HL_CPP_LIB_NAME} ${LIB_TYPE}) ++if (COMMAND cotire) ++cotire(${HDF5_HL_CPP_LIB_TARGET}) ++endif() + + #----------------------------------------------------------------------------- + # Add file(s) to CMake Install +diff -rupN hdf5-1.8.8/hl/src/CMakeLists.txt hdf5-1.8.8.cotire/hl/src/CMakeLists.txt +--- hdf5-1.8.8/hl/src/CMakeLists.txt 2011-11-07 23:11:38.000000000 +0100 ++++ hdf5-1.8.8.cotire/hl/src/CMakeLists.txt 2012-03-24 17:30:11.000000000 +0100 +@@ -37,6 +37,9 @@ ADD_LIBRARY (${HDF5_HL_LIB_TARGET} ${LIB + TARGET_LINK_LIBRARIES (${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_LIB_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} ${LIB_TYPE}) ++if (COMMAND cotire) ++cotire(${HDF5_HL_LIB_TARGET}) ++endif() + + #----------------------------------------------------------------------------- + # Add file(s) to CMake Install +diff -rupN hdf5-1.8.8/src/CMakeLists.txt hdf5-1.8.8.cotire/src/CMakeLists.txt +--- hdf5-1.8.8/src/CMakeLists.txt 2011-11-07 23:11:30.000000000 +0100 ++++ hdf5-1.8.8.cotire/src/CMakeLists.txt 2012-03-24 17:29:26.000000000 +0100 +@@ -631,6 +631,16 @@ ADD_LIBRARY (${HDF5_LIB_TARGET} ${LIB_TY + TARGET_LINK_LIBRARIES (${HDF5_LIB_TARGET} ${LINK_LIBS}) + SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} ${LIB_TYPE}) ++#set_target_properties(${HDF5_LIB_TARGET} PROPERTIES COTIRE_IGNORED_INCLUDE_DIRECTORIES "/Developer/usr;/usr/llvm-gcc-4.2;${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}") ++ ++if (COMMAND cotire) ++SET_SOURCE_FILES_PROPERTIES ( ++"${HDF5_BINARY_DIR}/H5overflow.h" ++"${HDF5_BINARY_DIR}/H5version.h" ++"${HDF5_BINARY_DIR}/H5Edefin.h" ++PROPERTIES COTIRE_DEPENDENCY FALSE) ++cotire(${HDF5_LIB_TARGET}) ++endif() + + #----------------------------------------------------------------------------- + # Add file(s) to CMake Install +Binary files hdf5-1.8.8/src/H5public.h.gch and hdf5-1.8.8.cotire/src/H5public.h.gch differ +diff -rupN hdf5-1.8.8/test/CMakeLists.txt hdf5-1.8.8.cotire/test/CMakeLists.txt +--- hdf5-1.8.8/test/CMakeLists.txt 2011-11-07 23:11:23.000000000 +0100 ++++ hdf5-1.8.8.cotire/test/CMakeLists.txt 2012-03-24 17:30:22.000000000 +0100 +@@ -30,6 +30,9 @@ IF (MINGW) + ENDIF (MINGW) + TARGET_LINK_LIBRARIES (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} ${LIB_TYPE}) ++if (COMMAND cotire) ++cotire(${HDF5_TEST_LIB_TARGET}) ++endif() + + # -------------------------------------------------------------------- + # Copy all the HDF5 files from the test directory into the source directory +diff -rupN hdf5-1.8.8/tools/lib/CMakeLists.txt hdf5-1.8.8.cotire/tools/lib/CMakeLists.txt +--- hdf5-1.8.8/tools/lib/CMakeLists.txt 2011-11-07 23:11:35.000000000 +0100 ++++ hdf5-1.8.8.cotire/tools/lib/CMakeLists.txt 2012-03-24 17:28:41.000000000 +0100 +@@ -40,6 +40,9 @@ H5_SET_LIB_OPTIONS ( + HDF5_TOOLS_LIB_NAME_RELEASE + HDF5_TOOLS_LIB_NAME_DEBUG + ) ++if (COMMAND cotire) ++cotire(${HDF5_TOOLS_LIB_TARGET}) ++endif() + + ############################################################################## + ############################################################################## diff --git a/Patches/libpng-1.5.9.patch b/Patches/libpng-1.5.9.patch new file mode 100644 index 0000000..09e987d --- /dev/null +++ b/Patches/libpng-1.5.9.patch @@ -0,0 +1,38 @@ +diff -rupN libpng-1.5.9/CMakeLists.txt libpng-1.5.9.cotire/CMakeLists.txt +--- libpng-1.5.9/CMakeLists.txt 2012-02-18 21:31:14.000000000 +0100 ++++ libpng-1.5.9.cotire/CMakeLists.txt 2012-03-24 18:08:54.000000000 +0100 +@@ -9,6 +9,8 @@ + cmake_minimum_required(VERSION 2.4.4) + set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") ++ + if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE) + if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4) + # workaround CMake 2.4.x bug +@@ -146,6 +148,12 @@ if(PNG_SHARED) + set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib") + endif() + target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ if (COMMAND cotire) ++ cotire(${PNG_LIB_NAME}) ++ if (TARGET ${PNG_LIB_NAME}_unity) ++ target_link_libraries(${PNG_LIB_NAME}_unity ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ endif() ++ endif() + endif() + + if(PNG_STATIC) +@@ -157,6 +165,12 @@ if(PNG_STATIC) + set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib") + endif() + target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ if (COMMAND cotire) ++ cotire(${PNG_LIB_NAME_STATIC}) ++ if (TARGET ${PNG_LIB_NAME_STATIC}_unity) ++ target_link_libraries(${PNG_LIB_NAME_STATIC}_unity ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ endif() ++ endif() + endif() + + if(PNG_SHARED AND WIN32) diff --git a/Patches/llvm-3.0.src.patch b/Patches/llvm-3.0.src.patch new file mode 100644 index 0000000..20cfbd9 --- /dev/null +++ b/Patches/llvm-3.0.src.patch @@ -0,0 +1,58 @@ +diff -rupN llvm-3.0.src/CMakeLists.txt llvm-3.0.src.cotire/CMakeLists.txt +--- llvm-3.0.src/CMakeLists.txt 2011-10-06 03:51:51.000000000 +0200 ++++ llvm-3.0.src.cotire/CMakeLists.txt 2012-03-24 12:37:46.000000000 +0100 +@@ -15,6 +15,7 @@ set(PACKAGE_VERSION "3.0") + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + + include(VersionFromVCS) ++include(cotire) + + option(LLVM_APPEND_VC_REV + "Append the version control system revision id to LLVM version" OFF) +diff -rupN llvm-3.0.src/cmake/modules/AddLLVM.cmake llvm-3.0.src.cotire/cmake/modules/AddLLVM.cmake +--- llvm-3.0.src/cmake/modules/AddLLVM.cmake 2011-07-30 10:47:05.000000000 +0200 ++++ llvm-3.0.src.cotire/cmake/modules/AddLLVM.cmake 2012-03-11 15:06:04.000000000 +0100 +@@ -25,6 +25,9 @@ macro(add_llvm_library name) + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Libraries") ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + endmacro(add_llvm_library name) + + macro(add_llvm_library_dependencies name) +@@ -69,6 +72,9 @@ ${name} ignored.") + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") +@@ -89,6 +95,9 @@ macro(add_llvm_executable name) + add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) + endif( LLVM_COMMON_DEPENDS ) + link_system_libs( ${name} ) ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + endmacro(add_llvm_executable name) + + +diff -rupN llvm-3.0.src/lib/Support/CMakeLists.txt llvm-3.0.src.cotire/lib/Support/CMakeLists.txt +--- llvm-3.0.src/lib/Support/CMakeLists.txt 2011-09-13 21:42:16.000000000 +0200 ++++ llvm-3.0.src.cotire/lib/Support/CMakeLists.txt 2012-03-24 12:38:36.000000000 +0100 +@@ -4,6 +4,10 @@ if( MINGW ) + set(LLVM_REQUIRES_EH 1) + endif() + ++if (COMMAND cotire) ++ set_source_files_properties (IsInf.cpp IsNAN.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMSupport + APFloat.cpp + APInt.cpp diff --git a/Patches/yaml-cpp.patch b/Patches/yaml-cpp.patch new file mode 100644 index 0000000..c6166fd --- /dev/null +++ b/Patches/yaml-cpp.patch @@ -0,0 +1,37 @@ +diff -rupN yaml-cpp/CMakeLists.txt yaml-cpp-cotire/CMakeLists.txt +--- yaml-cpp/CMakeLists.txt 2012-01-21 09:52:48.000000000 +0100 ++++ yaml-cpp-cotire/CMakeLists.txt 2012-03-24 17:14:15.000000000 +0100 +@@ -14,6 +14,7 @@ if(POLICY CMP0015) + endif() + + include(CheckCXXCompilerFlag) ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") + + + ### +@@ -235,6 +236,7 @@ add_library(yaml-cpp + ${contrib_private_headers} + ) + ++cotire(yaml-cpp) + set_target_properties(yaml-cpp PROPERTIES + VERSION "${YAML_CPP_VERSION}" + SOVERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}" +diff -rupN yaml-cpp/test/CMakeLists.txt yaml-cpp-cotire/test/CMakeLists.txt +--- yaml-cpp/test/CMakeLists.txt 2012-01-21 09:52:48.000000000 +0100 ++++ yaml-cpp-cotire/test/CMakeLists.txt 2012-02-19 10:21:36.000000000 +0100 +@@ -13,3 +13,5 @@ add_executable(run-tests + target_link_libraries(run-tests yaml-cpp) + + add_test(yaml-reader-test run-tests) ++ ++cotire(run-tests) +\ No newline at end of file +diff -rupN yaml-cpp/util/CMakeLists.txt yaml-cpp-cotire/util/CMakeLists.txt +--- yaml-cpp/util/CMakeLists.txt 2012-01-21 09:52:48.000000000 +0100 ++++ yaml-cpp-cotire/util/CMakeLists.txt 2012-02-19 10:21:54.000000000 +0100 +@@ -1,2 +1,3 @@ + add_executable(parse parse.cpp) + target_link_libraries(parse yaml-cpp) ++cotire(parse) +\ No newline at end of file diff --git a/Patches/zlib-1.2.6.patch b/Patches/zlib-1.2.6.patch new file mode 100644 index 0000000..e48086f --- /dev/null +++ b/Patches/zlib-1.2.6.patch @@ -0,0 +1,23 @@ +diff -rupN zlib-1.2.6/CMakeLists.txt zlib-1.2.6.cotire/CMakeLists.txt +--- zlib-1.2.6/CMakeLists.txt 2012-01-17 03:51:23.000000000 +0100 ++++ zlib-1.2.6.cotire/CMakeLists.txt 2012-03-24 21:08:41.000000000 +0100 +@@ -7,6 +7,8 @@ if(NOT DEFINED BUILD_SHARED_LIBS) + option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) + endif() + ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") ++ + include(CheckTypeSize) + include(CheckFunctionExists) + include(CheckIncludeFile) +@@ -176,6 +178,10 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_I + install(FILES zlib.3 DESTINATION share/man/man3) + endif() + ++if (COMMAND cotire) ++ cotire(zlib) ++endif() ++ + #============================================================================ + # Example binaries + #============================================================================ diff --git a/README.md b/README.md index cb1fcc6..b6a307b 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,9 @@ the original target, but does so much faster by entering: See the advanced usage section of the [cotire manual][manual] for information on how to configure the cotire process (e.g., how to apply cotire to a certain build configuration only). +The directory `Patches` contains patch files to enable cotire for some popular open sources +packages that use CMake as a build system. + speedup ------- From a720d20bd19f202878f60e8a3b09a17c444521bd Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 26 Mar 2012 21:39:39 +0200 Subject: [PATCH 012/169] cotire 1.0.5 --- CMake/cotire.cmake | 11 +++++------ HISTORY.md | 6 ++++++ Patches/README.md | 2 +- Patches/llvm-3.0.src.patch | 17 ++++++++++++++--- src/log.cpp | 2 +- src/log.h | 2 +- src/main.cpp | 2 +- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ed44786..7d6f6e4 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.4") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.5") include(CMakeParseArguments) @@ -657,11 +657,10 @@ macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar) set (${_headerIsIgnoredVar} TRUE) elseif (IS_DIRECTORY "${_headerFile}") set (${_headerIsIgnoredVar} TRUE) - elseif ("${_headerFile}" MATCHES "\\.\\." AND "${_headerFile}" MATCHES "\\.h$") - # ignore C headers with embedded parent directory references - # these often stem from using GCC #include_next tricks - # which break the precompiled header compilation with the error message - # "error: no include path in which to search for header.h" + elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed" AND "${_headerFile}" MATCHES "\\.h$") + # heuristic: ignore C headers with embedded parent directory references or "-fixed" or "_fixed" in path + # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation + # with the error message "error: no include path in which to search for header.h" set (${_headerIsIgnoredVar} TRUE) else() set (${_headerIsIgnoredVar} FALSE) diff --git a/HISTORY.md b/HISTORY.md index 717f12a..1eef952 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.0.5 (2012-03-26) + +* fix Visual Studio C++ 2010 compilation of example project. +* enhance heuristic for #include_next directive detection. +* fix llvm-3.0.src.patch for GCC 4.6 compilation. + ## 1.0.4 (2012-03-24) * honor target property INCLUDE_DIRECTORIES introduced in CMake 2.8.8. diff --git a/Patches/README.md b/Patches/README.md index fb54cfe..54f1736 100644 --- a/Patches/README.md +++ b/Patches/README.md @@ -9,7 +9,7 @@ Then apply the corresponding patch: $ cd /path/to/llvm-3.0.src $ patch -p1 < /path/to/llvm-3.0.src.patch -Then proceed with an out-of-source Cmake build: +Then proceed with an out-of-source CMake build: $ mkdir build; cd build $ cmake .. diff --git a/Patches/llvm-3.0.src.patch b/Patches/llvm-3.0.src.patch index 20cfbd9..0ae3af0 100644 --- a/Patches/llvm-3.0.src.patch +++ b/Patches/llvm-3.0.src.patch @@ -1,6 +1,6 @@ diff -rupN llvm-3.0.src/CMakeLists.txt llvm-3.0.src.cotire/CMakeLists.txt --- llvm-3.0.src/CMakeLists.txt 2011-10-06 03:51:51.000000000 +0200 -+++ llvm-3.0.src.cotire/CMakeLists.txt 2012-03-24 12:37:46.000000000 +0100 ++++ llvm-3.0.src.cotire/CMakeLists.txt 2012-03-26 20:59:22.000000000 +0200 @@ -15,6 +15,7 @@ set(PACKAGE_VERSION "3.0") set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -11,7 +11,7 @@ diff -rupN llvm-3.0.src/CMakeLists.txt llvm-3.0.src.cotire/CMakeLists.txt "Append the version control system revision id to LLVM version" OFF) diff -rupN llvm-3.0.src/cmake/modules/AddLLVM.cmake llvm-3.0.src.cotire/cmake/modules/AddLLVM.cmake --- llvm-3.0.src/cmake/modules/AddLLVM.cmake 2011-07-30 10:47:05.000000000 +0200 -+++ llvm-3.0.src.cotire/cmake/modules/AddLLVM.cmake 2012-03-11 15:06:04.000000000 +0100 ++++ llvm-3.0.src.cotire/cmake/modules/AddLLVM.cmake 2012-03-26 20:59:22.000000000 +0200 @@ -25,6 +25,9 @@ macro(add_llvm_library name) ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) endif() @@ -42,9 +42,20 @@ diff -rupN llvm-3.0.src/cmake/modules/AddLLVM.cmake llvm-3.0.src.cotire/cmake/mo endmacro(add_llvm_executable name) +diff -rupN llvm-3.0.src/lib/Analysis/CMakeLists.txt llvm-3.0.src.cotire/lib/Analysis/CMakeLists.txt +--- llvm-3.0.src/lib/Analysis/CMakeLists.txt 2011-07-29 02:14:25.000000000 +0200 ++++ llvm-3.0.src.cotire/lib/Analysis/CMakeLists.txt 2012-03-26 20:59:36.000000000 +0200 +@@ -1,3 +1,7 @@ ++if (COMMAND cotire) ++ set_source_files_properties (ConstantFolding.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMAnalysis + AliasAnalysis.cpp + AliasAnalysisCounter.cpp diff -rupN llvm-3.0.src/lib/Support/CMakeLists.txt llvm-3.0.src.cotire/lib/Support/CMakeLists.txt --- llvm-3.0.src/lib/Support/CMakeLists.txt 2011-09-13 21:42:16.000000000 +0200 -+++ llvm-3.0.src.cotire/lib/Support/CMakeLists.txt 2012-03-24 12:38:36.000000000 +0100 ++++ llvm-3.0.src.cotire/lib/Support/CMakeLists.txt 2012-03-26 20:59:22.000000000 +0200 @@ -4,6 +4,10 @@ if( MINGW ) set(LLVM_REQUIRES_EH 1) endif() diff --git a/src/log.cpp b/src/log.cpp index 714714f..5294adb 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -4,7 +4,7 @@ #include -namespace log { +namespace logging { void error(const std::string& msg) { std::cerr << msg << std::endl; diff --git a/src/log.h b/src/log.h index 37919b4..a6ce24a 100644 --- a/src/log.h +++ b/src/log.h @@ -2,7 +2,7 @@ #include -namespace log { +namespace logging { void error(const std::string& msg); void info(const std::string& msg); diff --git a/src/main.cpp b/src/main.cpp index 1376d19..6c7aadc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,5 +8,5 @@ int main(int argc, char** argv) { std::string msg = example::get_message(); - log::info(msg); + logging::info(msg); } From 21304a24a77b7720d53b032c0e008561a34ab95c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 1 Apr 2012 14:45:44 +0200 Subject: [PATCH 013/169] cotire 1.0.6 --- CMake/cotire.cmake | 14 +- HISTORY.md | 4 + Patches/OpenCV-2.3.1.patch | 299 +++++++++++++++++++++++++++++++++++++ 3 files changed, 312 insertions(+), 5 deletions(-) create mode 100644 Patches/OpenCV-2.3.1.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 7d6f6e4..02c5ce0 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.6") include(CMakeParseArguments) @@ -409,7 +409,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta string (TOUPPER "${_config}" _config) set (_configDefinitions "") # CMAKE_INTDIR for multi-configuration build systems - if (CMAKE_CONFIGURATION_TYPES) + if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"") endif() # target export define symbol @@ -1398,7 +1398,6 @@ function (cotire_generate_target_script _language _configurations _target _targe cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS) # set up variables to be configured set (COTIRE_TARGET_LANGUAGE "${_language}") - set (COTIRE_TARGET_CONFIGURATIONS "${_configurations}") cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) @@ -1436,7 +1435,8 @@ function (cotire_generate_target_script _language _configurations _target _targe list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) set (_contents "") foreach (_var IN LISTS _matchVars ITEMS - MSVC CMAKE_GENERATOR CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES + CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") set (_contents "${_contents}set (${_var} \"${_value}\")\n") @@ -2214,8 +2214,12 @@ if (CMAKE_SCRIPT_MODE_FILE) set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${COTIRE_BUILD_TYPE}}) set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${COTIRE_BUILD_TYPE}}) + if (NOT COTIRE_BUILD_TYPE) + # init COTIRE_BUILD_TYPE to first configuration type if not set explicitly + list (GET CMAKE_CONFIGURATION_TYPES 0 COTIRE_BUILD_TYPE) + endif() # check if target has been cotired for actual build type COTIRE_BUILD_TYPE - list (FIND COTIRE_TARGET_CONFIGURATIONS "${COTIRE_BUILD_TYPE}" _index) + list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) if (_index GREATER -1) set (_sources ${COTIRE_TARGET_SOURCES}) set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) diff --git a/HISTORY.md b/HISTORY.md index 1eef952..be36b83 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.0.6 (2012-04-01) + +* correctly handle builds where both `CMAKE_BUILD_TYPE` and `CMAKE_CONFIGURATION_TYPES` are set. + ## 1.0.5 (2012-03-26) * fix Visual Studio C++ 2010 compilation of example project. diff --git a/Patches/OpenCV-2.3.1.patch b/Patches/OpenCV-2.3.1.patch new file mode 100644 index 0000000..43fc141 --- /dev/null +++ b/Patches/OpenCV-2.3.1.patch @@ -0,0 +1,299 @@ +diff -rupN OpenCV-2.3.1/3rdparty/libjasper/CMakeLists.txt OpenCV-2.3.1.cotire/3rdparty/libjasper/CMakeLists.txt +--- OpenCV-2.3.1/3rdparty/libjasper/CMakeLists.txt 2011-09-12 20:39:55.000000000 +0200 ++++ OpenCV-2.3.1.cotire/3rdparty/libjasper/CMakeLists.txt 2012-04-01 11:23:04.000000000 +0200 +@@ -56,3 +56,7 @@ if(NOT BUILD_SHARED_LIBS) + install(TARGETS ${the_target} + ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/3rdparty/libjpeg/CMakeLists.txt OpenCV-2.3.1.cotire/3rdparty/libjpeg/CMakeLists.txt +--- OpenCV-2.3.1/3rdparty/libjpeg/CMakeLists.txt 2011-09-12 20:40:15.000000000 +0200 ++++ OpenCV-2.3.1.cotire/3rdparty/libjpeg/CMakeLists.txt 2012-04-01 11:23:10.000000000 +0200 +@@ -48,3 +48,7 @@ if(NOT BUILD_SHARED_LIBS) + install(TARGETS ${the_target} + ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/3rdparty/libpng/CMakeLists.txt OpenCV-2.3.1.cotire/3rdparty/libpng/CMakeLists.txt +--- OpenCV-2.3.1/3rdparty/libpng/CMakeLists.txt 2011-09-12 20:40:02.000000000 +0200 ++++ OpenCV-2.3.1.cotire/3rdparty/libpng/CMakeLists.txt 2012-04-01 11:23:17.000000000 +0200 +@@ -49,3 +49,7 @@ if(NOT BUILD_SHARED_LIBS) + install(TARGETS ${the_target} + ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/3rdparty/libtiff/CMakeLists.txt OpenCV-2.3.1.cotire/3rdparty/libtiff/CMakeLists.txt +--- OpenCV-2.3.1/3rdparty/libtiff/CMakeLists.txt 2011-09-12 20:29:15.000000000 +0200 ++++ OpenCV-2.3.1.cotire/3rdparty/libtiff/CMakeLists.txt 2012-04-01 11:23:23.000000000 +0200 +@@ -103,3 +103,7 @@ if(NOT BUILD_SHARED_LIBS) + install(TARGETS ${the_target} + ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/3rdparty/zlib/CMakeLists.txt OpenCV-2.3.1.cotire/3rdparty/zlib/CMakeLists.txt +--- OpenCV-2.3.1/3rdparty/zlib/CMakeLists.txt 2011-09-12 20:29:21.000000000 +0200 ++++ OpenCV-2.3.1.cotire/3rdparty/zlib/CMakeLists.txt 2012-04-01 11:24:36.000000000 +0200 +@@ -40,3 +40,7 @@ if(NOT BUILD_SHARED_LIBS) + install(TARGETS ${the_target} + ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/CMakeLists.txt OpenCV-2.3.1.cotire/CMakeLists.txt +--- OpenCV-2.3.1/CMakeLists.txt 2011-09-12 20:45:38.000000000 +0200 ++++ OpenCV-2.3.1.cotire/CMakeLists.txt 2012-04-01 14:34:56.000000000 +0200 +@@ -39,6 +39,8 @@ endif(NOT CMAKE_TOOLCHAIN_FILE) + cmake_minimum_required(VERSION 2.4) + project(OpenCV) + ++include("${CMAKE_SOURCE_DIR}/cotire.cmake") ++ + set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE) + if(DEFINED CMAKE_BUILD_TYPE) + set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} ) +diff -rupN OpenCV-2.3.1/OpenCVModule.cmake OpenCV-2.3.1.cotire/OpenCVModule.cmake +--- OpenCV-2.3.1/OpenCVModule.cmake 2011-09-12 20:45:38.000000000 +0200 ++++ OpenCV-2.3.1.cotire/OpenCVModule.cmake 2012-04-01 11:26:16.000000000 +0200 +@@ -86,7 +86,7 @@ macro(define_opencv_module name) + INSTALL_NAME_DIR lib + ) + +- add_opencv_precompiled_headers(${the_target}) ++# add_opencv_precompiled_headers(${the_target}) + + # Add the required libraries for linking: + target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) +@@ -102,6 +102,10 @@ macro(define_opencv_module name) + ) + endif() + ++ if (COMMAND cotire) ++ cotire(${the_target}) ++ endif() ++ + # Dependencies of this target: + add_dependencies(${the_target} ${ARGN}) + +@@ -137,7 +141,7 @@ macro(define_opencv_module name) + + add_executable(${the_target} ${test_srcs} ${test_hdrs}) + +- add_opencv_precompiled_headers(${the_target}) ++# add_opencv_precompiled_headers(${the_target}) + + # Additional target properties + set_target_properties(${the_target} PROPERTIES +@@ -149,6 +153,10 @@ macro(define_opencv_module name) + set_target_properties(${the_target} PROPERTIES FOLDER "tests") + endif() + ++ if (COMMAND cotire) ++ cotire(${the_target}) ++ endif() ++ + add_dependencies(${the_target} ${test_deps}) + + # Add the required libraries for linking: +diff -rupN OpenCV-2.3.1/modules/androidcamera/CMakeLists.txt OpenCV-2.3.1.cotire/modules/androidcamera/CMakeLists.txt +--- OpenCV-2.3.1/modules/androidcamera/CMakeLists.txt 2011-09-12 20:42:03.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/androidcamera/CMakeLists.txt 2012-04-01 11:28:54.000000000 +0200 +@@ -52,3 +52,7 @@ if (NOT BUILD_ANDROID_CAMERA_WRAPPER) + COMPONENT main) + endforeach() + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/modules/androidcamera/camera_wrapper/CMakeLists.txt OpenCV-2.3.1.cotire/modules/androidcamera/camera_wrapper/CMakeLists.txt +--- OpenCV-2.3.1/modules/androidcamera/camera_wrapper/CMakeLists.txt 2011-09-12 20:42:03.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/androidcamera/camera_wrapper/CMakeLists.txt 2012-04-01 11:20:26.000000000 +0200 +@@ -34,3 +34,7 @@ SET_TARGET_PROPERTIES(${the_target} PROP + ) + + install(TARGETS ${the_target} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/modules/gpu/CMakeLists.txt OpenCV-2.3.1.cotire/modules/gpu/CMakeLists.txt +--- OpenCV-2.3.1/modules/gpu/CMakeLists.txt 2011-09-12 20:42:20.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/gpu/CMakeLists.txt 2012-04-01 11:41:04.000000000 +0200 +@@ -106,7 +106,7 @@ if (BUILD_SHARED_LIBS) + endif() + endif() + +-add_opencv_precompiled_headers(${the_target}) ++#add_opencv_precompiled_headers(${the_target}) + + # Additional target properties + set_target_properties(${the_target} PROPERTIES +@@ -156,6 +156,9 @@ install(FILES src/nvidia/NPP_staging/NPP + # DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}/device + # COMPONENT main) + ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() + + ################################################################################################################ + ################################ GPU Module Tests ##################################################### +@@ -192,14 +195,17 @@ if(BUILD_TESTS AND EXISTS ${CMAKE_CURREN + + add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia}) + +- add_opencv_precompiled_headers(${the_test_target}) ++# add_opencv_precompiled_headers(${the_test_target}) + + # Additional target properties + set_target_properties(${the_test_target} PROPERTIES + DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" + RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}" + ) +- ++ if (COMMAND cotire) ++ cotire(${the_test_target}) ++ endif() ++ + if(ENABLE_SOLUTION_FOLDERS) + set_target_properties(${the_test_target} PROPERTIES FOLDER "tests") + endif() +diff -rupN OpenCV-2.3.1/modules/haartraining/CMakeLists.txt OpenCV-2.3.1.cotire/modules/haartraining/CMakeLists.txt +--- OpenCV-2.3.1/modules/haartraining/CMakeLists.txt 2011-09-12 20:43:56.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/haartraining/CMakeLists.txt 2012-04-01 11:21:27.000000000 +0200 +@@ -45,6 +45,10 @@ set_target_properties(opencv_haartrainin + INSTALL_NAME_DIR lib + ) + ++if (COMMAND cotire) ++cotire(opencv_haartraining_engine) ++endif() ++ + if(NOT ANDROID) + # ----------------------------------------------------------- + # haartraining +diff -rupN OpenCV-2.3.1/modules/highgui/CMakeLists.txt OpenCV-2.3.1.cotire/modules/highgui/CMakeLists.txt +--- OpenCV-2.3.1/modules/highgui/CMakeLists.txt 2011-09-12 20:41:29.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/highgui/CMakeLists.txt 2012-04-01 12:17:12.000000000 +0200 +@@ -77,6 +77,10 @@ file(GLOB grfmt_srcs src/grfmt*.cpp) + set(grfmt_hdrs src/bitstrm.hpp ${grfmt_hdrs}) + set(grfmt_srcs src/bitstrm.cpp ${grfmt_srcs}) + ++if (COMMAND cotire) ++ set_source_files_properties (${grfmt_srcs} PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs}) + + set(highgui_srcs +@@ -209,6 +213,9 @@ if(APPLE) + else() + set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm) + endif() ++ if (COMMAND cotire) ++ set_source_files_properties (src/window_cocoa.mm src/cap_qtkit.mm PROPERTIES COTIRE_EXCLUDED TRUE) ++ endif() + endif(APPLE) + + if(WITH_ANDROID_CAMERA) +@@ -276,7 +283,7 @@ if (BUILD_SHARED_LIBS) + endif() + endif() + +-add_opencv_precompiled_headers(${the_target}) ++#add_opencv_precompiled_headers(${the_target}) + + # For dynamic link numbering convenions + if(NOT ANDROID) +@@ -307,6 +314,10 @@ if(MSVC) + set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") + endif(MSVC) + ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() ++ + # Dependencies of this target: + add_dependencies(${the_target} opencv_core opencv_imgproc) + +@@ -397,7 +408,7 @@ if(BUILD_TESTS) + + add_executable(${the_target} ${test_srcs} ${test_hdrs}) + +- add_opencv_precompiled_headers(${the_target}) ++# add_opencv_precompiled_headers(${the_target}) + + # Additional target properties + set_target_properties(${the_target} PROPERTIES +@@ -409,6 +420,10 @@ if(BUILD_TESTS) + set_target_properties(${the_target} PROPERTIES FOLDER "tests") + endif() + ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() ++ + add_dependencies(${the_target} ${test_deps}) + + # Add the required libraries for linking: +diff -rupN OpenCV-2.3.1/modules/java/CMakeLists.txt OpenCV-2.3.1.cotire/modules/java/CMakeLists.txt +--- OpenCV-2.3.1/modules/java/CMakeLists.txt 2011-09-12 20:40:26.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/java/CMakeLists.txt 2012-04-01 11:22:49.000000000 +0200 +@@ -163,6 +163,10 @@ set_target_properties(${target} PROPERTI + + install(TARGETS ${target} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + ++if (COMMAND cotire) ++cotire(${target}) ++endif() ++ + if(ANDROID) + target_link_libraries(${target} jnigraphics) + +diff -rupN OpenCV-2.3.1/modules/python/CMakeLists.txt OpenCV-2.3.1.cotire/modules/python/CMakeLists.txt +--- OpenCV-2.3.1/modules/python/CMakeLists.txt 2011-09-12 20:40:30.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/python/CMakeLists.txt 2012-04-01 11:23:51.000000000 +0200 +@@ -92,3 +92,7 @@ install(TARGETS ${cvpymodules} + ARCHIVE DESTINATION ${CVPY_PATH} COMPONENT main + ) + install(FILES src2/cv.py DESTINATION ${CVPY_PATH} COMPONENT main) ++ ++if (COMMAND cotire) ++cotire(${cv2_target}) ++endif() +diff -rupN OpenCV-2.3.1/modules/stitching/CMakeLists.txt OpenCV-2.3.1.cotire/modules/stitching/CMakeLists.txt +--- OpenCV-2.3.1/modules/stitching/CMakeLists.txt 2011-09-12 20:42:22.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/stitching/CMakeLists.txt 2012-04-01 11:24:09.000000000 +0200 +@@ -38,3 +38,7 @@ endif() + target_link_libraries(${the_target} ${stitching_libs}) + + install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main) ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() +diff -rupN OpenCV-2.3.1/modules/traincascade/CMakeLists.txt OpenCV-2.3.1.cotire/modules/traincascade/CMakeLists.txt +--- OpenCV-2.3.1/modules/traincascade/CMakeLists.txt 2011-09-12 20:40:17.000000000 +0200 ++++ OpenCV-2.3.1.cotire/modules/traincascade/CMakeLists.txt 2012-04-01 11:24:25.000000000 +0200 +@@ -44,3 +44,7 @@ target_link_libraries(${the_target} ${tr + if(NOT ANDROID) + install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main) + endif() ++ ++if (COMMAND cotire) ++cotire(${the_target}) ++endif() From 85b6368ab9f92a65399ce76da0d9268da11c7806 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 2 Apr 2012 20:49:08 +0200 Subject: [PATCH 014/169] cotire 1.0.7 --- CMake/cotire.cmake | 62 ++++++++++++++++++++++++++++++++++++++-------- HISTORY.md | 5 ++++ 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 02c5ce0..981ca7d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -36,7 +36,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.5) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.6") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.7") include(CMakeParseArguments) @@ -198,7 +198,7 @@ function (cotire_get_source_file_property_values _valuesVar _property) set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() -function (cotrie_copy_set_properites _configurations _type _source _target) +function (cotrie_resolve_config_properites _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "") @@ -211,6 +211,11 @@ function (cotrie_copy_set_properites _configurations _type _source _target) list (APPEND _properties ${_property}) endif() endforeach() + set (${_propertiesVar} ${_properties} PARENT_SCOPE) +endfunction() + +function (cotrie_copy_set_properites _configurations _type _source _target) + cotrie_resolve_config_properites("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) @@ -1465,7 +1470,7 @@ function (cotire_setup_pch_file_compilation _language _targetScript _prefixFile # make first source file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") endif() - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) @@ -1505,7 +1510,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _pre # make source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") if (NOT _wholeTarget) # for makefile based generator, we force the inclusion of the prefix header for a subset # of the source files, if this is a multi-language target or has excluded files @@ -1567,7 +1572,7 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") if (_wholeTarget) # for makefile based generator, we force inclusion of the prefix header for all target source files # if this is a single-language target without any excluded files @@ -1888,7 +1893,7 @@ function (cotire_setup_clean_target _target) endfunction() function (cotire_setup_pch_target _languages _configurations _target) - if ("${CMAKE_GENERATOR}" MATCHES "Makefiles") + if ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generators, we add a custom target to trigger the generation of the cotire related files set (_dependsFiles "") foreach (_language ${_languages}) @@ -1973,12 +1978,39 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() - # copy output location properties - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_ - RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_ - Fortran_MODULE_DIRECTORY) + RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_) + # copy output location properties + if (COTIRE_UNITY_OUTPUT_DIRECTORY) + set (_setDefaultOutputDir TRUE) + if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") + set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") + else() + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotrie_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) + foreach (_property ${_properties}) + get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) + if (_outputDir) + get_filename_component(_outputDir "${_outputDir}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) + set_property(TARGET ${_target} PROPERTY ${_property} "${_outputDir}") + set (_setDefaultOutputDir FALSE) + endif() + endforeach() + if (_setDefaultOutputDir) + get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) + endif() + endif() + if (_setDefaultOutputDir) + set_target_properties(${_unityTargetName} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${_outputDir}" + LIBRARY_OUTPUT_DIRECTORY "${_outputDir}" + RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") + endif() + else() + cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + endif() # copy output name cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ @@ -2329,7 +2361,7 @@ else() endif() option (COTIRE_DEBUG "Enable cotire debugging output?" ${COTIRE_DEBUG_INIT}) - if (NOT DEFINED COTIRE_DEBUG_INIT) + if (NOT DEFINED COTIRE_VERBOSE_INIT) if (DEFINED COTIRE_VERBOSE) set (COTIRE_VERBOSE_INIT ${COTIRE_VERBOSE}) else() @@ -2380,6 +2412,14 @@ else() if (NOT DEFINED COTIRE_TARGETS_FOLDER) set (COTIRE_TARGETS_FOLDER "cotire") endif() + if (NOT DEFINED COTIRE_UNITY_OUTPUT_DIRECTORY) + if ("${CMAKE_GENERATOR}" MATCHES "Ninja") + # generated Ninja build files do not work if the unity target produces the same output file as the cotired target + set (COTIRE_UNITY_OUTPUT_DIRECTORY "unity") + else() + set (COTIRE_UNITY_OUTPUT_DIRECTORY "") + endif() + endif() # define cotire cache variables diff --git a/HISTORY.md b/HISTORY.md index be36b83..368b2a5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.0.7 (2012-04-02) + +* add support for Ninja generator introduced in CMake 2.8.8. +* fix bug with initialization of variable `COTIRE_VERBOSE`. + ## 1.0.6 (2012-04-01) * correctly handle builds where both `CMAKE_BUILD_TYPE` and `CMAKE_CONFIGURATION_TYPES` are set. From 01195cc40cecf5e1f11eef365dee379ed9bca202 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 5 Apr 2012 12:39:29 +0200 Subject: [PATCH 015/169] cotire 1.0.8 require CMake 2.8.6 --- CMake/cotire.cmake | 5 +++-- HISTORY.md | 4 ++++ README.md | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 981ca7d..594db3e 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -33,10 +33,11 @@ endif() set(__COTIRE_INCLUDED TRUE) # we need the CMake variables CMAKE_SCRIPT_MODE_FILE and CMAKE_ARGV available since 2.8.5 -cmake_minimum_required(VERSION 2.8.5) +# we need APPEND_STRING option for set_property available since 2.8.6 +cmake_minimum_required(VERSION 2.8.6) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.7") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.8") include(CMakeParseArguments) diff --git a/HISTORY.md b/HISTORY.md index 368b2a5..0f3789a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.0.7 (2012-04-05) + +* require CMake 2.8.6 since we are using `set_property` option `APPEND_STRING`. + ## 1.0.7 (2012-04-02) * add support for Ninja generator introduced in CMake 2.8.8. diff --git a/README.md b/README.md index b6a307b..142e872 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ features requirements ------------ -* [CMake 2.8.5][cmk] or newer. The executable `cmake` should be on the system path. +* [CMake 2.8.6][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. * [GCC][gcc] under Linux. * [Xcode][xcdt] developer tools package under OS X. This includes [Clang][clang]. From c17b4762a1cc07bdef9239e96de0fe94d7795183 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 5 Apr 2012 12:50:37 +0200 Subject: [PATCH 016/169] fix version --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 0f3789a..94509dd 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,4 @@ -## 1.0.7 (2012-04-05) +## 1.0.8 (2012-04-05) * require CMake 2.8.6 since we are using `set_property` option `APPEND_STRING`. From 8037083a40b6bee2fee9c80290e1387d0f9c2c7b Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 9 Apr 2012 20:49:25 +0200 Subject: [PATCH 017/169] cotire 1.0.9 --- CMake/cotire.cmake | 101 +++++++++++++++++++++++++++++++++++---------- HISTORY.md | 5 +++ MANUAL.md | 23 +++++++++-- README.md | 5 ++- 4 files changed, 107 insertions(+), 27 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 594db3e..972685b 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -37,7 +37,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.6) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.8") +set (COTIRE_CMAKE_MODULE_VERSION "1.0.9") include(CMakeParseArguments) @@ -50,7 +50,8 @@ function (cotire_determine_compiler_version _language _versionPrefix) else() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} + string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" ${_versionPrefix}_VERSION "${_versionLine}") @@ -61,7 +62,8 @@ function (cotire_determine_compiler_version _language _versionPrefix) set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") else() # assume GCC like command line interface - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} "-dumpversion" + string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" OUTPUT_VARIABLE ${_versionPrefix}_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) endif() @@ -114,6 +116,10 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude else() set (_ignoreExtensions "") endif() + if (COTIRE_DEBUG) + message (STATUS "${_language} source file extensions: ${_languageExtensions}") + message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") + endif() foreach (_sourceFile ${ARGN}) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) @@ -465,6 +471,25 @@ function (cotire_get_target_compiler_flags _config _language _directory _target set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) endfunction() +function (cotire_add_sys_root_paths _pathsVar) + if (APPLE) + if (CMAKE_OSX_SYSROOT AND CMAKE_${_language}_HAS_ISYSROOT) + foreach (_path IN LISTS ${_pathsVar}) + if (IS_ABSOLUTE "${_path}") + get_filename_component(_path "${CMAKE_OSX_SYSROOT}/${_path}" ABSOLUTE) + if (EXISTS "${_path}") + list (APPEND ${_pathsVar} "${_path}") + endif() + endif() + endforeach() + endif() + endif() + set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE) + if (COTIRE_DEBUG) + message (STATUS "${_pathsVar}=${${_pathsVar}}") + endif() +endfunction() + function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) set (_extraProperties ${ARGN}) set (_result "") @@ -560,6 +585,17 @@ macro (cotire_set_cmd_to_prologue _cmdVar) endif() endmacro() +function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) + if (NOT _compilerExe) + set (_compilerExe "${CMAKE_${_language}_COMPILER") + endif() + if (NOT _compilerArg1) + set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) + endif() + string (STRIP "${_compilerArg1}" _compilerArg1) + set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) +endfunction() + macro (cotire_add_definitions_to_cmd _cmdVar) foreach (_definition ${ARGN}) if (MSVC) @@ -822,13 +858,11 @@ function (cotire_scan_includes _includesVar) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") endif() - if (NOT _option_COMPILER_EXECUTABLE) - set (_option_COMPILER_EXECUTABLE "${CMAKE_${_option_LANGUAGE}_COMPILER}") - endif() if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() - set (_cmd "${_option_COMPILER_EXECUTABLE}") + set (_cmd "${_option_COMPILER_EXECUTABLE}" ${_option_COMPILER_ARG1}) + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) @@ -1052,18 +1086,17 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags elseif ("${_compilerID}" STREQUAL "GNU") # GCC options used # -H print the name of each header file used - # -M do dependency scanning - # -MG don't raise error on missing files + # -E invoke preprocessor # -fdirectives-only do not expand macros, requires GCC >= 4.3 if (_flags) # append to list - list (APPEND _flags -H -M -MG) + list (APPEND _flags -H -E) if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") list (APPEND _flags "-fdirectives-only") endif() else() # return as a flag string - set (_flags "-H -M -MG") + set (_flags "-H -E") if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") set (_flags "${_flags} -fdirectives-only") endif() @@ -1071,13 +1104,13 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags elseif ("${_compilerID}" STREQUAL "Clang") # Clang options used # -H print the name of each header file used - # -M do dependency scanning + # -E invoke preprocessor if (_flags) # append to list - list (APPEND _flags -H -M) + list (APPEND _flags -H -E) else() # return as a flag string - set (_flags "-H -M") + set (_flags "-H -E") endif() else() message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") @@ -1144,8 +1177,8 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # return as a flag string set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") endif() - elseif ("${_compilerID}" MATCHES "GNU|Clang") - # GCC / Clang options used + elseif ("${_compilerID}" STREQUAL "GNU") + # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used if (_flags) @@ -1155,6 +1188,17 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # return as a flag string set (_flags "-include \"${_prefixFile}\" -Winvalid-pch") endif() + elseif ("${_compilerID}" STREQUAL "Clang") + # Clang options used + # -include process include file as the first line of the primary source file + # -Qunused-arguments don't emit warning for unused driver arguments + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}" "-Qunused-arguments") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -Qunused-arguments") + endif() else() message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() @@ -1169,13 +1213,10 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") endif() - if (NOT _option_COMPILER_EXECUTABLE) - set (_option_COMPILER_EXECUTABLE "${CMAKE_${_option_LANGUAGE}_COMPILER") - endif() if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() - set (_cmd "${_option_COMPILER_EXECUTABLE}") + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) @@ -1406,7 +1447,9 @@ function (cotire_generate_target_script _language _configurations _target _targe set (COTIRE_TARGET_LANGUAGE "${_language}") cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) + cotire_add_sys_root_paths(COTIRE_TARGET_IGNORE_PATH) get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) + cotire_add_sys_root_paths(COTIRE_TARGET_INCLUDE_PATH) get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS) get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) @@ -1442,7 +1485,8 @@ function (cotire_generate_target_script _language _configurations _target _targe set (_contents "") foreach (_var IN LISTS _matchVars ITEMS MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES - CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 + CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") set (_contents "${_contents}set (${_var} \"${_value}\")\n") @@ -1713,7 +1757,12 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa string (REPLACE ";" " " _languagesStr "${_languages}") string (REPLACE ";" ", " _excludedStr "${ARGN}") set (_targetMsg "") - if (NOT _targetUsePCH AND NOT _targetAddSCU) + if (NOT _languages) + set (_targetMsg "Target ${_target} cannot be cotired.") + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetUsePCH AND NOT _targetAddSCU) set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build and precompiled header.") if (_disableMsg) set (_targetMsg "${_targetMsg} ${_disableMsg}") @@ -1786,6 +1835,12 @@ function (cotire_choose_target_languages _target _targetLanguagesVar) endif() endforeach() set (_targetMsgLevel STATUS) + if (NOT _targetLanguages) + string (REPLACE ";" " or " _languagesStr "${_languages}") + set (_disableMsg "No ${_languagesStr} source files.") + set (_targetUsePCH FALSE) + set (_targetAddSCU FALSE) + endif() if (_targetUsePCH) list (LENGTH _allSourceFiles _numberOfSources) if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) @@ -2297,6 +2352,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_generate_prefix_header( "${COTIRE_ARGV3}" ${_files} COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" @@ -2320,6 +2376,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_precompile_prefix_header( "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}" COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" diff --git a/HISTORY.md b/HISTORY.md index 94509dd..ba7d2a4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.0.9 (2012-04-09) + +* add support for compiler wrappers like ccache. +* under Mac OS X, apply `CMAKE_OSX_SYSROOT` to prefix header include and ignore paths. + ## 1.0.8 (2012-04-05) * require CMake 2.8.6 since we are using `set_property` option `APPEND_STRING`. diff --git a/MANUAL.md b/MANUAL.md index 070fceb..9e479d5 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -15,7 +15,7 @@ systems. The design of cotire tries to adhere to the following principles: #### as automatic as possible [Precompiled header][pch] and [unity builds][scu] are good ideas in principle, but in reality -they do not work if the burdon of maintaining the required additional source files (a +they do not work if the burden of maintaining the required additional source files (a [prefix header][pfh] and a unity source file) is put on the developer. A modern build system like CMake provides enough context information to have the build system generate and update these files automatically. @@ -351,7 +351,7 @@ As an example, if these properties are set on a source file of the example proje COTIRE_UNITY_SOURCE_PRE_UNDEFS "max;min" COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") -This will make cotire add #undefs to the generated unity source file. +This will make cotire add undefs to the generated unity source file. #ifdef __cplusplus #include "/Users/sakra/Documents/cotire/src/main.cpp" @@ -373,6 +373,15 @@ source and the prefix header for verbose builds. `COTIRE_VERBOSE` defaults to `F When using a Makefile generator `COTIRE_VERBOSE` defaults to the value of the makefile variable `VERBOSE` (i.e., `make VERBOSE=1`). +### using cotire with compiler wrappers + +Cotire is compatible with CMake compiler wrappers. For example, the use of [ccache][ccch] may be +enabled in the following way upon configuring the project: + + $ export CC="/usr/local/bin/ccache /usr/bin/gcc" + $ export CXX="/usr/local/bin/ccache /usr/bin/g++" + $ cmake .. + cotire usage restrictions ------------------------- @@ -390,10 +399,16 @@ multiple targets. Neither GCC nor Clang support the use of precompiled headers when performing a Mac OS X multi-architecture build (e.g., using option `-DCMAKE_OSX_ARCHITECTURES=i386;x86_64`). +### Objective-C + +CMake targets that contain Objective-C or Objective-C++ source files cannot be cotired. +To get a workable build system, set the `COTIRE_EXCLUDED` property on .m and .mm source files. + [1260]:http://www.cmake.org/Bug/view.php?id=1260 -[kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake -[gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html +[ccch]:http://ccache.samba.org/ [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders +[gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html +[kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx [msvc_pch_create]:http://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx [msvc_pch_use]:http://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx diff --git a/README.md b/README.md index 142e872..b795801 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,11 @@ features * Supports mixed language CMake targets. * Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds. * Compatible with CMake single build type and CMake multi-configuration builds. -* Compatible with most CMake generators. +* Compatible with most CMake generators (including [Ninja][ninja]). * Compatible with parallel builds (make -j, Visual Studio, Xcode). * Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). * Compatible with CMake's [cross-compiling][ccrc] support. +* Compatible with compiler wrappers like [ccache][ccch]. * Tested with Windows, Linux and OS X. * MIT licensed. @@ -104,6 +105,7 @@ limitations * The size of the CMake build folder will increase, because precompiled headers are large binaries. * It is not possible to share precompiled headers generated by cotire between CMake targets. +[ccch]:http://ccache.samba.org/ [ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling [cgwn]:http://www.cygwin.com/ [clang]:http://clang.llvm.org/ @@ -111,6 +113,7 @@ limitations [gcc]:http://gcc.gnu.org/ [manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md [mingw]:http://www.mingw.org/ +[ninja]:http://martine.github.com/ninja/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [pfh]:http://en.wikipedia.org/wiki/Prefix_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit From 127a097464bc4fd634d1cca7e44afadcd121cfb8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Apr 2012 20:38:10 +0200 Subject: [PATCH 018/169] cotire 1.1.0 --- CMake/cotire.cmake | 143 +++++++++++++++++++++++---------------------- HISTORY.md | 7 +++ MANUAL.md | 24 +++++++- 3 files changed, 102 insertions(+), 72 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 972685b..8525526 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -37,7 +37,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.6) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.0.9") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.0") include(CMakeParseArguments) @@ -210,8 +210,8 @@ function (cotrie_resolve_config_properites _configurations _propertiesVar) foreach (_property ${ARGN}) if ("${_property}" MATCHES "") foreach (_config ${_configurations}) - string (TOUPPER "${_config}" _config) - string (REPLACE "" "${_config}" _configProperty "${_property}") + string (TOUPPER "${_config}" _upperConfig) + string (REPLACE "" "${_upperConfig}" _configProperty "${_property}") list (APPEND _properties ${_configProperty}) endforeach() else() @@ -282,14 +282,14 @@ function (cotire_filter_compile_flags _flagFilter _matchedOptionsVar _unmatchedO endfunction() function (cotire_get_target_compile_flags _config _language _directory _target _flagsVar) - string (TOUPPER "${_config}" _config) + string (TOUPPER "${_config}" _upperConfig) # collect options from CMake language variables set (_compileFlags "") if (CMAKE_${_language}_FLAGS) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}") endif() - if (CMAKE_${_language}_FLAGS_${_config}) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_config}}") + if (CMAKE_${_language}_FLAGS_${_upperConfig}) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}") endif() if (_target) # add option from CMake target type variable @@ -326,7 +326,7 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ endif() # platform specific flags if (APPLE) - get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_config}) + get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) if (NOT _architectures) get_target_property(_architectures ${_target} OSX_ARCHITECTURES) endif() @@ -418,7 +418,7 @@ function (cotire_get_target_export_symbol _target _exportSymbolVar) endfunction() function (cotire_get_target_compile_definitions _config _language _directory _target _definitionsVar) - string (TOUPPER "${_config}" _config) + string (TOUPPER "${_config}" _upperConfig) set (_configDefinitions "") # CMAKE_INTDIR for multi-configuration build systems if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") @@ -434,7 +434,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() - get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS_${_config}) + get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() @@ -443,7 +443,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() - get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_config}) + get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() @@ -515,12 +515,12 @@ endfunction() function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar) set (_compileDefinitions "") if (NOT CMAKE_SCRIPT_MODE_FILE) - string (TOUPPER "${_config}" _config) + string (TOUPPER "${_config}" _upperConfig) get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS) if (_definitions) list (APPEND _compileDefinitions ${_definitions}) endif() - get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_config}) + get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _compileDefinitions ${_definitions}) endif() @@ -724,10 +724,10 @@ endmacro() macro (cotire_parse_line _line _headerFileVar _headerDepthVar) if (MSVC) # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: - # English: "Note: including file:" - # German: "Hinweis: Einlesen der Datei:" + # English: "Note: including file: C:\directory\file" + # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : character - if ("${_line}" MATCHES "^[^:]+:[^:]+:( +)(.*)$") + if ("${_line}" MATCHES "( +)([^:]+:[^:]+)$") # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) @@ -882,7 +882,10 @@ function (cotire_scan_includes _includesVar) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (WIN32) + if ("${_option_COMPILER_ID}" STREQUAL "MSVC") + if (COTIRE_DEBUG) + message (STATUS "clearing VS_UNICODE_OUTPUT") + endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -918,11 +921,12 @@ macro (cotire_comment_str _language _commentText _commentVar) endmacro() function (cotire_write_file _language _file _contents _force) - cotire_comment_str("${_language}" "cotire.cmake ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1) + get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) + cotire_comment_str("${_language}" "${_moduleName} ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1) cotire_comment_str("${_language}" "${_file}" _header2) set (_contents "${_header1}\n${_header2}\n${_contents}") if (COTIRE_DEBUG) - message ("${_contents}") + message (STATUS "${_contents}") endif() if (_force OR NOT EXISTS "${_file}") file (WRITE "${_file}" "${_contents}") @@ -1226,7 +1230,10 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (WIN32) + if ("${_option_COMPILER_ID}" STREQUAL "MSVC") + if (COTIRE_DEBUG) + message (STATUS "clearing VS_UNICODE_OUTPUT") + endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -1440,7 +1447,8 @@ endfunction() function (cotire_generate_target_script _language _configurations _target _targetScriptVar) set (COTIRE_TARGET_SOURCES ${ARGN}) - set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_cotire.cmake") + get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) + set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS) cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS) # set up variables to be configured @@ -1455,29 +1463,18 @@ function (cotire_generate_target_script _language _configurations _target _targe get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) - if (CMAKE_CONFIGURATION_TYPES) - set (COTIRE_TARGET_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}") - foreach (_config ${CMAKE_CONFIGURATION_TYPES}) - cotire_get_target_include_directories( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_config}) - cotire_get_target_compile_definitions( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_config}) - cotire_get_target_compiler_flags( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_config}) - cotire_get_source_files_compile_definitions( - "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_config} ${COTIRE_TARGET_SOURCES}) - endforeach() - else() - set (COTIRE_TARGET_CONFIGURATION_TYPES "") + set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") + foreach (_config ${_configurations}) + string (TOUPPER "${_config}" _upperConfig) cotire_get_target_include_directories( - "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES) + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}) cotire_get_target_compile_definitions( - "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS) + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) cotire_get_target_compiler_flags( - "${CMAKE_BUILD_TYPE}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS) + "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) cotire_get_source_files_compile_definitions( - "${CMAKE_BUILD_TYPE}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS ${COTIRE_TARGET_SOURCES}) - endif() + "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${COTIRE_TARGET_SOURCES}) + endforeach() get_cmake_property(_vars VARIABLES) string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") # remove COTIRE_VERBOSE which is passed as a CMake define on command line @@ -2137,8 +2134,10 @@ function (cotire_target _target) if (NOT _option_CONFIGURATIONS) if (CMAKE_CONFIGURATION_TYPES) set (_option_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) - else() + elseif (CMAKE_BUILD_TYPE) set (_option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}") + else() + set (_option_CONFIGURATIONS "None") endif() endif() # trivial checks @@ -2150,9 +2149,16 @@ function (cotire_target _target) # check if target needs to be cotired for build type # when using configuration types, the test is performed at build time cotire_init_cotire_target_properties(${_target}) - if (NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE AND _option_CONFIGURATIONS) - list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index) + if (NOT CMAKE_CONFIGURATION_TYPES) + if (CMAKE_BUILD_TYPE) + list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index) + else() + list (FIND _option_CONFIGURATIONS "None" _index) + endif() if (_index EQUAL -1) + if (COTIRE_DEBUG) + message (STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not cotired (${_option_CONFIGURATIONS})") + endif() return() endif() endif() @@ -2282,7 +2288,7 @@ if (CMAKE_SCRIPT_MODE_FILE) endforeach() if (COTIRE_DEBUG) - message ("${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") + message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") endif() # include target script if available @@ -2298,36 +2304,31 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() endif() - if (COTIRE_TARGET_CONFIGURATION_TYPES) - set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${COTIRE_BUILD_TYPE}}) - set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) - set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${COTIRE_BUILD_TYPE}}) - if (NOT COTIRE_BUILD_TYPE) - # init COTIRE_BUILD_TYPE to first configuration type if not set explicitly - list (GET CMAKE_CONFIGURATION_TYPES 0 COTIRE_BUILD_TYPE) - endif() - # check if target has been cotired for actual build type COTIRE_BUILD_TYPE - list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) - if (_index GREATER -1) - set (_sources ${COTIRE_TARGET_SOURCES}) - set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${COTIRE_BUILD_TYPE}}) - else() - set (_sources "") - set (_sourcesDefinitions "") - endif() - else() - set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES}) - set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS}) - set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS}) + if (NOT COTIRE_BUILD_TYPE) + set (COTIRE_BUILD_TYPE "None") + endif() + string (TOUPPER "${COTIRE_BUILD_TYPE}" _upperConfig) + set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}}) + set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}}) + set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}}) + # check if target has been cotired for actual build type COTIRE_BUILD_TYPE + list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) + if (_index GREATER -1) set (_sources ${COTIRE_TARGET_SOURCES}) - set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS}) + set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) + else() + if (COTIRE_DEBUG) + message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") + endif() + set (_sources "") + set (_sourcesDefinitions "") endif() set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) set (_targetPostUndefs ${COTIRE_TARGET_POST_UNDEFS}) set (_sourcesPreUndefs ${COTIRE_TARGET_SOURCES_PRE_UNDEFS}) set (_sourcesPostUndefs ${COTIRE_TARGET_SOURCES_POST_UNDEFS}) - if (${COTIRE_ARGV1} STREQUAL "unity") + if ("${COTIRE_ARGV1}" STREQUAL "unity") cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) cotire_generate_unity_source( @@ -2340,7 +2341,7 @@ if (CMAKE_SCRIPT_MODE_FILE) SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} SOURCES_POST_UNDEFS ${_sourcesPostUndefs}) - elseif (${COTIRE_ARGV1} STREQUAL "prefix") + elseif ("${COTIRE_ARGV1}" STREQUAL "prefix") set (_files "") foreach (_index RANGE 4 ${COTIRE_ARGC}) @@ -2364,7 +2365,7 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) - elseif (${COTIRE_ARGV1} STREQUAL "precompile") + elseif ("${COTIRE_ARGV1}" STREQUAL "precompile") set (_files "") foreach (_index RANGE 5 ${COTIRE_ARGC}) @@ -2384,7 +2385,7 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) - elseif (${COTIRE_ARGV1} STREQUAL "combine") + elseif ("${COTIRE_ARGV1}" STREQUAL "combine") set (_files "") foreach (_index RANGE 2 ${COTIRE_ARGC}) @@ -2394,12 +2395,12 @@ if (CMAKE_SCRIPT_MODE_FILE) endforeach() cotire_generate_unity_source(${_files}) - elseif (${COTIRE_ARGV1} STREQUAL "cleanup") + elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup") cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}") else() - message (FATAL_ERROR "Unknown command ${COTIRE_ARGV1}.") + message (FATAL_ERROR "Unknown cotire command \"${COTIRE_ARGV1}\".") endif() else() diff --git a/HISTORY.md b/HISTORY.md index ba7d2a4..12f8fe2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.1.0 (2012-04-19) + +* tested with CMake 2.8.8. +* added example to manual that shows how to apply cotire to CMake object library targets. +* fixed multiple bugs with handling of CMake single build type and multiple configuration builds. +* added more robust parsing of localized MSVC `/showIncludes` output. + ## 1.0.9 (2012-04-09) * add support for compiler wrappers like ccache. diff --git a/MANUAL.md b/MANUAL.md index 9e479d5..9e9192e 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -269,7 +269,7 @@ directories. A target inherits the property value from its enclosing directory. ### disabling precompiled headers for small targets The cache variable `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` can be set to the minimum number of -source files required to enable the use of precompiled header. It defaults to 3. +source files required to enable the use of a precompiled header. It defaults to 3. ### configuring the generation of the prefix header @@ -382,6 +382,27 @@ enabled in the following way upon configuring the project: $ export CXX="/usr/local/bin/ccache /usr/bin/g++" $ cmake .. +### applying cotire to object library targets + +CMake 2.8.8 introduced a new type of library target called [object library][objlib]. An object +library is a convenience target that compiles multiple source files but does not create a linked +target library for them, e.g.: + + add_library(myLib OBJECT lib1.cpp lib2.cpp lib3.cpp) + add_executable(exeA $ mainA.cpp) + add_executable(exeB $ mainB.cpp) + +The `cotire` function can be applied to an object library target in a familiar fashion: + + add_library(myLib OBJECT lib1.cpp lib2.cpp lib3.cpp) + cotire(myLib) + # use unity object library for executables + add_executable(exeA $ mainA.cpp) + add_executable(exeB $ mainB.cpp) + +Because object library targets do not support `PRE_BUILD` actions, precompiled header usage cannot +be enabled for them for Xcode projects generated with CMake. Unity builds work as expected, though. + cotire usage restrictions ------------------------- @@ -415,4 +436,5 @@ To get a workable build system, set the `COTIRE_EXCLUDED` property on .m and .mm [EoUB]:http://leewinder.co.uk/blog/?p=394 [pch]:http://en.wikipedia.org/wiki/Precompiled_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit +[objlib]:http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library [pfh]:http://en.wikipedia.org/wiki/Prefix_header From 94dc7ae8c3c83cd196dbf770447370680da245d1 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 20 Apr 2012 22:03:53 +0200 Subject: [PATCH 019/169] cotire 1.1.1 --- CMake/cotire.cmake | 8 ++++---- HISTORY.md | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 8525526..e8eadc8 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -37,7 +37,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.6) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.1") include(CMakeParseArguments) @@ -726,8 +726,8 @@ macro (cotire_parse_line _line _headerFileVar _headerDepthVar) # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" - # We use a very general regular expression, relying on the presence of the : character - if ("${_line}" MATCHES "( +)([^:]+:[^:]+)$") + # We use a very general regular expression, relying on the presence of the : characters + if ("${_line}" MATCHES ":( +)([^:]+:[^:]+)$") # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) @@ -1974,7 +1974,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) # determine unity target sub type get_target_property(_targetType ${_target} TYPE) if ("${_targetType}" STREQUAL "EXECUTABLE") - get_target_property(_isWin32 ${_target} WIN32) + get_target_property(_isWin32 ${_target} WIN32_EXECUTABLE) get_target_property(_isMacOSX_Bundle ${_target} MACOSX_BUNDLE) if (_isWin32) set (_unityTargetSubType WIN32) diff --git a/HISTORY.md b/HISTORY.md index 12f8fe2..0ad5039 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.1.1 (2012-04-20) + +* fixed bug with generation of unity targets for `WIN32_EXECUTABLE` targets. +* fixed bug with parsing of localized MSVC `/showIncludes` output. + ## 1.1.0 (2012-04-19) * tested with CMake 2.8.8. From 1f92f153a6ca152cfea5e982f0b6521d157e891d Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 May 2012 22:03:56 +0200 Subject: [PATCH 020/169] cotire 1.1.2 --- CMake/cotire.cmake | 18 ++++++++++-------- HISTORY.md | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e8eadc8..3cd4c05 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -37,7 +37,7 @@ set(__COTIRE_INCLUDED TRUE) cmake_minimum_required(VERSION 2.8.6) set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.2") include(CMakeParseArguments) @@ -93,13 +93,15 @@ endfunction() macro (cotire_check_is_path_relative_to _path _isRelativeVar) set (${_isRelativeVar} FALSE) - foreach (_dir ${ARGN}) - file (RELATIVE_PATH _relPath "${_dir}" "${_path}") - if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")) - set (${_isRelativeVar} TRUE) - break() - endif() - endforeach() + if (IS_ABSOLUTE "${_path}") + foreach (_dir ${ARGN}) + file (RELATIVE_PATH _relPath "${_dir}" "${_path}") + if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")) + set (${_isRelativeVar} TRUE) + break() + endif() + endforeach() + endif() endmacro() function (cotire_filter_language_source_files _language _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) diff --git a/HISTORY.md b/HISTORY.md index 0ad5039..603d7f1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.1.2 (2012-05-06) + +* make handling of include directories more robust agains invalid paths. + ## 1.1.1 (2012-04-20) * fixed bug with generation of unity targets for `WIN32_EXECUTABLE` targets. From 5d14a50ae77eba9c66d3f006177fd38810b1def0 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 23 May 2012 19:54:58 +0200 Subject: [PATCH 021/169] new patches related to llvm-3.1 --- HISTORY.md | 2 +- Patches/clang-3.1.src.patch | 35 +++++++++++++++++++ Patches/llvm-3.1.src.patch | 69 +++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Patches/clang-3.1.src.patch create mode 100644 Patches/llvm-3.1.src.patch diff --git a/HISTORY.md b/HISTORY.md index 603d7f1..2510da0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,6 @@ ## 1.1.2 (2012-05-06) -* make handling of include directories more robust agains invalid paths. +* make handling of include directories more robust against invalid paths. ## 1.1.1 (2012-04-20) diff --git a/Patches/clang-3.1.src.patch b/Patches/clang-3.1.src.patch new file mode 100644 index 0000000..55ab88b --- /dev/null +++ b/Patches/clang-3.1.src.patch @@ -0,0 +1,35 @@ +diff -rupN clang-3.1.src/CMakeLists.txt clang-3.1.src.cotire/CMakeLists.txt +--- clang-3.1.src/CMakeLists.txt 2012-04-16 06:16:43.000000000 +0200 ++++ clang-3.1.src.cotire/CMakeLists.txt 2012-05-23 19:34:06.000000000 +0200 +@@ -36,6 +36,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + include(TableGen) + include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") + include(HandleLLVMOptions) ++ include(cotire) + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + +@@ -211,6 +212,11 @@ macro(add_clang_library name) + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} + RUNTIME DESTINATION bin) + set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") ++ if (COMMAND cotire) ++ if (NOT "${name}" MATCHES "libclang") ++ cotire(${name}) ++ endif() ++ endif() + endmacro(add_clang_library) + + macro(add_clang_executable name) +diff -rupN clang-3.1.src/tools/libclang/CMakeLists.txt clang-3.1.src.cotire/tools/libclang/CMakeLists.txt +--- clang-3.1.src/tools/libclang/CMakeLists.txt 2012-04-13 19:26:32.000000000 +0200 ++++ clang-3.1.src.cotire/tools/libclang/CMakeLists.txt 2012-05-23 19:34:06.000000000 +0200 +@@ -88,3 +88,8 @@ if( NOT BUILD_SHARED_LIBS AND NOT WIN32 + PROPERTIES + OUTPUT_NAME "libclang") + endif() ++ ++if (COMMAND cotire) ++ cotire(libclang) ++ cotire(${LIBCLANG_STATIC_TARGET_NAME}) ++endif() diff --git a/Patches/llvm-3.1.src.patch b/Patches/llvm-3.1.src.patch new file mode 100644 index 0000000..4a0a9c6 --- /dev/null +++ b/Patches/llvm-3.1.src.patch @@ -0,0 +1,69 @@ +diff -rupN llvm-3.1.src/CMakeLists.txt llvm-3.1.src.cotire/CMakeLists.txt +--- llvm-3.1.src/CMakeLists.txt 2012-05-16 00:06:08.000000000 +0200 ++++ llvm-3.1.src.cotire/CMakeLists.txt 2012-05-23 19:49:12.000000000 +0200 +@@ -18,6 +18,7 @@ set(PACKAGE_VERSION "${LLVM_VERSION_MAJO + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + + include(VersionFromVCS) ++include(cotire) + + option(LLVM_APPEND_VC_REV + "Append the version control system revision id to LLVM version" OFF) +diff -rupN llvm-3.1.src/cmake/modules/AddLLVM.cmake llvm-3.1.src.cotire/cmake/modules/AddLLVM.cmake +--- llvm-3.1.src/cmake/modules/AddLLVM.cmake 2011-11-29 20:25:30.000000000 +0100 ++++ llvm-3.1.src.cotire/cmake/modules/AddLLVM.cmake 2012-05-23 19:49:59.000000000 +0200 +@@ -25,6 +25,9 @@ macro(add_llvm_library name) + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Libraries") ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + + # Add the explicit dependency information for this library. + # +@@ -68,6 +71,9 @@ ${name} ignored.") + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") +@@ -88,6 +94,9 @@ macro(add_llvm_executable name) + add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) + endif( LLVM_COMMON_DEPENDS ) + link_system_libs( ${name} ) ++ if (COMMAND cotire) ++ cotire(${name}) ++ endif() + endmacro(add_llvm_executable name) + + +diff -rupN llvm-3.1.src/lib/Analysis/CMakeLists.txt llvm-3.1.src.cotire/lib/Analysis/CMakeLists.txt +--- llvm-3.1.src/lib/Analysis/CMakeLists.txt 2012-03-16 06:51:52.000000000 +0100 ++++ llvm-3.1.src.cotire/lib/Analysis/CMakeLists.txt 2012-05-23 19:49:12.000000000 +0200 +@@ -1,3 +1,7 @@ ++if (COMMAND cotire) ++ set_source_files_properties (ConstantFolding.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMAnalysis + AliasAnalysis.cpp + AliasAnalysisCounter.cpp +diff -rupN llvm-3.1.src/lib/Support/CMakeLists.txt llvm-3.1.src.cotire/lib/Support/CMakeLists.txt +--- llvm-3.1.src/lib/Support/CMakeLists.txt 2012-04-17 22:03:03.000000000 +0200 ++++ llvm-3.1.src.cotire/lib/Support/CMakeLists.txt 2012-05-23 19:49:12.000000000 +0200 +@@ -4,6 +4,10 @@ if( MINGW ) + set(LLVM_REQUIRES_EH 1) + endif() + ++if (COMMAND cotire) ++ set_source_files_properties (IsInf.cpp IsNAN.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMSupport + APFloat.cpp + APInt.cpp From 7691926a708bceea5ae8dd8eac54df63be92d34c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 12 Aug 2012 14:58:13 +0200 Subject: [PATCH 022/169] cotire 1.1.3 --- .gitignore | 1 + CMake/cotire.cmake | 66 +++++++++++++++++++++++++++++++++++++--------- HISTORY.md | 7 +++++ 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index b33cb3a..7f6efa0 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # ignore CMake build directories build*/ .DS_Store +.project diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3cd4c05..3ce94ac 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -32,12 +32,19 @@ if(__COTIRE_INCLUDED) endif() set(__COTIRE_INCLUDED TRUE) +# call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(PUSH) +endif() # we need the CMake variables CMAKE_SCRIPT_MODE_FILE and CMAKE_ARGV available since 2.8.5 # we need APPEND_STRING option for set_property available since 2.8.6 cmake_minimum_required(VERSION 2.8.6) +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(POP) +endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.3") include(CMakeParseArguments) @@ -133,8 +140,13 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude if (_sourceExt) list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex) - if (_sourceIndex GREATER -1 AND _ignoreIndex LESS 0) - set (_sourceIsFiltered TRUE) + if (_ignoreIndex LESS 0) + if (_sourceIndex GREATER -1) + set (_sourceIsFiltered TRUE) + elseif ("${_sourceLanguage}" STREQUAL "${_language}") + # add to excluded sources, if file is not ignored and has correct language without having the correct extension + list (APPEND _excludedSourceFiles "${_sourceFile}") + endif() endif() endif() endif() @@ -296,13 +308,37 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (_target) # add option from CMake target type variable get_target_property(_targetType ${_target} TYPE) - if (_targetType STREQUAL "MODULE_LIBRARY") - # flags variable for module library uses different name SHARED_MODULE - # (e.g., CMAKE_SHARED_MODULE_C_FLAGS) - set (_targetType SHARED_MODULE) + if (CMAKE_VERSION VERSION_LESS "2.8.9") + set (_PIC_Policy "OLD") + else() + # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on + cmake_policy(GET CMP0018 _PIC_Policy) endif() - if (CMAKE_${_targetType}_${_language}_FLAGS) - set (_compileFlags "${_compileFlags} ${CMAKE_${_targetType}_${_language}_FLAGS}") + if (COTIRE_DEBUG) + message(STATUS "CMP0018=${_PIC_Policy}, CMAKE_POLICY_DEFAULT_CMP0018=${CMAKE_POLICY_DEFAULT_CMP0018}") + endif() + if (_PIC_Policy STREQUAL "NEW") + # NEW behavior: honor the POSITION_INDEPENDENT_CODE target property + get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) + if (_targetPIC) + if (_targetType STREQUAL "EXECUTABLE") + if (CMAKE_${_targetType}_${_language}_FLAGS) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") + else() + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") + endif() + endif() + endif() + else() + # OLD behavior or policy not set: use the value of CMAKE_SHARED_LIBRARY__FLAGS + if (_targetType STREQUAL "MODULE_LIBRARY") + # flags variable for module library uses different name SHARED_MODULE + # (e.g., CMAKE_SHARED_MODULE_C_FLAGS) + set (_targetType SHARED_MODULE) + endif() + if (CMAKE_${_targetType}_${_language}_FLAGS) + set (_compileFlags "${_compileFlags} ${CMAKE_${_targetType}_${_language}_FLAGS}") + endif() endif() endif() if (_directory) @@ -377,7 +413,12 @@ function (cotire_get_target_include_directories _config _language _directory _ta if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE) cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") if (_isRelative) - list (INSERT _includeDirs _projectInsertIndex "${_dir}") + list (LENGTH _includeDirs _len) + if (_len EQUAL _projectInsertIndex) + list (APPEND _includeDirs "${_dir}") + else() + list (INSERT _includeDirs _projectInsertIndex "${_dir}") + endif() math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1") else() list (APPEND _includeDirs "${_dir}") @@ -2078,7 +2119,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ COMPILE_FLAGS Fortran_FORMAT INCLUDE_DIRECTORIES - INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_) + INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_ + POSITION_INDEPENDENT_CODE) # copy link stuff cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH @@ -2088,7 +2130,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ - SOVERSION VERSION) + NO_SONAME SOVERSION VERSION) # copy Qt stuff cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} AUTOMOC AUTOMOC_MOC_OPTIONS) diff --git a/HISTORY.md b/HISTORY.md index 2510da0..c710d47 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.1.3 (2012-08-12) + +* fix out of range index operation upon building list of target include directories. +* honor target properties `POSITION_INDEPENDENT_CODE` and `NO_SONAME` introduced with CMake 2.8.9. +* make selection of target source files for requested target language more careful. +* prevent modification of the CMake policy stack upon CMake version check. + ## 1.1.2 (2012-05-06) * make handling of include directories more robust against invalid paths. From 95e10831a4ebe20fa71d7e70aa156e0195844d32 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 15 Aug 2012 19:54:06 +0200 Subject: [PATCH 023/169] cotire 1.1.4 --- CMake/cotire.cmake | 24 ++++++++++++++++-------- HISTORY.md | 5 +++++ README.md | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3ce94ac..616ac60 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.3") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.4") include(CMakeParseArguments) @@ -1680,15 +1680,23 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript foreach (_unityFile ${_unityFiles}) file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) + # set up compiled unity source dependencies + # this ensures that missing source files are generated before the unity file is compiled + if (COTIRE_DEBUG) + message (STATUS "${_unityCmd} OBJECT_DEPENDS ${_dependencySources}") + endif() + if (_dependencySources) + set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) + endif() cotire_set_cmd_to_prologue(_unityCmd) list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetScript}" "${_unityFile}") if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript} ${_dependencySources}") + message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript}") endif() add_custom_command( OUTPUT "${_unityFile}" COMMAND ${_unityCmd} - DEPENDS "${_targetScript}" ${_dependencySources} + DEPENDS "${_targetScript}" COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) @@ -2331,15 +2339,15 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() endforeach() - if (COTIRE_DEBUG) - message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") - endif() - # include target script if available if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$") include("${COTIRE_ARGV2}") endif() + if (COTIRE_DEBUG) + message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") + endif() + if (WIN32) # for MSVC, compiler IDs may not always be set correctly if (MSVC) @@ -2378,7 +2386,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_generate_unity_source( "${COTIRE_ARGV3}" ${_sources} LANGUAGE "${COTIRE_TARGET_LANGUAGE}" - DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" ${COTIRE_TARGET_UNITY_DEPENDS} + DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} PRE_UNDEFS ${_targetPreUndefs} POST_UNDEFS ${_targetPostUndefs} diff --git a/HISTORY.md b/HISTORY.md index c710d47..a3b07d9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.1.4 (2012-08-15) + +* prevent redundant re-generation of the unity source, prefix header and precompiled header files + (this makes cotire more applicable to C++ projects that use Qt). + ## 1.1.3 (2012-08-12) * fix out of range index operation upon building list of target include directories. diff --git a/README.md b/README.md index b795801..ce4557e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ features * Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). * Compatible with CMake's [cross-compiling][ccrc] support. * Compatible with compiler wrappers like [ccache][ccch]. +* Applicable to CMake based Qt projects. * Tested with Windows, Linux and OS X. * MIT licensed. From 0787b381e3a1f795ebdc62b5b51851264d612f75 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 17 Aug 2012 09:12:47 +0200 Subject: [PATCH 024/169] cotire 1.1.5 --- CMake/cotire.cmake | 46 ++++++++++++++++++++++++++++++++++++---------- HISTORY.md | 8 +++++++- MANUAL.md | 8 ++++++-- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 616ac60..2936fee 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.4") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.5") include(CMakeParseArguments) @@ -125,9 +125,15 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude else() set (_ignoreExtensions "") endif() + if (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS) + set (_excludeExtensions "${COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS}") + else() + set (_excludeExtensions "") + endif() if (COTIRE_DEBUG) message (STATUS "${_language} source file extensions: ${_languageExtensions}") message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") + message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") endif() foreach (_sourceFile ${ARGN}) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) @@ -138,14 +144,19 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic) cotire_get_source_file_extension("${_sourceFile}" _sourceExt) if (_sourceExt) - list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex) if (_ignoreIndex LESS 0) - if (_sourceIndex GREATER -1) - set (_sourceIsFiltered TRUE) - elseif ("${_sourceLanguage}" STREQUAL "${_language}") - # add to excluded sources, if file is not ignored and has correct language without having the correct extension + list (FIND _excludeExtensions "${_sourceExt}" _excludeIndex) + if (_excludeIndex GREATER -1) list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) + if (_sourceIndex GREATER -1) + set (_sourceIsFiltered TRUE) + elseif ("${_sourceLanguage}" STREQUAL "${_language}") + # add to excluded sources, if file is not ignored and has correct language without having the correct extension + list (APPEND _excludedSourceFiles "${_sourceFile}") + endif() endif() endif() endif() @@ -1309,11 +1320,13 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (${_msgVar} "Unsupported ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}." PARENT_SCOPE) endif() if (APPLE) - # PCH compilation not supported by GCC / Clang when multiple build architectures (e.g., i386, x86_64) are selected + # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) if (CMAKE_CONFIGURATION_TYPES) set (_configs ${CMAKE_CONFIGURATION_TYPES}) - else() + elseif (CMAKE_BUILD_TYPE) set (_configs ${CMAKE_BUILD_TYPE}) + else() + set (_configs "None") endif() foreach (_config ${_configs}) cotire_get_target_compile_flags("${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" _targetFlags) @@ -1322,7 +1335,7 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) if (_numberOfArchitectures GREATER 1) string (REPLACE ";" ", " _architectureStr "${_architectures}") set (${_msgVar} - "Precompiled headers not supported on Darwin for multiple architecture builds (${_architectureStr})." + "Precompiled headers not supported on Darwin for multi-architecture builds (${_architectureStr})." PARENT_SCOPE) break() endif() @@ -2487,6 +2500,9 @@ else() set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "" CACHE STRING "Ignore headers from these directories when generating the prefix header.") + set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING + "Ignore sources with the listed file extensions from the generated unity source.") + set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING "Minimum number of sources in target required to enable use of precompiled header.") @@ -2545,7 +2561,7 @@ else() define_property( CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS" - BRIEF_DOCS "Ignore includes with the listed file extensions from the prefix header when generating the prefix header." + BRIEF_DOCS "Ignore includes with the listed file extensions from the generated prefix header." FULL_DOCS "The variable can be set to a semicolon separated list of file extensions." "If a header file extension matches one in the list, it will be excluded from the generated prefix header." @@ -2553,6 +2569,16 @@ else() "If not defined, defaults to inc;inl;ipp." ) + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS" + BRIEF_DOCS "Exclude sources with the listed file extensions from the generated unity source." + FULL_DOCS + "The variable can be set to a semicolon separated list of file extensions." + "If a source file extension matches one in the list, it will be excluded from the generated unity source file." + "Source files with an extension in CMAKE__IGNORE_EXTENSIONS are always excluded." + "If not defined, defaults to m;mm." + ) + define_property( CACHED_VARIABLE PROPERTY "COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES" BRIEF_DOCS "Minimum number of sources in target required to enable use of precompiled header." diff --git a/HISTORY.md b/HISTORY.md index a3b07d9..bf78bd4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.1.5 (2012-08-17) + + * new cache variable `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS` can be set to globally exclude + sources with the listed file extensions from the generated unity source. + * fix check for multi-architecture builds under OS X. + ## 1.1.4 (2012-08-15) * prevent redundant re-generation of the unity source, prefix header and precompiled header files @@ -29,7 +35,7 @@ ## 1.0.9 (2012-04-09) * add support for compiler wrappers like ccache. -* under Mac OS X, apply `CMAKE_OSX_SYSROOT` to prefix header include and ignore paths. +* under OS X, apply `CMAKE_OSX_SYSROOT` to prefix header include and ignore paths. ## 1.0.8 (2012-04-05) diff --git a/MANUAL.md b/MANUAL.md index 9e9192e..2620a18 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -325,6 +325,9 @@ Problematic source files should be moved towards the end. will not be included in the unity source file and will be compiled separately when the unity build is performed. +* `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS` can be used to exclude source files by file extension +from inclusion in the generated unity source. It defaults to the CMake list `m;mm`. + * If the unity source file is too large and the compilation process runs into a compiler limit, the target property `COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES` can be set. If the target contains more than that number of source files, cotire will create multiple unity source files @@ -422,8 +425,9 @@ multi-architecture build (e.g., using option `-DCMAKE_OSX_ARCHITECTURES=i386;x86 ### Objective-C -CMake targets that contain Objective-C or Objective-C++ source files cannot be cotired. -To get a workable build system, set the `COTIRE_EXCLUDED` property on .m and .mm source files. +CMake targets that contain Objective-C or Objective-C++ source files cannot be cotired. Source +files ending with .m and .mm are excluded by default through the initial default setting of +`COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS`. [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ From 1b680fe697d741dbd46eb59eee6f2f09e3dde040 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 22 Sep 2012 16:26:47 +0200 Subject: [PATCH 025/169] cotire 1.1.6 --- CMake/cotire.cmake | 11 +++++++++-- HISTORY.md | 6 ++++++ MANUAL.md | 26 +++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 2936fee..6260bbe 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.6") include(CMakeParseArguments) @@ -943,7 +943,11 @@ function (cotire_scan_includes _includesVar) # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() - execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_QUIET ERROR_VARIABLE _output) + execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE _result OUTPUT_QUIET ERROR_VARIABLE _output) + if (_result) + message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.") + endif() cotire_parse_includes( "${_option_LANGUAGE}" "${_output}" "${_option_IGNORE_PATH}" "${_option_INCLUDE_PATH}" @@ -2030,6 +2034,9 @@ function (cotire_setup_pch_target _languages _configurations _target) cotire_init_target("${_pchTargetName}") cotire_add_to_pch_all_target(${_pchTargetName}) endif() + else() + # for other generators, we add the "clean all" target to clean up the precompiled header + cotire_setup_clean_all_target() endif() endfunction() diff --git a/HISTORY.md b/HISTORY.md index bf78bd4..c2e9dda 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.1.6 (2012-09-22) + +* check result code upon scanning includes. +* always add a `clean_cotire` target to easily clean up cotire generated files. +* add section on `extern "C"` linkage issues to manual. + ## 1.1.5 (2012-08-17) * new cache variable `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS` can be set to globally exclude diff --git a/MANUAL.md b/MANUAL.md index 2620a18..ed2ad35 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -296,7 +296,7 @@ ignore other project related headers in `CMAKE_SOURCE_DIR`: The properties `COTIRE_PREFIX_HEADER_IGNORE_PATH` and `COTIRE_PREFIX_HEADER_INCLUDE_PATH` can also be set on directories. -The following cache variables also affect the selection of prefix headers. +The following cache variables also affect the selection of prefix headers: * Directory paths in `COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH` will be added to the list of ignored directories when the prefix header file is created. @@ -312,6 +312,30 @@ precompiled header and would result in a rebuild of the whole target. To make th creation dependent on changes to certain target source files, the source file property `COTIRE_DEPENDENCY` can be set to `TRUE` for those files. +### fixing linkage issues + +When a C++ program uses `extern "C"` on a system header file, cotire will not be able to detect +that the include file needs C linkage and will include the file with C++ linkage in the generated +prefix header instead. For example, the C interface to BLAS `cblas.h` usually has to be included +as `extern "C"` in a C++ program: + + extern "C" { + #include + } + +The presence of `extern "C"` includes will prevent cotired targets from being linked successfully +because of unresolved function references using the wrong linkage. To work around the problem, +the property `COTIRE_PREFIX_HEADER_IGNORE_PATH` can be set to a list including the full path of +the `extern "C"` header file. Here's an example: + + set_property(DIRECTORY + PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH + "${ATLAS_INCLUDE_DIR}/cblas.h" + "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") + +That way `cblas.h` will not be included in the generated prefix header and will not cause problems +upon linking. + ### configuring the generation of the unity source By default cotire adds all target source file to the generated unity source. In most cases a From ed340018627fd912c31bb8d416b7b06fe20bce89 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 26 Oct 2012 09:50:26 +0200 Subject: [PATCH 026/169] cotire 1.1.7 --- CMake/cotire.cmake | 6 +++++- HISTORY.md | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 6260bbe..bb9feab 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.6") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.7") include(CMakeParseArguments) @@ -810,7 +810,11 @@ function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honore # prevent CMake macro invocation errors due to backslash characters in Windows paths string (REPLACE "\\" "/" _scanOutput "${_scanOutput}") endif() + # canonize slashes + string (REPLACE "//" "/" _scanOutput "${_scanOutput}") + # prevent semicolon from being interpreted as a line separator string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}") + # then separate lines string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}") list (LENGTH _scanOutput _len) # remove duplicate lines to speed up parsing diff --git a/HISTORY.md b/HISTORY.md index c2e9dda..5eb9a03 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.1.7 (2012-10-26) + +* cope with double slash characters in scanned include paths. + ## 1.1.6 (2012-09-22) * check result code upon scanning includes. From 938d8dd90c54650e932d1b1bb7ef26bc9d748df2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 27 Oct 2012 09:47:55 +0200 Subject: [PATCH 027/169] cotire 1.1.8 --- CMake/cotire.cmake | 8 ++++++-- HISTORY.md | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index bb9feab..9e591ee 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.7") +set (COTIRE_CMAKE_MODULE_VERSION "1.1.8") include(CMakeParseArguments) @@ -1709,6 +1709,10 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript if (_dependencySources) set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) endif() + if (MSVC) + # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC + set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS " /bigobj ") + endif() cotire_set_cmd_to_prologue(_unityCmd) list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetScript}" "${_unityFile}") if (COTIRE_DEBUG) @@ -2219,7 +2223,7 @@ function (cotire_target _target) # trivial checks get_target_property(_imported ${_target} IMPORTED) if (_imported) - message (WARNING "Imported target ${_target} cannot be cotired") + message (WARNING "Imported target ${_target} cannot be cotired.") return() endif() # check if target needs to be cotired for build type diff --git a/HISTORY.md b/HISTORY.md index 5eb9a03..5082405 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.1.8 (2012-10-27) + +* when using MSVC, apply option `/bigobj` to compilation of generated unity files. + ## 1.1.7 (2012-10-26) * cope with double slash characters in scanned include paths. From 1c37a8651b5ef848fd3dc038052334f337b3a404 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 1 Nov 2012 13:08:02 +0100 Subject: [PATCH 028/169] cotire 1.2.0 --- .gitattributes | 8 ++ CMake/cotire.cmake | 220 +++++++++++++++++++++++++++++++-------------- HISTORY.md | 19 +++- MANUAL.md | 62 +++++++++++-- README.md | 11 ++- 5 files changed, 242 insertions(+), 78 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d49e736 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +*.sh eol=lf +bootstrap eol=lf +configure eol=lf +*.[1-9] eol=lf + +*.bat eol=crlf +*.cmd eol=crlf +*.vbs eol=crlf diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 9e591ee..f2a3194 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.1.8") +set (COTIRE_CMAKE_MODULE_VERSION "1.2.0") include(CMakeParseArguments) @@ -397,21 +397,21 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() -function (cotire_get_target_include_directories _config _language _directory _target _includeDirsVar) +function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar) set (_includeDirs "") # default include dirs if (CMAKE_INCLUDE_CURRENT_DIR) - list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}") - list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}") + list (APPEND _includeDirs "${_targetBinaryDir}") + list (APPEND _includeDirs "${_targetSourceDir}") endif() # parse additional include directories from target compile flags - cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("I" _dirs _ignore ${_targetFlags}) if (_dirs) list (APPEND _includeDirs ${_dirs}) endif() # target include directories - get_directory_property(_dirs DIRECTORY "${_directory}" INCLUDE_DIRECTORIES) + get_directory_property(_dirs DIRECTORY "${_targetSourceDir}" INCLUDE_DIRECTORIES) if (_target) get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) if (_targetDirs) @@ -1305,7 +1305,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) endif() endfunction() -function (cotire_check_precompiled_header_support _language _target _msgVar) +function (cotire_check_precompiled_header_support _language _targetSourceDir _target _msgVar) if (MSVC) # supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version @@ -1337,7 +1337,7 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (_configs "None") endif() foreach (_config ${_configs}) - cotire_get_target_compile_flags("${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("arch" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) if (_numberOfArchitectures GREATER 1) @@ -1427,11 +1427,11 @@ function (cotire_make_prefix_file_path _language _target _prefixFileVar) endif() endfunction() -function (cotire_make_pch_file_path _language _target _pchFileVar) +function (cotire_make_pch_file_path _language _targetSourceDir _target _pchFileVar) cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) set (${_pchFileVar} "" PARENT_SCOPE) if (_prefixFileBaseName AND _prefixFileName) - cotire_check_precompiled_header_support("${_language}" "${_target}" _msg) + cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _msg) if (NOT _msg) if (XCODE) # For Xcode, we completely hand off the compilation of the prefix header to the IDE @@ -1473,10 +1473,9 @@ function (cotire_select_unity_source_files _unityFile _sourcesVar) endfunction() function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar) - get_target_property(_targetSourceFiles ${_target} SOURCES) set (_dependencySources "") # depend on target's generated source files - cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) if (_generatedSources) # but omit all generated source files that have the COTIRE_EXCLUDED property set to true cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources}) @@ -1499,22 +1498,21 @@ function (cotire_get_unity_source_dependencies _language _target _dependencySour endfunction() function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar) - get_target_property(_targetSourceFiles ${_target} SOURCES) # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") - cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles}) + cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_language} ${_target} prefix header DEPENDS ${_dependencySources}") endif() set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() -function (cotire_generate_target_script _language _configurations _target _targetScriptVar) +function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar) set (COTIRE_TARGET_SOURCES ${ARGN}) get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") - cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS) - cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS) + cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) + cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) # set up variables to be configured set (COTIRE_TARGET_LANGUAGE "${_language}") cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) @@ -1531,11 +1529,11 @@ function (cotire_generate_target_script _language _configurations _target _targe foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) cotire_get_target_include_directories( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}) + "${_config}" "${_language}" "${_targetSourceDir}" "${_targetBinaryDir}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}) cotire_get_target_compile_definitions( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) + "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) cotire_get_target_compiler_flags( - "${_config}" "${_language}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) + "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) cotire_get_source_files_compile_definitions( "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${COTIRE_TARGET_SOURCES}) endforeach() @@ -1557,7 +1555,7 @@ function (cotire_generate_target_script _language _configurations _target _targe set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) endfunction() -function (cotire_setup_pch_file_compilation _language _targetScript _prefixFile _pchFile) +function (cotire_setup_pch_file_compilation _language _targetSourceDir _targetScript _prefixFile _pchFile) set (_sourceFiles ${ARGN}) if (MSVC) # for Visual Studio, we attach the precompiled header compilation to the first source file @@ -1591,7 +1589,7 @@ function (cotire_setup_pch_file_compilation _language _targetScript _prefixFile COMMAND ${_cmds} DEPENDS "${_prefixFile}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) endif() endif() @@ -1646,7 +1644,7 @@ function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (${_propertyValueVar} "" PARENT_SCOPE) endfunction() -function (cotire_setup_target_pch_usage _languages _target _wholeTarget) +function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _wholeTarget) if (MSVC) # for Visual Studio, precompiled header inclusion is always done on the source file level # see cotire_setup_prefix_file_inclusion @@ -1664,7 +1662,7 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) list (LENGTH _prefixFiles _numberOfPrefixFiles) if (_numberOfPrefixFiles GREATER 1) cotire_make_prefix_file_path("" ${_target} _prefixHeader) - cotire_setup_combine_command(${_target} "${_prefixHeader}" "${_prefixFiles}" _cmds) + cotire_setup_combine_command("${_targetSourceDir}" "" "${_prefixHeader}" "${_prefixFiles}" _cmds) else() set (_prefixHeader "${_prefixFiles}") endif() @@ -1673,7 +1671,7 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) endif() add_custom_command(TARGET "${_target}" PRE_BUILD ${_cmds} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Updating target ${_target} prefix headers" VERBATIM) # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") @@ -1695,7 +1693,7 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) endif() endfunction() -function (cotire_setup_unity_generation_commands _language _target _targetScript _unityFiles _cmdsVar) +function (cotire_setup_unity_generation_commands _language _targetSourceDir _target _targetScript _unityFiles _cmdsVar) set (_dependencySources "") cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) foreach (_unityFile ${_unityFiles}) @@ -1703,15 +1701,15 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) # set up compiled unity source dependencies # this ensures that missing source files are generated before the unity file is compiled - if (COTIRE_DEBUG) - message (STATUS "${_unityCmd} OBJECT_DEPENDS ${_dependencySources}") + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}") endif() if (_dependencySources) set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) endif() if (MSVC) # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC - set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS " /bigobj ") + set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetScript}" "${_unityFile}") @@ -1723,19 +1721,19 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript COMMAND ${_unityCmd} DEPENDS "${_targetScript}" COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) + WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) endforeach() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) +function (cotire_setup_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) set (_sourceFiles ${ARGN}) list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_untiy_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) - cotire_setup_combine_command(${_target} "${_unityFile}" "${_unityFiles}" ${_cmdsVar}) + cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" "${_unityFiles}" ${_cmdsVar}) else() set (_unityFile "${_unityFiles}") endif() @@ -1758,19 +1756,32 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_combine_command _target _joinedFile _files _cmdsVar) - file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") - set (_filesRelPaths "") +function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _files _cmdsVar) + set (_filesPaths "") foreach (_file ${_files}) - file (RELATIVE_PATH _fileRelPath "${CMAKE_BINARY_DIR}" "${_file}") - list (APPEND _filesRelPaths "${_fileRelPath}") + if (IS_ABSOLUTE "${_file}") + set (_filePath "${_file}") + else() + get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) + endif() + file (RELATIVE_PATH _fileRelPath "${CMAKE_BINARY_DIR}" "${_filePath}") + if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") + list (APPEND _filesPaths "${_fileRelPath}") + else() + list (APPEND _filesPaths "${_filePath}") + endif() endforeach() cotire_set_cmd_to_prologue(_prefixCmd) - list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine" "${_joinedFile}" ${_filesRelPaths}) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") + if (_targetScript) + list (APPEND _prefixCmd "${_targetScript}") + endif() + list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths}) if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) + file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") add_custom_command( OUTPUT "${_joinedFile}" COMMAND ${_prefixCmd} @@ -1865,7 +1876,7 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) endfunction() -function (cotire_choose_target_languages _target _targetLanguagesVar) +function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar) set (_languages ${ARGN}) set (_allSourceFiles "") set (_allExcludedSourceFiles "") @@ -1885,7 +1896,7 @@ function (cotire_choose_target_languages _target _targetLanguagesVar) return() endif() if (_targetUsePCH AND "${_language}" STREQUAL "C" OR "${_language}" STREQUAL "CXX") - cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) + cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _disableMsg) if (_disableMsg) set (_targetUsePCH FALSE) endif() @@ -1955,7 +1966,7 @@ function (cotire_choose_target_languages _target _targetLanguagesVar) set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) endfunction() -function (cotire_process_target_language _language _configurations _target _wholeTargetVar _cmdsVar) +function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTargetVar _cmdsVar) set (${_cmdsVar} "" PARENT_SCOPE) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_sourceFiles "") @@ -1965,30 +1976,41 @@ function (cotire_process_target_language _language _configurations _target _whol if (NOT _sourceFiles) return() endif() + set (_wholeTarget ${${_wholeTargetVar}}) + set (_cmds "") + # check for user provided unity source file list + get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT) + if (NOT _unitySourceFiles) + set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources}) + endif() + cotire_generate_target_script( + ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript ${_unitySourceFiles}) get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) if (NOT _maxIncludes) set (_maxIncludes 0) endif() - cotire_make_untiy_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_sourceFiles} ${_cotiredSources}) + cotire_make_untiy_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() endif() - set (_wholeTarget ${${_wholeTargetVar}}) - cotire_generate_target_script( - ${_language} "${_configurations}" ${_target} _targetScript ${_sourceFiles}) - set (_cmds "") cotire_setup_unity_generation_commands( - ${_language} ${_target} "${_targetScript}" "${_unityFiles}" _cmds ${_sourceFiles} ${_cotiredSources}) + ${_language} "${_targetSourceDir}" ${_target} "${_targetScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) if (_prefixFile) - cotire_setup_prefix_generation_command( - ${_language} ${_target} "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_sourceFiles} ${_cotiredSources}) + # check for user provided prefix header files + get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) + if (_prefixHeaderFiles) + cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_prefixHeaderFiles}" _cmds) + else() + cotire_setup_prefix_generation_command( + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) - cotire_make_pch_file_path(${_language} ${_target} _pchFile) + cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( - ${_language} "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) if (_excludedSources) set (_wholeTarget FALSE) endif() @@ -2048,8 +2070,11 @@ function (cotire_setup_pch_target _languages _configurations _target) endif() endfunction() -function (cotire_setup_unity_build_target _languages _configurations _target) - set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") +function (cotire_setup_unity_build_target _languages _configurations _targetSourceDir _target) + get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) + if (NOT _unityTargetName) + set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") + endif() # determine unity target sub type get_target_property(_targetType ${_target} TYPE) if ("${_targetType}" STREQUAL "EXECUTABLE") @@ -2083,7 +2108,23 @@ function (cotire_setup_unity_build_target _languages _configurations _target) if (_sourceFiles OR _cotiredSources) list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources}) endif() - # then add unity source file instead + # if cotire is applied to a target which has not been added in the current source dir, + # non-existing files cannot be referenced from the unity build target (this is a CMake restriction) + if (NOT "${_targetSourceDir}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + set (_nonExistingFiles "") + foreach (_file ${_unityTargetSources}) + if (NOT EXISTS "${_file}") + list (APPEND _nonExistingFiles "${_file}") + endif() + endforeach() + if (_nonExistingFiles) + if (COTIRE_VERBOSE) + message (STATUS "removing non-existing ${_nonExistingFiles} from ${_unityTargetName}") + endif() + list (REMOVE_ITEM _unityTargetSources ${_nonExistingFiles}) + endif() + endif() + # add unity source files instead list (APPEND _unityTargetSources ${_unityFiles}) # make unity files use precompiled header if there are multiple unity files list (LENGTH _unityFiles _numberOfUnityFiles) @@ -2092,7 +2133,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) if (_prefixFile AND _pchFile) cotire_setup_pch_file_compilation( - ${_language} "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) + ${_language} "${_targetSourceDir}" "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) cotire_setup_prefix_file_inclusion( ${_language} ${_target} FALSE "${_prefixFile}" "${_pchFile}" ${_unityFiles}) # add the prefix header to unity target sources @@ -2201,13 +2242,19 @@ function (cotire_setup_unity_build_target _languages _configurations _target) cotire_init_target(${_unityTargetName}) cotire_add_to_unity_all_target(${_unityTargetName}) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") -endfunction() +endfunction(cotire_setup_unity_build_target) function (cotire_target _target) set(_options "") - set(_oneValueArgs "") + set(_oneValueArgs SOURCE_DIR BINARY_DIR) set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_SOURCE_DIR) + set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + if (NOT _option_BINARY_DIR) + set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() if (NOT _option_LANGUAGES) get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) endif() @@ -2243,7 +2290,7 @@ function (cotire_target _target) endif() endif() # choose languages that apply to the target - cotire_choose_target_languages("${_target}" _targetLanguages ${_option_LANGUAGES}) + cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages ${_option_LANGUAGES}) if (NOT _targetLanguages) return() endif() @@ -2255,18 +2302,19 @@ function (cotire_target _target) endif() set (_cmds "") foreach (_language ${_targetLanguages}) - cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" ${_target} _wholeTarget _cmd) + cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" + "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} _wholeTarget _cmd) if (_cmd) list (APPEND _cmds ${_cmd}) endif() endforeach() get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) if (_targetAddSCU) - cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" "${_option_SOURCE_DIR}" ${_target}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) - cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds}) + cotire_setup_target_pch_usage("${_targetLanguages}" "${_option_SOURCE_DIR}" ${_target} ${_wholeTarget} ${_cmds}) cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) endif() get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) @@ -2340,13 +2388,20 @@ endfunction() function (cotire) set(_options "") - set(_oneValueArgs "") + set(_oneValueArgs SOURCE_DIR BINARY_DIR) set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_targets ${_option_UNPARSED_ARGUMENTS}) + if (NOT _option_SOURCE_DIR) + set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + if (NOT _option_BINARY_DIR) + set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() foreach (_target ${_targets}) if (TARGET ${_target}) - cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS}) + cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS} + SOURCE_DIR "${_option_SOURCE_DIR}" BINARY_DIR "${_option_BINARY_DIR}") else() message (WARNING "${_target} is not a target") endif() @@ -2467,13 +2522,22 @@ if (CMAKE_SCRIPT_MODE_FILE) elseif ("${COTIRE_ARGV1}" STREQUAL "combine") + if (COTIRE_TARGET_LANGUAGE) + set (_startIndex 3) + else() + set (_startIndex 2) + endif() set (_files "") - foreach (_index RANGE 2 ${COTIRE_ARGC}) + foreach (_index RANGE ${_startIndex} ${COTIRE_ARGC}) if (COTIRE_ARGV${_index}) list (APPEND _files "${COTIRE_ARGV${_index}}") endif() endforeach() - cotire_generate_unity_source(${_files}) + if (COTIRE_TARGET_LANGUAGE) + cotire_generate_unity_source(${_files} LANGUAGE "${COTIRE_TARGET_LANGUAGE}") + else() + cotire_generate_unity_source(${_files}) + endif() elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup") @@ -2761,6 +2825,26 @@ else() "Defaults to empty." ) + define_property( + TARGET PROPERTY "COTIRE__UNITY_SOURCE_INIT" + BRIEF_DOCS "User provided unity source file to be used instead of the automatically generated one." + FULL_DOCS + "If set, cotire will only add the given file(s) to the generated unity source file." + "If not set, cotire will add all the target source files to the generated unity source file." + "The property can be set to a user provided unity source file." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE__PREFIX_HEADER_INIT" + BRIEF_DOCS "User provided prefix header file to be used instead of the automatically generated one." + FULL_DOCS + "If set, cotire will add the given header file(s) to the generated prefix header file." + "If not set, cotire will generate a prefix header by tracking the header files included by the unity source file." + "The property can be set to a user provided prefix header file (e.g., stdafx.h)." + "Defaults to empty." + ) + define_property( TARGET PROPERTY "COTIRE__UNITY_SOURCE" BRIEF_DOCS "Read-only property. The generated unity source file(s)." @@ -2787,9 +2871,11 @@ else() define_property( TARGET PROPERTY "COTIRE_UNITY_TARGET_NAME" - BRIEF_DOCS "Read-only property. The name of the generated unity build target corresponding to this target." + BRIEF_DOCS "The name of the generated unity build target corresponding to this target." FULL_DOCS - "cotire sets this property to the name the generated unity build target for this target." + "This property can be set to the desired name of the unity target that will be created by cotire." + "If not set, the unity target name will be set to this target's name with the suffix _unity appended." + "After this target has been processed by cotire, the property is set to the actual name of the generated unity target." "Defaults to empty string." ) diff --git a/HISTORY.md b/HISTORY.md index 5082405..0bf068f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,16 @@ +## 1.2.0 (2012-11-01) + +* add support for manually maintained prefix header and unity source files. +* the target property `COTIRE__PREFIX_HEADER_INIT` can be set to a user provided prefix + header file to be used instead of the automatically generated one (e.g., `stdafx.h`). +* the new target property `COTIRE__UNITY_SOURCE_INIT` can be set to a user provided unity + source file to be used instead of the automatically generated one. +* the target property `COTIRE_UNITY_TARGET_NAME` is no longer read-only. It can be set to the + desired name of the unity target that will be added by cotire. +* add parameters `SOURCE_DIR` and `BINARY_DIR` to function `cotire` to allow for explicitly + specifying a target's source and binary directory, if target to be cotired has been added in a + different directory. + ## 1.1.8 (2012-10-27) * when using MSVC, apply option `/bigobj` to compilation of generated unity files. @@ -14,9 +27,9 @@ ## 1.1.5 (2012-08-17) - * new cache variable `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS` can be set to globally exclude - sources with the listed file extensions from the generated unity source. - * fix check for multi-architecture builds under OS X. +* new cache variable `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS` can be set to globally exclude + sources with the listed file extensions from the generated unity source. +* fix check for multi-architecture builds under OS X. ## 1.1.4 (2012-08-15) diff --git a/MANUAL.md b/MANUAL.md index ed2ad35..f71bd8c 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -24,9 +24,8 @@ these files automatically. The configuration of precompiled headers usage and single computation unit builds belongs to the build system and not in the source code. Nobody wants to litter one's source files with `hdrstop` -pragmas or be forced to add an include directive to every file. The same source code should build -properly when a precompiled header isn't used and should build faster when a precompiled header -is used. +pragmas or be forced to add an include directive to every file. Source code should build properly +when a precompiled header isn't used and should build faster when a precompiled header is used. #### minimal interface @@ -233,6 +232,19 @@ If a source file's `COMPILE_FLAGS` are modified by cotire, it sets the source fi `COTIRE_TARGET` to the name of the target, that the source file's build command has been altered for. +### changing the name of the generated unity build target + +By default cotire uses the name of the the original target with the suffix `_unity` appended +for the name of the generated unity build target. To create the unity build target under a +different name, set the `COTIRE_UNITY_TARGET_NAME` property: + + add_executable(example_template main.cpp example.cpp log.cpp log.h example.h) + set_target_properties(example_template PROPERTIES COTIRE_UNITY_TARGET_NAME "example") + ... + cotire(example_template) + +Invoking the `example` target will then run the unity build. + ### restricting cotire to certain build configurations To restrict the cotire related modifications to the build process to certain build configurations, @@ -271,6 +283,30 @@ directories. A target inherits the property value from its enclosing directory. The cache variable `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` can be set to the minimum number of source files required to enable the use of a precompiled header. It defaults to 3. +### using a manually maintained prefix header instead of the automatically generated one + +cotire can be configured to use an existing manually maintained prefix header (e.g., Visual Studio +projects often use a prefix header named `stdafx.h`) instead of the automatically generated one. +Set the target property `COTIRE_CXX_PREFIX_HEADER_INIT` to the path of the existing prefix header +file. The path is interpreted relative to the target source directory: + + set_target_properties(example PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h") + cotire(example) + +The property can also be set to a list of header files which will then make up the contents of +the generated prefix header. + +### using a generated prefix header for multiple targets + +A prefix header that is generated for a cotired target can be applied to a different target that +has been added in the same source directory: + + cotire(example) + get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) + ... + set_target_properties(example2 PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${_prefixHeader}") + cotire(example2) + ### configuring the generation of the prefix header There are multiple target properties which affect the generation of the prefix header: @@ -304,7 +340,7 @@ ignored directories when the prefix header file is created. * `COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS` can be used to ignore header files by file extension. It defaults to the CMake list `inc;inl;ipp`. -During development changes to the project source files may affect the list of header files that +During development, changes to the project source files may affect the list of header files that should be selected for inclusion in the prefix header (e.g., a standard include may be added or removed from a target source file). Cotire does not automatically recreate the prefix header, when a target source file is changed, because this would always trigger a re-compilation of the @@ -325,8 +361,8 @@ as `extern "C"` in a C++ program: The presence of `extern "C"` includes will prevent cotired targets from being linked successfully because of unresolved function references using the wrong linkage. To work around the problem, -the property `COTIRE_PREFIX_HEADER_IGNORE_PATH` can be set to a list including the full path of -the `extern "C"` header file. Here's an example: +the property `COTIRE_PREFIX_HEADER_IGNORE_PATH` can also include the full path of header files +besides directories. Here is an example: set_property(DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH @@ -336,6 +372,18 @@ the `extern "C"` header file. Here's an example: That way `cblas.h` will not be included in the generated prefix header and will not cause problems upon linking. +### using a manually maintained unity source instead of the automatically generated one + +cotire can be configured to use an existing manually maintained unity source file instead of the +automatically generated one. Set the target property `COTIRE_CXX_UNITY_SOURCE_INIT` to the path +of the existing unity source file. Its path is interpreted relative to the target source directory: + + set_target_properties(example PROPERTIES COTIRE_CXX_UNITY_SOURCE_INIT "example-all.cpp") + cotire(example) + +The property can also be set to a list of source files which will then make up the contents of +the generated unity source file. + ### configuring the generation of the unity source By default cotire adds all target source file to the generated unity source. In most cases a @@ -390,7 +438,7 @@ This will make cotire add undefs to the generated unity source file. #endif The properties `COTIRE_UNITY_SOURCE_PRE_UNDEFS` and `COTIRE_UNITY_SOURCE_POST_UNDEFS` can also be -set on targets. Cotire will add #undefs for each source file in the unity source then. +set on targets. Cotire will add `#undef` directives for each source file in the unity source then. ### enabling verbose builds diff --git a/README.md b/README.md index ce4557e..c0db837 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,13 @@ features * Automatically generates a single compilation unit (aka unity source file) for a CMake target. * Automatically generates a [prefix header][pfh] by tracking includes used by a CMake target. * Automatically precompiles prefix header and applies resulting precompiled header to a CMake target. +* Alternatively, allows for using manually maintained unity source and prefix header files. * Supports C/C++ compilers Clang, GCC and Visual Studio C++. * Supports mixed language CMake targets. * Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds. * Compatible with CMake single build type and CMake multi-configuration builds. * Compatible with most CMake generators (including [Ninja][ninja]). -* Compatible with parallel builds (make -j, Visual Studio, Xcode). +* Compatible with parallel builds (make -j, [jom][jom], Visual Studio, Xcode). * Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). * Compatible with CMake's [cross-compiling][ccrc] support. * Compatible with compiler wrappers like [ccache][ccch]. @@ -65,6 +66,12 @@ For the generation of the prefix header, cotire will automatically choose header target that are outside of the project directory and thus are likely to change infrequently. The precompiled prefix header is then applied to the target to speed up the compilation process. +To use an existing manually maintained prefix header instead of the automatically generated one, +set the `COTIRE_CXX_PREFIX_HEADER_INIT` property before invoking cotire: + + set_target_properties(MyExecutable PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h") + cotire(MyExecutable) + As a side effect, cotire generates a new target named `MyExecutable_unity`, which lets you perform a unity build for the original target. The unity target inherits all build settings from the original target except for linked libraries and target dependencies. To get a workable unity @@ -105,6 +112,7 @@ limitations * CMake configure time will increase for cotired targets. * The size of the CMake build folder will increase, because precompiled headers are large binaries. * It is not possible to share precompiled headers generated by cotire between CMake targets. + Multiple targets can share a generated prefix header, though (see the [cotire manual][manual]). [ccch]:http://ccache.samba.org/ [ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling @@ -122,3 +130,4 @@ limitations [xcdt]:http://developer.apple.com/tools/xcode/ [PCHH]:http://gcc.gnu.org/wiki/PCHHaters [EoUB]:http://leewinder.co.uk/blog/?p=394 +[jom]:http://qt-project.org/wiki/jom From 4ac39b0d9fbfdf20559c88e2638643a3d09dda5c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 9 Jan 2013 21:43:03 +0100 Subject: [PATCH 029/169] cotire 1.3.0 --- CMake/cotire.cmake | 279 +++++++++++++++++++++++++++++++++------------ HISTORY.md | 7 ++ MANUAL.md | 14 ++- README.md | 12 +- 4 files changed, 235 insertions(+), 77 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index f2a3194..da26ad4 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012 Sascha Kratky +# Copyright 2012-2013 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.2.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.0") include(CMakeParseArguments) @@ -257,8 +257,8 @@ function (cotrie_copy_set_properites _configurations _type _source _target) endforeach() endfunction() -function (cotire_filter_compile_flags _flagFilter _matchedOptionsVar _unmatchedOptionsVar) - if (MSVC) +function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") set (_flagPrefix "[/-]") else() set (_flagPrefix "--?") @@ -406,7 +406,7 @@ function (cotire_get_target_include_directories _config _language _targetSourceD endif() # parse additional include directories from target compile flags cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) - cotire_filter_compile_flags("I" _dirs _ignore ${_targetFlags}) + cotire_filter_compile_flags("I" "${_language}" _dirs _ignore ${_targetFlags}) if (_dirs) list (APPEND _includeDirs ${_dirs}) endif() @@ -504,7 +504,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) - cotire_filter_compile_flags("D" _definitions _ignore ${_targetFlags}) + cotire_filter_compile_flags("D" "${_language}" _definitions _ignore ${_targetFlags}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() @@ -518,7 +518,7 @@ endfunction() function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) # parse target compile flags omitting compile definitions and include directives cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) - cotire_filter_compile_flags("[ID]" _ignore _compilerFlags ${_targetFlags}) + cotire_filter_compile_flags("[ID]" "${_language}" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compileFlags) message (STATUS "Target ${_target} compiler flags ${_compileFlags}") endif() @@ -650,9 +650,9 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) endfunction() -macro (cotire_add_definitions_to_cmd _cmdVar) +macro (cotire_add_definitions_to_cmd _cmdVar _language) foreach (_definition ${ARGN}) - if (MSVC) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") list (APPEND ${_cmdVar} "/D${_definition}") else() list (APPEND ${_cmdVar} "-D${_definition}") @@ -660,9 +660,9 @@ macro (cotire_add_definitions_to_cmd _cmdVar) endforeach() endmacro() -macro (cotire_add_includes_to_cmd _cmdVar) +macro (cotire_add_includes_to_cmd _cmdVar _language) foreach (_include ${ARGN}) - if (MSVC) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) list (APPEND ${_cmdVar} "/I${_include}") else() @@ -921,9 +921,9 @@ function (cotire_scan_includes _includesVar) endif() set (_cmd "${_option_COMPILER_EXECUTABLE}" ${_option_COMPILER_ARG1}) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") - cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) + cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning set (_existingSourceFiles "") @@ -940,7 +940,7 @@ function (cotire_scan_includes _includesVar) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if ("${_option_COMPILER_ID}" STREQUAL "MSVC") + if (_option_COMPILER_ID MATCHES "MSVC") if (COTIRE_DEBUG) message (STATUS "clearing VS_UNICODE_OUTPUT") endif() @@ -1009,7 +1009,7 @@ function (cotire_generate_unity_source _unityFile) set(_oneValueArgs LANGUAGE) set(_multiValueArgs DEPENDS SOURCES_COMPILE_DEFINITIONS - PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS) + PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_unityFileIsUpToDate "${_unityFile}" ${_option_DEPENDS}) @@ -1031,6 +1031,9 @@ function (cotire_generate_unity_source _unityFile) set (_option_SOURCES_POST_UNDEFS "") endif() set (_contents "") + if (_option_PROLOGUE) + list (APPEND _contents ${_option_PROLOGUE}) + endif() if (_option_LANGUAGE AND _sourceFiles) if ("${_option_LANGUAGE}" STREQUAL "CXX") list (APPEND _contents "#ifdef __cplusplus") @@ -1083,6 +1086,9 @@ function (cotire_generate_unity_source _unityFile) if (_option_LANGUAGE AND _sourceFiles) list (APPEND _contents "#endif") endif() + if (_option_EPILOGUE) + list (APPEND _contents ${_option_EPILOGUE}) + endif() list (APPEND _contents "") string (REPLACE ";" "\n" _contents "${_contents}") if (COTIRE_VERBOSE) @@ -1103,6 +1109,11 @@ function (cotire_generate_prefix_header _prefixFile) return() endif() endif() + set (_epilogue "") + if (_option_COMPILER_ID MATCHES "Intel") + # Intel compiler requires hdrstop pragma to stop generating PCH file + set (_epilogue "#pragma hdrstop") + endif() set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) cotire_scan_includes(_selectedHeaders ${_sourceFiles} LANGUAGE "${_option_LANGUAGE}" @@ -1116,7 +1127,7 @@ function (cotire_generate_prefix_header _prefixFile) INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} UNPARSED_LINES _unparsedLines) - cotire_generate_unity_source("${_prefixFile}" LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) + cotire_generate_unity_source("${_prefixFile}" EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) set (_unparsedLinesFile "${_prefixFile}.log") if (_unparsedLines) if (COTIRE_VERBOSE OR NOT _selectedHeaders) @@ -1125,15 +1136,13 @@ function (cotire_generate_prefix_header _prefixFile) message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFileRelPath}") endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") - file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") - else() - file (REMOVE "${_unparsedLinesFile}") endif() + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") endfunction() function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) set (_flags ${${_flagsVar}}) - if ("${_compilerID}" STREQUAL "MSVC") + if (_compilerID MATCHES "MSVC") # cl.exe options used # /nologo suppresses display of sign-on banner # /TC treat all files named on the command line as C source files @@ -1149,7 +1158,7 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags # return as a flag string set (_flags "${_sourceFileType${_language}} /EP /showIncludes") endif() - elseif ("${_compilerID}" STREQUAL "GNU") + elseif (_compilerID MATCHES "GNU") # GCC options used # -H print the name of each header file used # -E invoke preprocessor @@ -1167,7 +1176,7 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags set (_flags "${_flags} -fdirectives-only") endif() endif() - elseif ("${_compilerID}" STREQUAL "Clang") + elseif (_compilerID MATCHES "Clang") # Clang options used # -H print the name of each header file used # -E invoke preprocessor @@ -1178,6 +1187,42 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags # return as a flag string set (_flags "-H -E") endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + # Windows Intel options used + # /nologo do not display compiler version information + # /QH display the include file order + # /EP preprocess to stdout, omitting #line directives + # /TC process all source or unrecognized file types as C source files + # /TP process all source or unrecognized file types as C++ source files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /QH) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP /QH") + endif() + else() + # Linux / Mac OS X Intel options used + # -H print the name of each header file used + # -EP preprocess to stdout, omitting #line directives + # -Kc++ process all source or unrecognized file types as C++ source files + if (_flags) + # append to list + if ("${_language}" STREQUAL "CXX") + list (APPEND _flags -Kc++) + endif() + list (APPEND _flags -H -EP) + else() + # return as a flag string + if ("${_language}" STREQUAL "CXX") + set (_flags "-Kc++ ") + endif() + set (_flags "${_flags}-H -EP") + endif() + endif() else() message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() @@ -1186,7 +1231,7 @@ endfunction() function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersion _prefixFile _pchFile _hostFile _flagsVar) set (_flags ${${_flagsVar}}) - if ("${_compilerID}" STREQUAL "MSVC") + if (_compilerID MATCHES "MSVC") file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) @@ -1207,7 +1252,7 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # return as a flag string set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") endif() - elseif ("${_compilerID}" MATCHES "GNU|Clang") + elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used # -x specify the source language # -c compile but do not link @@ -1221,6 +1266,52 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # return as a flag string set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) + # Windows Intel options used + # /nologo do not display compiler version information + # /Yc create a precompiled header (PCH) file + # /Fp specify a path or file name for precompiled header files + # /FI tells the preprocessor to include a specified file name as the header file + # /TC process all source or unrecognized file types as C source files + # /TP process all source or unrecognized file types as C++ source files + # /Zs syntax check only + # /Qwd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" + "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}" "/Qwd673") + else() + # return as a flag string + set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\" /Qwd673") + endif() + else() + # Linux / Mac OS X Intel options used + # -pch-dir location for precompiled header files + # -pch-create name of the precompiled header (PCH) to create + # -Kc++ process all source or unrecognized file types as C++ source files + # -fsyntax-only check only for correct syntax + # -wd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + get_filename_component(_pchDir "${_pchFile}" PATH) + get_filename_component(_pchName "${_pchFile}" NAME) + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + if (_flags) + # append to list + if ("${_language}" STREQUAL "CXX") + list (APPEND _flags -Kc++) + endif() + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-wd673" "-fsyntax-only" "${_hostFile}") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\" -wd673") + endif() + endif() else() message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() @@ -1229,7 +1320,7 @@ endfunction() function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) set (_flags ${${_flagsVar}}) - if ("${_compilerID}" STREQUAL "MSVC") + if (_compilerID MATCHES "MSVC") file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) # cl.exe options used @@ -1243,7 +1334,7 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # return as a flag string set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") endif() - elseif ("${_compilerID}" STREQUAL "GNU") + elseif (_compilerID MATCHES "GNU") # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used @@ -1254,7 +1345,7 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # return as a flag string set (_flags "-include \"${_prefixFile}\" -Winvalid-pch") endif() - elseif ("${_compilerID}" STREQUAL "Clang") + elseif (_compilerID MATCHES "Clang") # Clang options used # -include process include file as the first line of the primary source file # -Qunused-arguments don't emit warning for unused driver arguments @@ -1265,6 +1356,38 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # return as a flag string set (_flags "-include \"${_prefixFile}\" -Qunused-arguments") endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + # Windows Intel options used + # /Yu use a precompiled header (PCH) file + # /Fp specify a path or file name for precompiled header files + # /FI tells the preprocessor to include a specified file name as the header file + # /Qwd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + if (_flags) + # append to list + list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" "/Qwd673") + else() + # return as a flag string + set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\" /Qwd673") + endif() + else() + # Linux / Mac OS X Intel options used + # -pch-dir location for precompiled header files + # -pch-use name of the precompiled header (PCH) to use + # -include process include file as the first line of the primary source file + # -wd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + get_filename_component(_pchDir "${_pchFile}" PATH) + get_filename_component(_pchName "${_pchFile}" NAME) + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}" "-wd673") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\" -wd673") + endif() + endif() else() message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() @@ -1283,16 +1406,16 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") - cotire_add_definitions_to_cmd(_cmd ${_option_COMPILE_DEFINITIONS}) + cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd ${_option_INCLUDE_DIRECTORIES}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if ("${_option_COMPILER_ID}" STREQUAL "MSVC") + if (_option_COMPILER_ID MATCHES "MSVC") if (COTIRE_DEBUG) message (STATUS "clearing VS_UNICODE_OUTPUT") endif() @@ -1306,24 +1429,33 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) endfunction() function (cotire_check_precompiled_header_support _language _targetSourceDir _target _msgVar) - if (MSVC) + set (_unsupportedCompilerVersionMsg + "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID} version ${COTIRE_${_language}_COMPILER_VERSION}.") + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version set (${_msgVar} "" PARENT_SCOPE) - elseif ("${CMAKE_${_language}_COMPILER_ID}" STREQUAL "GNU") - # GCC PCH support requires GCC >= 3.4 + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") + # GCC PCH support requires version >= 3.4 cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") - set (${_msgVar} - "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID} version ${COTIRE_${_language}_COMPILER_VERSION}." - PARENT_SCOPE) + set (${_msgVar} "${_unsupportedCompilerVersionMsg}" PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() - elseif ("${CMAKE_${_language}_COMPILER_ID}" STREQUAL "Clang") - # Clang has PCH support + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") + # all Clang versions have PCH support set (${_msgVar} "" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") + # Intel PCH support requires version >= 8.0.0 + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND + "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") + set (${_msgVar} "${_unsupportedCompilerVersionMsg}" PARENT_SCOPE) + else() + set (${_msgVar} "" PARENT_SCOPE) + endif() else() set (${_msgVar} "Unsupported ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}." PARENT_SCOPE) endif() @@ -1338,7 +1470,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta endif() foreach (_config ${_configs}) cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) - cotire_filter_compile_flags("arch" _architectures _ignore ${_targetFlags}) + cotire_filter_compile_flags("arch" "${_language}" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) if (_numberOfArchitectures GREATER 1) string (REPLACE ";" ", " _architectureStr "${_architectures}") @@ -1420,7 +1552,7 @@ function (cotire_make_prefix_file_path _language _target _prefixFileVar) if (NOT _language) set (_language "C") endif() - if (MSVC OR "${CMAKE_${_language}_COMPILER_ID}" MATCHES "GNU|Clang") + if (MSVC OR CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel") cotire_get_intermediate_dir(_baseDir) set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE) endif() @@ -1438,12 +1570,15 @@ function (cotire_make_pch_file_path _language _targetSourceDir _target _pchFileV return() endif() cotire_get_intermediate_dir(_baseDir) - if (MSVC) + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # MSVC uses the extension .pch added to the prefix header base name set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE) - elseif ("${CMAKE_${_language}_COMPILER_ID}" MATCHES "GNU|Clang") + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GCC / Clang look for a precompiled header corresponding to the prefix header with the extension .gch appended set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") + # Intel uses the extension .pchi added to the prefix header base name + set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pchi" PARENT_SCOPE) endif() endif() endif() @@ -1555,10 +1690,10 @@ function (cotire_generate_target_script _language _configurations _targetSourceD set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) endfunction() -function (cotire_setup_pch_file_compilation _language _targetSourceDir _targetScript _prefixFile _pchFile) +function (cotire_setup_pch_file_compilation _language _targetBinaryDir _targetScript _prefixFile _pchFile) set (_sourceFiles ${ARGN}) - if (MSVC) - # for Visual Studio, we attach the precompiled header compilation to the first source file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # for Visual Studio and Intel, we attach the precompiled header compilation to the first source file # the remaining files include the precompiled header, see cotire_setup_prefix_file_inclusion if (_sourceFiles) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) @@ -1567,7 +1702,7 @@ function (cotire_setup_pch_file_compilation _language _targetSourceDir _targetSc set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_pch_compilation_flags( - "${_language}" "MSVC" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") @@ -1597,8 +1732,8 @@ endfunction() function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) set (_sourceFiles ${ARGN}) - if (MSVC) - # for Visual Studio, we include the precompiled header in all but the first source file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # for Visual Studio and Intel, we include the precompiled header in all but the first source file # the first source file does the precompiled header compilation, see cotire_setup_pch_file_compilation list (LENGTH _sourceFiles _numberOfSourceFiles) if (_numberOfSourceFiles GREATER 1) @@ -1608,7 +1743,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _pre set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_pch_inclusion_flags( - "${_language}" "MSVC" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # make source files depend on precompiled header @@ -1645,10 +1780,7 @@ function (cotire_get_first_set_property_value _propertyValueVar _type _object) endfunction() function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _wholeTarget) - if (MSVC) - # for Visual Studio, precompiled header inclusion is always done on the source file level - # see cotire_setup_prefix_file_inclusion - elseif (XCODE) + if (XCODE) # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers # if necessary, we also generate a single prefix header which includes all language specific prefix headers set (_prefixFiles "") @@ -1677,18 +1809,22 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") + # for makefile based generator, we force inclusion of the prefix header for all target source files + # if this is a single-language target without any excluded files if (_wholeTarget) - # for makefile based generator, we force inclusion of the prefix header for all target source files - # if this is a single-language target without any excluded files set (_language "${_languages}") - get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) - get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) - set (_flags "") - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - cotire_add_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" - "${_prefixFile}" "${_pchFile}" _flags) - set_property (TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level + # see cotire_setup_prefix_file_inclusion + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + endif() endif() endif() endfunction() @@ -1707,8 +1843,8 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar if (_dependencySources) set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) endif() - if (MSVC) - # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) @@ -1747,7 +1883,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_targetScript} ${_unityFile} ${_dependencySources}") endif() add_custom_command( - OUTPUT "${_prefixFile}" + OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} DEPENDS "${_targetScript}" "${_unityFile}" ${_dependencySources} COMMENT "Generating ${_language} prefix header ${_prefixFileRelPath}" @@ -2010,7 +2146,7 @@ function (cotire_process_target_language _language _configurations _targetSource cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( - ${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} "${_targetBinaryDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) if (_excludedSources) set (_wholeTarget FALSE) endif() @@ -2049,9 +2185,9 @@ function (cotire_setup_pch_target _languages _configurations _target) set (_dependsFiles "") foreach (_language ${_languages}) set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) - if (NOT MSVC) - # Visual Studio only creates precompiled header as a side effect - list(INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # Visual Studio and Intel only create precompiled header as a side effect + list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) endif() cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) if (_dependsFile) @@ -2133,7 +2269,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) if (_prefixFile AND _pchFile) cotire_setup_pch_file_compilation( - ${_language} "${_targetSourceDir}" "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) + ${_language} "${_targetBinaryDir}" "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) cotire_setup_prefix_file_inclusion( ${_language} ${_target} FALSE "${_prefixFile}" "${_pchFile}" ${_unityFiles}) # add the prefix header to unity target sources @@ -2222,6 +2358,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour elseif (WIN32) cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS + PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_KEYWORD VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES) diff --git a/HISTORY.md b/HISTORY.md index 0bf068f..11b47ec 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.3.0 (2013-01-09) + +* add support for Intel C and C++ compilers. +* CMake 2.8.10 compatibility fixes. +* properly clean up generated cotire log files upon invoking `clean` target. +* documentation updates. + ## 1.2.0 (2012-11-01) * add support for manually maintained prefix header and unity source files. diff --git a/MANUAL.md b/MANUAL.md index f71bd8c..f2a5c54 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -193,8 +193,8 @@ build rule and generates the precompiled header as described in the documentatio [GCC][gcc_pch] and [Clang][clang_pch]. Cotire then modifies the `COMPILE_FLAGS` property of the target to force the inclusion of the prefix header. -Visual Studio C++ uses a [different approach][msvc_pch] to pre-compiling. It requires a host -source file to generate the precompiled header as a side effect of producing an object file. +Visual Studio C++ and Intel C++ use a [different approach][msvc_pch] to pre-compiling. Both compilers +require a host source file to generate the precompiled header as a side effect of producing an object file. Cotire modifies the `COMPILE_FLAGS` of the first target source file to [generate][msvc_pch_create] the precompiled header and then modifies the `COMPILE_FLAGS` of the remaining target source files to [include][msvc_pch_use] the generated precompiled header. @@ -296,6 +296,10 @@ file. The path is interpreted relative to the target source directory: The property can also be set to a list of header files which will then make up the contents of the generated prefix header. +If the prefix header `stdafx.h` needs an accompanying source file (e.g., `stdafx.cpp`) in order +to be pre-compiled properly, that source file needs to be the first one on the list of source +files in the target's `add_executable` or `add_library` call. + ### using a generated prefix header for multiple targets A prefix header that is generated for a cotired target can be applied to a different target that @@ -501,6 +505,11 @@ CMake targets that contain Objective-C or Objective-C++ source files cannot be c files ending with .m and .mm are excluded by default through the initial default setting of `COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS`. +### Intel C++ + +Intel C++ support has only been tested with [Intel C++ Composer XE 2013 for Linux][icc_linux] and may +not work with other platforms or versions. + [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders @@ -514,3 +523,4 @@ files ending with .m and .mm are excluded by default through the initial default [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit [objlib]:http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library [pfh]:http://en.wikipedia.org/wiki/Prefix_header +[icc_linux]:http://software.intel.com/en-us/non-commercial-software-development diff --git a/README.md b/README.md index c0db837..af22824 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ features * Automatically generates a [prefix header][pfh] by tracking includes used by a CMake target. * Automatically precompiles prefix header and applies resulting precompiled header to a CMake target. * Alternatively, allows for using manually maintained unity source and prefix header files. -* Supports C/C++ compilers Clang, GCC and Visual Studio C++. +* Supports C/C++ compilers Clang, GCC, Intel and Visual Studio C++. * Supports mixed language CMake targets. * Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds. * Compatible with CMake single build type and CMake multi-configuration builds. @@ -31,7 +31,8 @@ requirements * [CMake 2.8.6][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. -* [GCC][gcc] under Linux. +* [GCC][gcc] under Linux or OS X. +* [Intel C++ compiler][icc] under Windows, Linux or OS X. * [Xcode][xcdt] developer tools package under OS X. This includes [Clang][clang]. installation @@ -106,13 +107,14 @@ modifications, because they [break][EoUB] the use of some C and C++ language fea Generally, modern C++ code which makes heavy use of header-only libraries will profit the most from cotiring. -limitations ------------ +known issues +------------ * CMake configure time will increase for cotired targets. * The size of the CMake build folder will increase, because precompiled headers are large binaries. * It is not possible to share precompiled headers generated by cotire between CMake targets. Multiple targets can share a generated prefix header, though (see the [cotire manual][manual]). +* Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [ccch]:http://ccache.samba.org/ [ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling @@ -131,3 +133,5 @@ limitations [PCHH]:http://gcc.gnu.org/wiki/PCHHaters [EoUB]:http://leewinder.co.uk/blog/?p=394 [jom]:http://qt-project.org/wiki/jom +[intel]:http://software.intel.com/en-us/c-compilers +[XGE]:http://www.incredibuild.com \ No newline at end of file From a1fb0f0f7b2ab77d292b26669cc9d25827a5327f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 29 Jan 2013 20:38:19 +0100 Subject: [PATCH 030/169] cotire 1.3.1 --- CMake/cotire.cmake | 10 +++++----- HISTORY.md | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index da26ad4..38b9a89 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.1") include(CMakeParseArguments) @@ -406,7 +406,7 @@ function (cotire_get_target_include_directories _config _language _targetSourceD endif() # parse additional include directories from target compile flags cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) - cotire_filter_compile_flags("I" "${_language}" _dirs _ignore ${_targetFlags}) + cotire_filter_compile_flags("${_language}" "I" _dirs _ignore ${_targetFlags}) if (_dirs) list (APPEND _includeDirs ${_dirs}) endif() @@ -504,7 +504,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) - cotire_filter_compile_flags("D" "${_language}" _definitions _ignore ${_targetFlags}) + cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() @@ -518,7 +518,7 @@ endfunction() function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) # parse target compile flags omitting compile definitions and include directives cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) - cotire_filter_compile_flags("[ID]" "${_language}" _ignore _compilerFlags ${_targetFlags}) + cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compileFlags) message (STATUS "Target ${_target} compiler flags ${_compileFlags}") endif() @@ -1470,7 +1470,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta endif() foreach (_config ${_configs}) cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) - cotire_filter_compile_flags("arch" "${_language}" _architectures _ignore ${_targetFlags}) + cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) if (_numberOfArchitectures GREATER 1) string (REPLACE ";" ", " _architectureStr "${_architectures}") diff --git a/HISTORY.md b/HISTORY.md index 11b47ec..a281672 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.3.1 (2013-01-29) + +* fix bug with filtering of compile options. + ## 1.3.0 (2013-01-09) * add support for Intel C and C++ compilers. From 6695cc2672a26f297cc118bcae7873abf21b45a6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 31 Jan 2013 16:48:16 +0100 Subject: [PATCH 031/169] fix broken link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af22824..b3620e6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ requirements * [CMake 2.8.6][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. * [GCC][gcc] under Linux or OS X. -* [Intel C++ compiler][icc] under Windows, Linux or OS X. +* [Intel C++ compiler][intel] under Windows, Linux or OS X. * [Xcode][xcdt] developer tools package under OS X. This includes [Clang][clang]. installation From 76fa21838192b063bc67c5b8f368e74e4677aa4f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 2 Feb 2013 09:57:35 +0100 Subject: [PATCH 032/169] cotire 1.3.2 --- CMake/cotire.cmake | 4 ++-- HISTORY.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 38b9a89..96b1098 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,7 +44,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.2") include(CMakeParseArguments) @@ -641,7 +641,7 @@ endmacro() function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) if (NOT _compilerExe) - set (_compilerExe "${CMAKE_${_language}_COMPILER") + set (_compilerExe "${CMAKE_${_language}_COMPILER}") endif() if (NOT _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) diff --git a/HISTORY.md b/HISTORY.md index a281672..2f08781 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.3.2 (2013-02-02) + +* fixed missing curly brace (thanks shaunew). + ## 1.3.1 (2013-01-29) * fix bug with filtering of compile options. From 8a34657a7b47f265f5b51d4266b92e37e07935f3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 3 Feb 2013 15:40:09 +0100 Subject: [PATCH 033/169] cotire 1.3.3 --- CMake/cotire.cmake | 89 +++++++++++++++++++++++++++++++--------------- HISTORY.md | 6 ++++ MANUAL.md | 4 +++ license | 2 +- 4 files changed, 72 insertions(+), 29 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 96b1098..f1eeec5 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -33,6 +33,7 @@ endif() set(__COTIRE_INCLUDED TRUE) # call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode +# cmake_minimum_required also sets the policy version as a side effect, which we have to avoid if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(PUSH) endif() @@ -44,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.3") include(CMakeParseArguments) @@ -319,25 +320,24 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (_target) # add option from CMake target type variable get_target_property(_targetType ${_target} TYPE) - if (CMAKE_VERSION VERSION_LESS "2.8.9") - set (_PIC_Policy "OLD") - else() + if (POLICY CMP0018) # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on cmake_policy(GET CMP0018 _PIC_Policy) + else() + # default to old behavior + set (_PIC_Policy "OLD") endif() if (COTIRE_DEBUG) - message(STATUS "CMP0018=${_PIC_Policy}, CMAKE_POLICY_DEFAULT_CMP0018=${CMAKE_POLICY_DEFAULT_CMP0018}") + message(STATUS "CMP0018=${_PIC_Policy}") endif() if (_PIC_Policy STREQUAL "NEW") # NEW behavior: honor the POSITION_INDEPENDENT_CODE target property get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) if (_targetPIC) - if (_targetType STREQUAL "EXECUTABLE") - if (CMAKE_${_targetType}_${_language}_FLAGS) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") - else() - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") - endif() + if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") + elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") endif() endif() else() @@ -405,6 +405,7 @@ function (cotire_get_target_include_directories _config _language _targetSourceD list (APPEND _includeDirs "${_targetSourceDir}") endif() # parse additional include directories from target compile flags + set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "I" _dirs _ignore ${_targetFlags}) if (_dirs) @@ -503,6 +504,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta endif() # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled + set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) if (_definitions) @@ -517,7 +519,9 @@ endfunction() function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) # parse target compile flags omitting compile definitions and include directives + set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) + set (_compilerFlags "") cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compileFlags) message (STATUS "Target ${_target} compiler flags ${_compileFlags}") @@ -631,6 +635,9 @@ endfunction() macro (cotire_set_cmd_to_prologue _cmdVar) set (${_cmdVar} "${CMAKE_COMMAND}") + if (COTIRE_DEBUG) + list (APPEND ${_cmdVar} "--warn-uninitialized") + endif() list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") if (COTIRE_VERBOSE) list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") @@ -1279,16 +1286,22 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # /TC process all source or unrecognized file types as C source files # /TP process all source or unrecognized file types as C++ source files # /Zs syntax check only - # /Qwd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" - "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}" "/Qwd673") + "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "/Wpch-messages") + endif() else() # return as a flag string - set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\" /Qwd673") + set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} /Wpch-messages") + endif() endif() else() # Linux / Mac OS X Intel options used @@ -1296,7 +1309,7 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # -pch-create name of the precompiled header (PCH) to create # -Kc++ process all source or unrecognized file types as C++ source files # -fsyntax-only check only for correct syntax - # -wd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) get_filename_component(_pchDir "${_pchFile}" PATH) get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") @@ -1306,10 +1319,16 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio if ("${_language}" STREQUAL "CXX") list (APPEND _flags -Kc++) endif() - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-wd673" "-fsyntax-only" "${_hostFile}") + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "-Wpch-messages") + endif() else() # return as a flag string - set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\" -wd673") + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() else() @@ -1364,28 +1383,40 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # /Yu use a precompiled header (PCH) file # /Fp specify a path or file name for precompiled header files # /FI tells the preprocessor to include a specified file name as the header file - # /Qwd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) if (_flags) # append to list - list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" "/Qwd673") + list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "/Wpch-messages") + endif() else() # return as a flag string - set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\" /Qwd673") + set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} /Wpch-messages") + endif() endif() else() # Linux / Mac OS X Intel options used # -pch-dir location for precompiled header files # -pch-use name of the precompiled header (PCH) to use # -include process include file as the first line of the primary source file - # -wd673 disable warning 673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) + # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) get_filename_component(_pchDir "${_pchFile}" PATH) get_filename_component(_pchName "${_pchFile}" NAME) if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}" "-wd673") + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "-Wpch-messages") + endif() else() # return as a flag string - set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\" -wd673") + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() else() @@ -1429,8 +1460,8 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) endfunction() function (cotire_check_precompiled_header_support _language _targetSourceDir _target _msgVar) - set (_unsupportedCompilerVersionMsg - "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID} version ${COTIRE_${_language}_COMPILER_VERSION}.") + set (_unsupportedCompiler + "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version @@ -1440,7 +1471,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") - set (${_msgVar} "${_unsupportedCompilerVersionMsg}" PARENT_SCOPE) + set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() @@ -1452,12 +1483,12 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") - set (${_msgVar} "${_unsupportedCompilerVersionMsg}" PARENT_SCOPE) + set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() else() - set (${_msgVar} "Unsupported ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}." PARENT_SCOPE) + set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() if (APPLE) # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) @@ -1469,6 +1500,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta set (_configs "None") endif() foreach (_config ${_configs}) + set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) @@ -2561,6 +2593,7 @@ if (CMAKE_SCRIPT_MODE_FILE) # include target script if available if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$") + # the included target scripts sets up additional variables relating to the target (e.g., COTIRE_TARGET_SOURCES) include("${COTIRE_ARGV2}") endif() diff --git a/HISTORY.md b/HISTORY.md index 2f08781..49325a8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.3.3 (2013-02-03) + +* fixed bug with handling of policy CMP0018 relating to target property `POSITION_INDEPENDENT_CODE`. +* fixed warnings relating to uninitialized variables. +* Intel XE 2013 Update 2 compatibility fixes. + ## 1.3.2 (2013-02-02) * fixed missing curly brace (thanks shaunew). diff --git a/MANUAL.md b/MANUAL.md index f2a5c54..d522b24 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -510,6 +510,10 @@ files ending with .m and .mm are excluded by default through the initial default Intel C++ support has only been tested with [Intel C++ Composer XE 2013 for Linux][icc_linux] and may not work with other platforms or versions. +The Intel compiler may issue incorrect warnings #672 (the command line options do not match those +used when precompiled header was created) or #673 (the initial sequence of preprocessing directives +is not compatible with those of precompiled header file) upon compilation of cotired targets. + [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders diff --git a/license b/license index 6495439..6c03be0 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012 Sascha Kratky +Copyright (c) 2012-2013 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 1efc6d24a8b1be6d0501cf891649c39a534f5caa Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 7 Feb 2013 17:33:37 +0100 Subject: [PATCH 034/169] cotire 1.3.4 --- CMake/cotire.cmake | 8 ++++---- HISTORY.md | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index f1eeec5..3cc087a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.3") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.4") include(CMakeParseArguments) @@ -523,8 +523,8 @@ function (cotire_get_target_compiler_flags _config _language _directory _target cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) set (_compilerFlags "") cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) - if (COTIRE_DEBUG AND _compileFlags) - message (STATUS "Target ${_target} compiler flags ${_compileFlags}") + if (COTIRE_DEBUG AND _compilerFlags) + message (STATUS "Target ${_target} compiler flags ${_compilerFlags}") endif() set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) endfunction() @@ -2335,7 +2335,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) get_filename_component(_outputDir "${_outputDir}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) - set_property(TARGET ${_target} PROPERTY ${_property} "${_outputDir}") + set_property(TARGET ${_unityTargetName} PROPERTY ${_property} "${_outputDir}") set (_setDefaultOutputDir FALSE) endif() endforeach() diff --git a/HISTORY.md b/HISTORY.md index 49325a8..31f9793 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.3.4 (2013-02-07) + +* fixed bug with computing to output directory of the generated unity target (thanks shaunew). +* fixed wrong variable reference in debugging output (thanks shaunew). + ## 1.3.3 (2013-02-03) * fixed bug with handling of policy CMP0018 relating to target property `POSITION_INDEPENDENT_CODE`. From 0ef11cade183d6995e1da3b7144f9d0f21c85ca1 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 1 Mar 2013 20:29:15 +0100 Subject: [PATCH 035/169] cotire 1.3.5 --- CMake/cotire.cmake | 10 +++++----- HISTORY.md | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3cc087a..2782c72 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.4") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.5") include(CMakeParseArguments) @@ -1519,7 +1519,7 @@ macro (cotire_get_intermediate_dir _cotireDir) get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) endmacro() -function (cotire_make_untiy_source_file_paths _language _target _maxIncludes _unityFilesVar) +function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) set (_sourceFiles ${ARGN}) list (LENGTH _sourceFiles _numberOfSources) set (_unityFileExt_C ".c") @@ -1900,7 +1900,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments - cotire_make_untiy_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) + cotire_make_unity_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" "${_unityFiles}" ${_cmdsVar}) else() set (_unityFile "${_unityFiles}") @@ -2157,7 +2157,7 @@ function (cotire_process_target_language _language _configurations _targetSource if (NOT _maxIncludes) set (_maxIncludes 0) endif() - cotire_make_untiy_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) + cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() endif() @@ -2844,7 +2844,7 @@ else() "This may be set to an integer > 0." "If a target contains more than that number of source files, cotire will create multiple unity source files for it." "If not set, cotire will only create a single unity source file." - "Is use to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." + "Is used to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." "Defaults to empty." ) diff --git a/HISTORY.md b/HISTORY.md index 31f9793..efc46e2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.3.5 (2013-03-01) + +* fix typos in function names and property descriptions. + ## 1.3.4 (2013-02-07) * fixed bug with computing to output directory of the generated unity target (thanks shaunew). From bdc118b5a4f2843471bcb96769f1961443634969 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 6 Mar 2013 21:09:41 +0100 Subject: [PATCH 036/169] cotire 1.3.6 --- CMake/cotire.cmake | 17 ++++++++++------- HISTORY.md | 5 +++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 2782c72..af8c0ca 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.3.6") include(CMakeParseArguments) @@ -1826,7 +1826,7 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who list (LENGTH _prefixFiles _numberOfPrefixFiles) if (_numberOfPrefixFiles GREATER 1) cotire_make_prefix_file_path("" ${_target} _prefixHeader) - cotire_setup_combine_command("${_targetSourceDir}" "" "${_prefixHeader}" "${_prefixFiles}" _cmds) + cotire_setup_combine_command("${_targetSourceDir}" "" "${_prefixHeader}" _cmds ${_prefixFiles}) else() set (_prefixHeader "${_prefixFiles}") endif() @@ -1901,7 +1901,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_unity_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) - cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" "${_unityFiles}" ${_cmdsVar}) + cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) else() set (_unityFile "${_unityFiles}") endif() @@ -1924,7 +1924,8 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _files _cmdsVar) +function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _cmdsVar) + set (_files ${ARGN}) set (_filesPaths "") foreach (_file ${_files}) if (IS_ABSOLUTE "${_file}") @@ -1932,7 +1933,7 @@ function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _fil else() get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) endif() - file (RELATIVE_PATH _fileRelPath "${CMAKE_BINARY_DIR}" "${_filePath}") + file (RELATIVE_PATH _fileRelPath "${_sourceDir}" "${_filePath}") if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") list (APPEND _filesPaths "${_fileRelPath}") else() @@ -1955,7 +1956,7 @@ function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _fil COMMAND ${_prefixCmd} DEPENDS ${_files} COMMENT "Generating ${_joinedFileRelPath}" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + WORKING_DIRECTORY "${_sourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2168,7 +2169,7 @@ function (cotire_process_target_language _language _configurations _targetSource # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) - cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_prefixHeaderFiles}" _cmds) + cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) @@ -3106,4 +3107,6 @@ else() "Defaults to empty string." ) + message (STATUS "cotire ${COTIRE_CMAKE_MODULE_VERSION} loaded.") + endif() diff --git a/HISTORY.md b/HISTORY.md index efc46e2..a88609a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.3.6 (2013-03-06) + +* fix bug with prefix header initialization for generator Xcode. +* print cotire version upon inclusion. + ## 1.3.5 (2013-03-01) * fix typos in function names and property descriptions. From cb1a037eb8b15e5332ad5318cb9ff732666c439b Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 11 Mar 2013 22:00:00 +0100 Subject: [PATCH 037/169] cotire 1.4.0 --- CMake/cotire.cmake | 222 ++++++++++++++++++++++++++++++--------------- HISTORY.md | 7 ++ MANUAL.md | 97 ++++++++++++++++---- README.md | 5 +- 4 files changed, 240 insertions(+), 91 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index af8c0ca..ba2c8f2 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,9 +45,10 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.3.6") +set (COTIRE_CMAKE_MODULE_VERSION "1.4.0") include(CMakeParseArguments) +include(ProcessorCount) function (cotire_determine_compiler_version _language _versionPrefix) if (NOT ${_versionPrefix}_VERSION) @@ -1519,11 +1520,31 @@ macro (cotire_get_intermediate_dir _cotireDir) get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) endmacro() -function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) - set (_sourceFiles ${ARGN}) - list (LENGTH _sourceFiles _numberOfSources) +macro (cotire_setup_file_extension_variables) set (_unityFileExt_C ".c") set (_unityFileExt_CXX ".cxx") + set (_prefixFileExt_C ".h") + set (_prefixFileExt_CXX ".hxx") +endmacro() + +function (cotire_make_single_unity_source_file_path _language _target _unityFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _unityFileExt_${_language}) + set (${_unityFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}") + cotire_get_intermediate_dir(_baseDir) + set (_unityFile "${_baseDir}/${_unityFileName}") + set (${_unityFileVar} "${_unityFile}" PARENT_SCOPE) + if (COTIRE_DEBUG) + message(STATUS "${_unityFile}") + endif() +endfunction() + +function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) + cotire_setup_file_extension_variables() if (NOT DEFINED _unityFileExt_${_language}) set (${_unityFileVar} "" PARENT_SCOPE) return() @@ -1533,11 +1554,13 @@ function (cotire_make_unity_source_file_paths _language _target _maxIncludes _un set (_startIndex 0) set (_index 0) set (_unityFiles "") + set (_sourceFiles ${ARGN}) foreach (_sourceFile ${_sourceFiles}) get_source_file_property(_startNew "${_sourceFile}" COTIRE_START_NEW_UNITY_SOURCE) math (EXPR _unityFileCount "${_index} - ${_startIndex}") if (_startNew OR (_maxIncludes GREATER 0 AND NOT _unityFileCount LESS _maxIncludes)) if (_index GREATER 0) + # start new unity file segment math (EXPR _endIndex "${_index} - 1") set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") @@ -1546,10 +1569,12 @@ function (cotire_make_unity_source_file_paths _language _target _maxIncludes _un endif() math (EXPR _index "${_index} + 1") endforeach() + list (LENGTH _sourceFiles _numberOfSources) if (_startIndex EQUAL 0) - set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}") - list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + # there is only a single unity file + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFiles) elseif (_startIndex LESS _numberOfSources) + # end with final unity file segment math (EXPR _endIndex "${_index} - 1") set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") @@ -1560,9 +1585,21 @@ function (cotire_make_unity_source_file_paths _language _target _maxIncludes _un endif() endfunction() +function (cotire_unity_to_prefix_file_path _language _target _unityFile _prefixFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _unityFileExt_${_language}) + set (${_prefixFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + string (REPLACE "${_unityFileBaseName}" "${_prefixFileBaseName}" _prefixFile "${_unityFile}") + string (REGEX REPLACE "${_unityFileExt_${_language}}$" "${_prefixFileExt_${_language}}" _prefixFile "${_prefixFile}") + set (${_prefixFileVar} "${_prefixFile}" PARENT_SCOPE) +endfunction() + function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar) - set (_prefixFileExt_C ".h") - set (_prefixFileExt_CXX ".hxx") + cotire_setup_file_extension_variables() if (NOT _language) set (_prefixFileBaseName "${_target}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_C}") @@ -1811,6 +1848,43 @@ function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (${_propertyValueVar} "" PARENT_SCOPE) endfunction() +function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _cmdsVar) + set (_files ${ARGN}) + set (_filesPaths "") + foreach (_file ${_files}) + if (IS_ABSOLUTE "${_file}") + set (_filePath "${_file}") + else() + get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) + endif() + file (RELATIVE_PATH _fileRelPath "${_sourceDir}" "${_filePath}") + if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") + list (APPEND _filesPaths "${_fileRelPath}") + else() + list (APPEND _filesPaths "${_filePath}") + endif() + endforeach() + cotire_set_cmd_to_prologue(_prefixCmd) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") + if (_targetScript) + list (APPEND _prefixCmd "${_targetScript}") + endif() + list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths}) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") + endif() + set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) + file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + add_custom_command( + OUTPUT "${_joinedFile}" + COMMAND ${_prefixCmd} + DEPENDS ${_files} + COMMENT "Generating ${_joinedFileRelPath}" + WORKING_DIRECTORY "${_sourceDir}" VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _wholeTarget) if (XCODE) # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers @@ -1892,20 +1966,17 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) endforeach() - set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) -endfunction() - -function (cotire_setup_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) - set (_sourceFiles ${ARGN}) list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments - cotire_make_unity_source_file_paths(${_language} ${_target} 0 _unityFile ${_unityFiles}) + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) - else() - set (_unityFile "${_unityFiles}") endif() - file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_single_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFile _cmdsVar) + set (_sourceFiles ${ARGN}) set (_dependencySources "") cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) cotire_set_cmd_to_prologue(_prefixCmd) @@ -1914,6 +1985,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_targetScript} ${_unityFile} ${_dependencySources}") endif() + file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} @@ -1924,40 +1996,25 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _cmdsVar) - set (_files ${ARGN}) - set (_filesPaths "") - foreach (_file ${_files}) - if (IS_ABSOLUTE "${_file}") - set (_filePath "${_file}") - else() - get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) - endif() - file (RELATIVE_PATH _fileRelPath "${_sourceDir}" "${_filePath}") - if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") - list (APPEND _filesPaths "${_fileRelPath}") - else() - list (APPEND _filesPaths "${_filePath}") - endif() - endforeach() - cotire_set_cmd_to_prologue(_prefixCmd) - list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") - if (_targetScript) - list (APPEND _prefixCmd "${_targetScript}") - endif() - list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths}) - if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") +function (cotire_setup_multi_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) + set (_sourceFiles ${ARGN}) + list (LENGTH _unityFiles _numberOfUnityFiles) + if (_numberOfUnityFiles GREATER 1) + set (_prefixFiles "") + foreach (_unityFile ${_unityFiles}) + cotire_unity_to_prefix_file_path(${_language} ${_target} "${_unityFile}" _prefixFileSegment) + cotire_setup_single_prefix_generation_command( + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" + "${_prefixFileSegment}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) + list (APPEND _prefixFiles "${_prefixFileSegment}") + endforeach() + # create a joint prefix header file from all prefix header segments + cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixFiles}) + else() + cotire_setup_single_prefix_generation_command( + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" + "${_prefixFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) endif() - set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) - file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") - add_custom_command( - OUTPUT "${_joinedFile}" - COMMAND ${_prefixCmd} - DEPENDS ${_files} - COMMENT "Generating ${_joinedFileRelPath}" - WORKING_DIRECTORY "${_sourceDir}" VERBATIM) - list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2135,6 +2192,30 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) endfunction() +function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) + set (_sourceFiles ${ARGN}) + get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + if (_maxIncludes MATCHES "(-j|--parallel) ?([0-9]*)") + set (_numberOfThreads "${CMAKE_MATCH_2}") + if (NOT _numberOfThreads) + # use all available cores + ProcessorCount(_numberOfThreads) + endif() + list (LENGTH _sourceFiles _numberOfSources) + math (EXPR _maxIncludes "(${_numberOfSources} + ${_numberOfThreads} - 1) / ${_numberOfThreads}") + # a unity source segment must not contain less than COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES files + if (_maxIncludes LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + set (_maxIncludes ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + endif() + elseif (NOT _maxIncludes MATCHES "[0-9]+") + set (_maxIncludes 0) + endif() + if (COTIRE_DEBUG) + message (STATUS "${_target} unity source max includes = ${_maxIncludes}") + endif() + set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) +endfunction() + function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTargetVar _cmdsVar) set (${_cmdsVar} "" PARENT_SCOPE) get_target_property(_targetSourceFiles ${_target} SOURCES) @@ -2154,10 +2235,7 @@ function (cotire_process_target_language _language _configurations _targetSource endif() cotire_generate_target_script( ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript ${_unitySourceFiles}) - get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) - if (NOT _maxIncludes) - set (_maxIncludes 0) - endif() + cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() @@ -2171,7 +2249,7 @@ function (cotire_process_target_language _language _configurations _targetSource if (_prefixHeaderFiles) cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() - cotire_setup_prefix_generation_command( + cotire_setup_multi_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) @@ -2295,20 +2373,6 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour endif() # add unity source files instead list (APPEND _unityTargetSources ${_unityFiles}) - # make unity files use precompiled header if there are multiple unity files - list (LENGTH _unityFiles _numberOfUnityFiles) - if (_targetUsePCH AND _numberOfUnityFiles GREATER ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) - get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) - get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) - if (_prefixFile AND _pchFile) - cotire_setup_pch_file_compilation( - ${_language} "${_targetBinaryDir}" "" "${_prefixFile}" "${_pchFile}" ${_unityFiles}) - cotire_setup_prefix_file_inclusion( - ${_language} ${_target} FALSE "${_prefixFile}" "${_pchFile}" ${_unityFiles}) - # add the prefix header to unity target sources - list (APPEND _unityTargetSources "${_prefixFile}") - endif() - endif() endif() endforeach() if (COTIRE_DEBUG) @@ -2756,7 +2820,17 @@ else() set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING "Minimum number of sources in target required to enable use of precompiled header.") - set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "" CACHE STRING + if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT) + if (DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT ${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}) + elseif ("${CMAKE_GENERATOR}" MATCHES "JOM|Ninja|Visual Studio") + # enable parallelization for generators that run multiple jobs by default + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "-j") + else() + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "0") + endif() + endif() + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT}" CACHE STRING "Maximum number of source files to include in a single unity source file.") if (NOT COTIRE_PREFIX_HEADER_FILENAME_SUFFIX) @@ -2842,11 +2916,13 @@ else() CACHED_VARIABLE PROPERTY "COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES" BRIEF_DOCS "Maximum number of source files to include in a single unity source file." FULL_DOCS - "This may be set to an integer > 0." + "This may be set to an integer >= 0." + "If 0, cotire will only create a single unity source file." "If a target contains more than that number of source files, cotire will create multiple unity source files for it." - "If not set, cotire will only create a single unity source file." + "Can be set to \"-j\" to optimize the count of unity source files for the number of available processor cores." + "Can be set to \"-j jobs\" to optimize the number of unity source files for the given number of simultaneous jobs." "Is used to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." - "Defaults to empty." + "Defaults to \"-j\" for the generators Visual Studio, JOM or Ninja. Defaults to 0 otherwise." ) # define cotire directory properties diff --git a/HISTORY.md b/HISTORY.md index a88609a..c821ab6 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.4.0 (2013-03-11) + +* one year anniversary release. +* add support for multi-core optimized unity builds for some CMake generators. +* add support for multi-core optimized prefix header generation. +* add more examples to cotire manual. + ## 1.3.6 (2013-03-06) * fix bug with prefix header initialization for generator Xcode. diff --git a/MANUAL.md b/MANUAL.md index d522b24..047fd1f 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -127,6 +127,9 @@ The unity source file uses absolute paths to include the target's source file. T intended to be portable across different build folders or machines. It is an intermediate file tied to the build folder that is automatically recreated by the build system if it is missing. +For multi-core machines cotire can be configured to generate multiple unity file segments that +can be built in parallel by the chosen CMake generator (see below). + ### the prefix header The prefix header is produced from the unity source file by running the unity file through the @@ -180,10 +183,12 @@ The generated prefix file includes the selected header files by their absolute p up the precompiling of the prefix header because the compiler does not have to search for header files in include directories again. -The prefix header is tailored to the CMake target that it is generated for and cannot be re-used -for a different CMake target. It is tied to the compiler environment of the local machine and -is not portable across different compilers or machines. It is automatically recreated by the -build system if it goes missing. +The prefix header is tailored to the CMake target that it is generated for. It is tied to the +compiler environment of the local machine and is not portable across different compilers or +machines. It is automatically recreated by the build system if it goes missing. + +The generated prefix header can be applied to a different target added in the same source directory +(see below). ### the precompiled header @@ -226,11 +231,24 @@ the correct precompiled header depending on the compilation language of the sour For a cotired target the target properties `COTIRE__UNITY_SOURCE`, `COTIRE__PREFIX_HEADER`, `COTIRE__PRECOMPILED_HEADER` will be set to the paths of the generated files (`` can be set to `CXX` or `C`). The target property -`COTIRE_UNITY_TARGET_NAME` will be set to the name of the generated unity target. +`COTIRE_UNITY_TARGET_NAME` will be set to the name of the generated unity target: + + cotire(example) + ... + get_target_property(_unitySource example COTIRE_CXX_UNITY_SOURCE) + get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) + get_target_property(_precompiledHeader example COTIRE_CXX_PRECOMPILED_HEADER) If a source file's `COMPILE_FLAGS` are modified by cotire, it sets the source file property `COTIRE_TARGET` to the name of the target, that the source file's build command has been -altered for. +altered for: + + cotire(example) + ... + get_source_file_property(_cotireTargetName "example.cpp" COTIRE_TARGET) + if (_cotireTargetName) + message(STATUS "example.cpp has been cotired for target ${_cotireTargetName}") + endif() ### changing the name of the generated unity build target @@ -281,7 +299,10 @@ directories. A target inherits the property value from its enclosing directory. ### disabling precompiled headers for small targets The cache variable `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` can be set to the minimum number of -source files required to enable the use of a precompiled header. It defaults to 3. +source files required to enable the use of a precompiled header. It defaults to 3. To override the +default, run `cmake` with the following options: + + $ cmake -D COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES=5 ### using a manually maintained prefix header instead of the automatically generated one @@ -293,23 +314,25 @@ file. The path is interpreted relative to the target source directory: set_target_properties(example PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h") cotire(example) -The property can also be set to a list of header files which will then make up the contents of -the generated prefix header. - If the prefix header `stdafx.h` needs an accompanying source file (e.g., `stdafx.cpp`) in order to be pre-compiled properly, that source file needs to be the first one on the list of source files in the target's `add_executable` or `add_library` call. +The property `COTIRE_CXX_PREFIX_HEADER_INIT` can also be set to a list of header files which will +then make up the contents of the generated prefix header. + ### using a generated prefix header for multiple targets -A prefix header that is generated for a cotired target can be applied to a different target that -has been added in the same source directory: +A prefix header that is generated for a cotired target can be applied to a different target +added in the same source directory: cotire(example) get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) ... - set_target_properties(example2 PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${_prefixHeader}") - cotire(example2) + set_target_properties(other_target PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${_prefixHeader}") + cotire(other_target) + +The compilation of either target will trigger the generation of the prefix header. ### configuring the generation of the prefix header @@ -350,7 +373,9 @@ removed from a target source file). Cotire does not automatically recreate the p when a target source file is changed, because this would always trigger a re-compilation of the precompiled header and would result in a rebuild of the whole target. To make the prefix header creation dependent on changes to certain target source files, the source file property -`COTIRE_DEPENDENCY` can be set to `TRUE` for those files. +`COTIRE_DEPENDENCY` can be set to `TRUE` for those files: + + set_property (SOURCE "example.cpp" PROPERTY COTIRE_DEPENDENCY "TRUE") ### fixing linkage issues @@ -378,7 +403,7 @@ upon linking. ### using a manually maintained unity source instead of the automatically generated one -cotire can be configured to use an existing manually maintained unity source file instead of the +Cotire can be configured to use an existing manually maintained unity source file instead of the automatically generated one. Set the target property `COTIRE_CXX_UNITY_SOURCE_INIT` to the path of the existing unity source file. Its path is interpreted relative to the target source directory: @@ -417,6 +442,25 @@ this property, it will complete the current unity file and start a new one. The file will include the source file as the first one. This property essentially works as a separator for unity source files. +### optimizing the build process for multiple processor cores + +To make use of all the machine's CPU cores for the unity compilation of a target, the target +property `COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES` can be set to the string `-j`. Cotire +will then create as many unity file segments as there are CPU cores on the machine. Because +the unity file segments do not depend on each other, a multi-core aware build process can compile +the file segments in parallel. + +To explicitly specify the number of cores, append the number after `-j`, e.g. `-j 4` or `-j4`. + +For CMake generators that are multi-core aware by default (i.e., Visual Studio, JOM, Ninja) cotire +will automatically initialize the property to `-j`. For makefile based generators, this has to be +done explicitly by setting the cache variable `COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES`, i.e.: + + $ cmake -D COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES=-j4 + $ make -j 4 + +The setting `-j` will also make the automatic prefix header generation run in parallel. + ### fixing macro definition clashes Many unity build problems stem from macro definitions leaking into other target source files, @@ -452,6 +496,22 @@ source and the prefix header for verbose builds. `COTIRE_VERBOSE` defaults to `F When using a Makefile generator `COTIRE_VERBOSE` defaults to the value of the makefile variable `VERBOSE` (i.e., `make VERBOSE=1`). +### conditionally loading cotire + +To make a `CMakeLists.txt` robust against a missing `cotire.cmake` module, the following strategy +can be applied to using cotire: + + include(cotire OPTIONAL) + ... + add_executable(example main.cpp example.cpp log.cpp log.h example.h) + ... + if (COMMAND cotire) + cotire(example) + endif() + +The `include(cotire OPTIONAL)` will prevent CMake from raising an error if cotire cannot be +found. The actual calls to cotire need to be guarded by `if (COMMAND cotire)` blocks. + ### using cotire with compiler wrappers Cotire is compatible with CMake compiler wrappers. For example, the use of [ccache][ccch] may be @@ -514,6 +574,10 @@ The Intel compiler may issue incorrect warnings #672 (the command line options d used when precompiled header was created) or #673 (the initial sequence of preprocessing directives is not compatible with those of precompiled header file) upon compilation of cotired targets. +### IncrediBuild + +Cotire is not compatible with [Xoreax IncrediBuild][XGE]. + [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders @@ -528,3 +592,4 @@ is not compatible with those of precompiled header file) upon compilation of cot [objlib]:http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library [pfh]:http://en.wikipedia.org/wiki/Prefix_header [icc_linux]:http://software.intel.com/en-us/non-commercial-software-development +[XGE]:http://www.incredibuild.com diff --git a/README.md b/README.md index b3620e6..d155ca2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ features * Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds. * Compatible with CMake single build type and CMake multi-configuration builds. * Compatible with most CMake generators (including [Ninja][ninja]). -* Compatible with parallel builds (make -j, [jom][jom], Visual Studio, Xcode). +* Supports multi-core unity builds for some generators (make -j, [jom][jom], Visual Studio, Ninja). * Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). * Compatible with CMake's [cross-compiling][ccrc] support. * Compatible with compiler wrappers like [ccache][ccch]. @@ -87,7 +87,8 @@ the original target, but does so much faster by entering: $ make MyExecutable_unity See the advanced usage section of the [cotire manual][manual] for information on how to -configure the cotire process (e.g., how to apply cotire to a certain build configuration only). +configure the cotire process (e.g., how to make the unity build use all available processor +cores). The directory `Patches` contains patch files to enable cotire for some popular open sources packages that use CMake as a build system. From eb63dcabf0daafc84dc8e6ea5f647861b643ed1a Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 8 Jun 2013 17:54:04 +0200 Subject: [PATCH 038/169] cotire 1.4.1 --- CMake/cotire.cmake | 81 ++++++++++++++++++++++------------------------ HISTORY.md | 6 ++++ MANUAL.md | 2 -- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ba2c8f2..a6e3141 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,36 +45,32 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.4.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.4.1") include(CMakeParseArguments) include(ProcessorCount) function (cotire_determine_compiler_version _language _versionPrefix) if (NOT ${_versionPrefix}_VERSION) - if (MSVC) - # use CMake's predefined version variable for MSVC, if available - if (DEFINED MSVC_VERSION) - set (${_versionPrefix}_VERSION "${MSVC_VERSION}") - else() - # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared - unset (ENV{VS_UNICODE_OUTPUT}) - string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} - ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) - string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" - ${_versionPrefix}_VERSION "${_versionLine}") - endif() + # use CMake's predefined compiler version variable (available since CMake 2.8.8) + if (DEFINED CMAKE_${_language}_COMPILER_VERSION) + set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") + elseif (WIN32) + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} + ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) + string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" ${_versionPrefix}_VERSION "${_versionLine}") else() - # use CMake's predefined compiler version variable (available since CMake 2.8.8) - if (DEFINED CMAKE_${_language}_COMPILER_VERSION) - set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") - else() - # assume GCC like command line interface - string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" - OUTPUT_VARIABLE ${_versionPrefix}_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) + # assume GCC like command line interface + string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) + execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" + OUTPUT_VARIABLE ${_versionPrefix}_VERSION + RESULT_VARIABLE _result + OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) + if (_result) + set (${_versionPrefix}_VERSION "") endif() endif() if (${_versionPrefix}_VERSION) @@ -398,7 +394,7 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() -function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar) +function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar) set (_includeDirs "") # default include dirs if (CMAKE_INCLUDE_CURRENT_DIR) @@ -1848,7 +1844,7 @@ function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (${_propertyValueVar} "" PARENT_SCOPE) endfunction() -function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _cmdsVar) +function (cotire_setup_combine_command _language _sourceDir _targetScript _joinedFile _cmdsVar) set (_files ${ARGN}) set (_filesPaths "") foreach (_file ${_files}) @@ -1875,11 +1871,19 @@ function (cotire_setup_combine_command _sourceDir _targetScript _joinedFile _cmd endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + get_filename_component(_joinedFileName "${_joinedFileRelPath}" NAME_WE) + if (_language AND _joinedFileName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") + set (_comment "Generating ${_language} unity source ${_joinedFileRelPath}") + elseif (_language AND _joinedFileName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") + set (_comment "Generating ${_language} prefix header ${_joinedFileRelPath}") + else() + set (_comment "Generating ${_joinedFileRelPath}") + endif() add_custom_command( OUTPUT "${_joinedFile}" COMMAND ${_prefixCmd} DEPENDS ${_files} - COMMENT "Generating ${_joinedFileRelPath}" + COMMENT "${_comment}" WORKING_DIRECTORY "${_sourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) @@ -1900,7 +1904,7 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who list (LENGTH _prefixFiles _numberOfPrefixFiles) if (_numberOfPrefixFiles GREATER 1) cotire_make_prefix_file_path("" ${_target} _prefixHeader) - cotire_setup_combine_command("${_targetSourceDir}" "" "${_prefixHeader}" _cmds ${_prefixFiles}) + cotire_setup_combine_command("" "${_targetSourceDir}" "" "${_prefixHeader}" _cmds ${_prefixFiles}) else() set (_prefixHeader "${_prefixFiles}") endif() @@ -1970,7 +1974,7 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2000,16 +2004,10 @@ function (cotire_setup_multi_prefix_generation_command _language _target _target set (_sourceFiles ${ARGN}) list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) - set (_prefixFiles "") - foreach (_unityFile ${_unityFiles}) - cotire_unity_to_prefix_file_path(${_language} ${_target} "${_unityFile}" _prefixFileSegment) - cotire_setup_single_prefix_generation_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" - "${_prefixFileSegment}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) - list (APPEND _prefixFiles "${_prefixFileSegment}") - endforeach() - # create a joint prefix header file from all prefix header segments - cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixFiles}) + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) + cotire_setup_single_prefix_generation_command( + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" + "${_prefixFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) else() cotire_setup_single_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" @@ -2195,7 +2193,7 @@ endfunction() function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (_sourceFiles ${ARGN}) get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) - if (_maxIncludes MATCHES "(-j|--parallel) ?([0-9]*)") + if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)") set (_numberOfThreads "${CMAKE_MATCH_2}") if (NOT _numberOfThreads) # use all available cores @@ -2223,7 +2221,7 @@ function (cotire_process_target_language _language _configurations _targetSource set (_excludedSources "") set (_cotiredSources "") cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) - if (NOT _sourceFiles) + if (NOT _sourceFiles AND NOT _cotiredSources) return() endif() set (_wholeTarget ${${_wholeTargetVar}}) @@ -2247,7 +2245,7 @@ function (cotire_process_target_language _language _configurations _targetSource # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) - cotire_setup_combine_command("${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_multi_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) @@ -2343,7 +2341,6 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour # determine unity target sources get_target_property(_targetSourceFiles ${_target} SOURCES) set (_unityTargetSources ${_targetSourceFiles}) - get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) foreach (_language ${_languages}) get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) if (_unityFiles) diff --git a/HISTORY.md b/HISTORY.md index c821ab6..a281708 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.4.1 (2013-06-08) + +* fixed bug with determination of compiler version. +* fixed bug with generation of unity source when target source files are used for multiple targets. +* fixed bug with multi-core optimized prefix header generation. + ## 1.4.0 (2013-03-11) * one year anniversary release. diff --git a/MANUAL.md b/MANUAL.md index 047fd1f..0faa067 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -459,8 +459,6 @@ done explicitly by setting the cache variable `COTIRE_MAXIMUM_NUMBER_OF_UNITY_IN $ cmake -D COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES=-j4 $ make -j 4 -The setting `-j` will also make the automatic prefix header generation run in parallel. - ### fixing macro definition clashes Many unity build problems stem from macro definitions leaking into other target source files, From d503793baf654188a2ee42088c0dee1560cd1d99 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 24 Aug 2013 17:23:01 +0200 Subject: [PATCH 039/169] cotire 1.4.2 --- CMake/cotire.cmake | 126 ++++++++++++++++++++++++++++++++------------- HISTORY.md | 6 +++ MANUAL.md | 3 ++ 3 files changed, 98 insertions(+), 37 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a6e3141..a381a69 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.4.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.4.2") include(CMakeParseArguments) include(ProcessorCount) @@ -1334,21 +1334,32 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() -function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) +function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) set (_flags ${${_flagsVar}}) if (_compilerID MATCHES "MSVC") file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) - file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) # cl.exe options used # /Yu uses a precompiled header file during build # /Fp specifies precompiled header binary file name # /FI forces inclusion of file - if (_flags) - # append to list - list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (_pchFile) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + if (_flags) + # append to list + list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + endif() else() - # return as a flag string - set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFileNative}\"") + endif() endif() elseif (_compilerID MATCHES "GNU") # GCC options used @@ -1375,23 +1386,34 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion elseif (_compilerID MATCHES "Intel") if (WIN32) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) - file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) # Windows Intel options used # /Yu use a precompiled header (PCH) file # /Fp specify a path or file name for precompiled header files # /FI tells the preprocessor to include a specified file name as the header file # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) - if (_flags) - # append to list - list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") - if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "/Wpch-messages") + if (_pchFile) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + if (_flags) + # append to list + list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "/Wpch-messages") + endif() + else() + # return as a flag string + set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} /Wpch-messages") + endif() endif() else() - # return as a flag string - set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") - if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} /Wpch-messages") + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFileNative}\"") endif() endif() else() @@ -1400,19 +1422,30 @@ function (cotire_add_pch_inclusion_flags _language _compilerID _compilerVersion # -pch-use name of the precompiled header (PCH) to use # -include process include file as the first line of the primary source file # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) - get_filename_component(_pchDir "${_pchFile}" PATH) - get_filename_component(_pchName "${_pchFile}" NAME) - if (_flags) - # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") - if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (_pchFile) + get_filename_component(_pchDir "${_pchFile}" PATH) + get_filename_component(_pchName "${_pchFile}" NAME) + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "-Wpch-messages") + endif() + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} -Wpch-messages") + endif() endif() else() - # return as a flag string - set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") - if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\"") endif() endif() endif() @@ -1759,7 +1792,7 @@ function (cotire_setup_pch_file_compilation _language _targetBinaryDir _targetSc set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we attach the precompiled header compilation to the first source file - # the remaining files include the precompiled header, see cotire_setup_prefix_file_inclusion + # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) @@ -1795,7 +1828,7 @@ function (cotire_setup_pch_file_compilation _language _targetBinaryDir _targetSc endif() endfunction() -function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) +function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we include the precompiled header in all but the first source file @@ -1807,7 +1840,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _pre list (REMOVE_AT _sourceFiles 0) set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - cotire_add_pch_inclusion_flags( + cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") @@ -1820,7 +1853,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _pre # of the source files, if this is a multi-language target or has excluded files set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - cotire_add_pch_inclusion_flags( + cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") @@ -1832,6 +1865,21 @@ function (cotire_setup_prefix_file_inclusion _language _target _wholeTarget _pre endif() endfunction() +function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) + set (_sourceFiles ${ARGN}) + # force the inclusion of the prefix header for the given source files + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + # make source files depend on prefix header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") +endfunction() + function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (_properties ${ARGN}) foreach (_property ${_properties}) @@ -1924,13 +1972,13 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who if (_wholeTarget) set (_language "${_languages}") # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level - # see cotire_setup_prefix_file_inclusion + # see cotire_setup_pch_file_inclusion if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - cotire_add_pch_inclusion_flags( + cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") @@ -2259,9 +2307,13 @@ function (cotire_process_target_language _language _configurations _targetSource if (_excludedSources) set (_wholeTarget FALSE) endif() - cotire_setup_prefix_file_inclusion( + cotire_setup_pch_file_inclusion( ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) endif() + elseif (_prefixHeaderFiles) + # user provided prefix header must be included + cotire_setup_prefix_file_inclusion( + ${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) endif() endif() # mark target as cotired for language @@ -2431,7 +2483,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour # copy link stuff cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH - LINKER_LANGUAGE LINK_DEPENDS + LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_ LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ diff --git a/HISTORY.md b/HISTORY.md index a281708..b669479 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.4.2 (2013-08-24) + +* CMake 2.8.11 compatibility fixes. +* always force the inclusion of a user provided prefix header, even if the target + contains too few sources to enable the use of a precompiled header. + ## 1.4.1 (2013-06-08) * fixed bug with determination of compiler version. diff --git a/MANUAL.md b/MANUAL.md index 0faa067..cb2b874 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -321,6 +321,9 @@ files in the target's `add_executable` or `add_library` call. The property `COTIRE_CXX_PREFIX_HEADER_INIT` can also be set to a list of header files which will then make up the contents of the generated prefix header. +A manually maintained prefix header will always be applied to the corresponding target, +even if the target contains too few sources to enable the use of a precompiled header. + ### using a generated prefix header for multiple targets A prefix header that is generated for a cotired target can be applied to a different target From b9a5113a4a80425c28ec1380f13c5dc4e0001c66 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 28 Sep 2013 14:20:09 +0200 Subject: [PATCH 040/169] cotire 1.4.3 --- CMake/cotire.cmake | 10 ++++++---- HISTORY.md | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a381a69..77ffa5b 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.4.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.4.3") include(CMakeParseArguments) include(ProcessorCount) @@ -167,7 +167,7 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) if (COTIRE_DEBUG) - message (STATUS "${_sourceFile} excluded=${_sourceIsExcluded} cotired=${_sourceIsCotired}") + message (STATUS "${_sourceFile} excluded=${_sourceIsExcluded} cotired=${_sourceIsCotired} compileFlags=${_sourceCompileFlags}") endif() if (_sourceIsCotired) list (APPEND _cotiredSourceFiles "${_sourceFile}") @@ -1788,7 +1788,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) endfunction() -function (cotire_setup_pch_file_compilation _language _targetBinaryDir _targetScript _prefixFile _pchFile) +function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _targetScript _prefixFile _pchFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we attach the precompiled header compilation to the first source file @@ -1806,6 +1806,8 @@ function (cotire_setup_pch_file_compilation _language _targetBinaryDir _targetSc set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") # make first source file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") + # mark first source file as cotired to prevent it from being used in another cotired target + set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") endif() elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generator, we add a custom command to precompile the prefix header @@ -2303,7 +2305,7 @@ function (cotire_process_target_language _language _configurations _targetSource cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( - ${_language} "${_targetBinaryDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) if (_excludedSources) set (_wholeTarget FALSE) endif() diff --git a/HISTORY.md b/HISTORY.md index b669479..b20f192 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.4.3 (2013-09-28) + +* fixed bug with generation of unity source file when `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` is + set to 0. + ## 1.4.2 (2013-08-24) * CMake 2.8.11 compatibility fixes. From f486a9dece2272eef6a1875ada36f0f6963769ed Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 13 Oct 2013 19:23:15 +0200 Subject: [PATCH 041/169] cotire 1.5.0 --- CMake/cotire.cmake | 194 ++++++++++++++++++++++++++---------- HISTORY.md | 11 ++ MANUAL.md | 52 +++++++++- Patches/clang-3.3.src.patch | 46 +++++++++ Patches/llvm-3.3.src.patch | 128 ++++++++++++++++++++++++ README.md | 10 +- 6 files changed, 382 insertions(+), 59 deletions(-) create mode 100644 Patches/clang-3.3.src.patch create mode 100644 Patches/llvm-3.3.src.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 77ffa5b..c17783b 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.4.3") +set (COTIRE_CMAKE_MODULE_VERSION "1.5.0") include(CMakeParseArguments) include(ProcessorCount) @@ -228,7 +228,7 @@ function (cotire_get_source_file_property_values _valuesVar _property) set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() -function (cotrie_resolve_config_properites _configurations _propertiesVar) +function (cotire_resolve_config_properites _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "") @@ -244,8 +244,8 @@ function (cotrie_resolve_config_properites _configurations _propertiesVar) set (${_propertiesVar} ${_properties} PARENT_SCOPE) endfunction() -function (cotrie_copy_set_properites _configurations _type _source _target) - cotrie_resolve_config_properites("${_configurations}" _properties ${ARGN}) +function (cotire_copy_set_properites _configurations _type _source _target) + cotire_resolve_config_properites("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) @@ -362,6 +362,10 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (_targetflags) set (_compileFlags "${_compileFlags} ${_targetflags}") endif() + get_target_property(_targetOptions ${_target} COMPILE_OPTIONS) + if (_targetOptions) + set (_compileFlags "${_compileFlags} ${_targetOptions}") + endif() endif() if (UNIX) separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") @@ -447,11 +451,15 @@ function (cotire_get_target_include_directories _config _language _targetSourceD endfunction() macro (cotire_make_C_identifier _identifierVar _str) - # mimic CMake SystemTools::MakeCindentifier behavior - if ("${_str}" MATCHES "^[0-9].+$") - set (_str "_${str}") + if (CMAKE_VERSION VERSION_LESS "2.8.12") + # mimic CMake SystemTools::MakeCindentifier behavior + if ("${_str}" MATCHES "^[0-9].+$") + set (_str "_${str}") + endif() + string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") + else() + string (MAKE_C_IDENTIFIER "${_identifierVar}" "${_str}") endif() - string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") endmacro() function (cotire_get_target_export_symbol _target _exportSymbolVar) @@ -1141,7 +1149,7 @@ function (cotire_generate_prefix_header _prefixFile) endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() - file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}") endfunction() function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) @@ -1378,10 +1386,10 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # -Qunused-arguments don't emit warning for unused driver arguments if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-Qunused-arguments") + list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") else() # return as a flag string - set (_flags "-include \"${_prefixFile}\" -Qunused-arguments") + set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1983,7 +1991,7 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) - set_property (TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") endif() endif() endif() @@ -2099,6 +2107,10 @@ function (cotire_init_cotire_target_properties _target) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS "") endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "") + endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET) if (NOT _isSet) if (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) @@ -2113,7 +2125,14 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) string (REPLACE ";" " " _languagesStr "${_languages}") - string (REPLACE ";" ", " _excludedStr "${ARGN}") + math (EXPR _numberOfExcludedFiles "${ARGC} - 4") + if (_numberOfExcludedFiles EQUAL 0) + set (_excludedStr "") + elseif (COTIRE_VERBOSE OR _numberOfExcludedFiles LESS 4) + string (REPLACE ";" ", " _excludedStr "excluding ${ARGN}") + else() + set (_excludedStr "excluding ${_numberOfExcludedFiles} files") + endif() set (_targetMsg "") if (NOT _languages) set (_targetMsg "Target ${_target} cannot be cotired.") @@ -2126,8 +2145,8 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa set (_targetMsg "${_targetMsg} ${_disableMsg}") endif() elseif (NOT _targetUsePCH) - if (_allExcludedSourceFiles) - set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr} without precompiled header.") + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header.") endif() @@ -2135,14 +2154,14 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa set (_targetMsg "${_targetMsg} ${_disableMsg}") endif() elseif (NOT _targetAddSCU) - if (_allExcludedSourceFiles) - set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr} without unity build.") + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") endif() else() - if (_allExcludedSourceFiles) - set (_targetMsg "${_languagesStr} target ${_target} cotired excluding files ${_excludedStr}.") + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired.") endif() @@ -2165,7 +2184,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER) get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE) if (_prefixHeader OR _unityBuildFile) - message (WARNING "Target ${_target} has already been cotired.") + message (STATUS "Target ${_target} has already been cotired.") set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() @@ -2377,15 +2396,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour # determine unity target sub type get_target_property(_targetType ${_target} TYPE) if ("${_targetType}" STREQUAL "EXECUTABLE") - get_target_property(_isWin32 ${_target} WIN32_EXECUTABLE) - get_target_property(_isMacOSX_Bundle ${_target} MACOSX_BUNDLE) - if (_isWin32) - set (_unityTargetSubType WIN32) - elseif (_isMacOSX_Bundle) - set (_unityTargetSubType MACOSX_BUNDLE) - else() - set (_unityTargetSubType "") - endif() + set (_unityTargetSubType "") elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") set (_unityTargetSubType "${CMAKE_MATCH_1}") else() @@ -2445,8 +2456,8 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) - cotrie_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) @@ -2466,24 +2477,31 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) endif() # copy output name - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ OUTPUT_NAME OUTPUT_NAME_ RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_ PREFIX _POSTFIX SUFFIX) # copy compile stuff - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ - COMPILE_FLAGS Fortran_FORMAT + COMPILE_FLAGS COMPILE_OPTIONS + Fortran_FORMAT Fortran_MODULE_DIRECTORY INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_ - POSITION_INDEPENDENT_CODE) + POSITION_INDEPENDENT_CODE + C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) + # copy interface stuff + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_STRING + INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES + INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) # copy link stuff - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ @@ -2493,24 +2511,22 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ NO_SONAME SOVERSION VERSION) # copy Qt stuff - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} AUTOMOC AUTOMOC_MOC_OPTIONS) # copy cmake stuff - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) - # copy platform stuff - if (APPLE) - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST - OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) - elseif (WIN32) - cotrie_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - GNUtoMS - PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ - VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_KEYWORD - VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER - VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES) - endif() + # copy Apple platform specific stuff + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST + MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) + # copy Windows platform specific stuff + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + GNUtoMS + PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ + VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_KEYWORD + VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER + VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES WIN32_EXECUTABLE) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) @@ -2558,6 +2574,14 @@ function (cotire_target _target) message (WARNING "Imported target ${_target} cannot be cotired.") return() endif() + # resolve alias + get_target_property(_aliasName ${_target} ALIASED_TARGET) + if (_aliasName) + if (COTIRE_DEBUG) + message (STATUS "${_target} is an alias. Applying cotire to aliased target ${_aliasName} instead.") + endif() + set (_target ${_aliasName}) + endif() # check if target needs to be cotired for build type # when using configuration types, the test is performed at build time cotire_init_cotire_target_properties(${_target}) @@ -2606,7 +2630,46 @@ function (cotire_target _target) if (_targetAddCleanTarget) cotire_setup_clean_target(${_target}) endif() -endfunction() +endfunction(cotire_target) + +function(cotire_target_link_libraries _target) + get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_unityTargetName}") + get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}") + endif() + if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") + if (CMAKE_VERSION VERSION_LESS "2.8.11") + message (WARNING "Unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") + return() + endif() + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + if (_linkLibraries) + if (COTIRE_DEBUG) + message (STATUS "target ${_target} link libraries: ${_linkLibraries}") + endif() + set (_unityTargetLibraries "") + foreach (_library ${_linkLibraries}) + if (TARGET "${_library}" AND "${_linkLibrariesStrategy}" MATCHES "COPY_UNITY") + get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_libraryUnityTargetName}") + list (APPEND _unityTargetLibraries "${_libraryUnityTargetName}") + else() + list (APPEND _unityTargetLibraries "${_library}") + endif() + else() + list (APPEND _unityTargetLibraries "${_library}") + endif() + endforeach() + set_property(TARGET ${_unityTargetName} APPEND PROPERTY LINK_LIBRARIES ${_unityTargetLibraries}) + if (COTIRE_DEBUG) + message (STATUS "set unity target ${_unityTargetName} link libraries: ${_unityTargetLibraries}") + endif() + endif() + endif() + endif() +endfunction(cotire_target_link_libraries) function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) if (_targetName) @@ -2688,7 +2751,12 @@ function (cotire) cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS} SOURCE_DIR "${_option_SOURCE_DIR}" BINARY_DIR "${_option_BINARY_DIR}") else() - message (WARNING "${_target} is not a target") + message (WARNING "${_target} is not a target.") + endif() + endforeach() + foreach (_target ${_targets}) + if (TARGET ${_target}) + cotire_target_link_libraries(${_target}) endif() endforeach() endfunction() @@ -3034,6 +3102,13 @@ else() "See target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." ) + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" + BRIEF_DOCS "Define strategy for setting up the unity target's link libraries." + FULL_DOCS + "See target property COTIRE_UNITY_LINK_LIBRARIES_INIT." + ) + # define cotire target properties define_property( @@ -3143,6 +3218,17 @@ else() "Defaults to empty." ) + define_property( + TARGET PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" INHERITED + BRIEF_DOCS "Define strategy for setting up unity target's link libraries." + FULL_DOCS + "If this property is empty, the generated unity target's link libraries have to be set up manually." + "If this property is set to COPY, the unity target's link libraries will be copied from this target." + "If this property is set to COPY_UNITY, the unity target's link libraries will be copied from this target with considering existing unity targets." + "Inherited from directory." + "Defaults to empty." + ) + define_property( TARGET PROPERTY "COTIRE__UNITY_SOURCE" BRIEF_DOCS "Read-only property. The generated unity source file(s)." diff --git a/HISTORY.md b/HISTORY.md index b20f192..7762958 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,14 @@ +## 1.5.0 (2013-10-13) + +* CMake 2.8.12 compatibility fixes. +* Upon generation of a unity target, cotire can now be configured to automatically copy all the + linked libraries and targets from the original target. See the section on the new target property + `COTIRE_UNITY_LINK_LIBRARIES_INIT` in the cotire manual. +* fixed bug with copying target properties to generated unity target. +* cotire manual updates. +* add new examples to the `Patches` directory. +* fix typos. + ## 1.4.3 (2013-09-28) * fixed bug with generation of unity source file when `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` is diff --git a/MANUAL.md b/MANUAL.md index cb2b874..2ff95e1 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -99,9 +99,11 @@ files generated by cotire. The `example_unity` target produces the same output `example` target, but does so by performing a unity build. The `all_pch` and `all_unity` serve as pool targets for all cotired project targets. -The `example_unity` target inherits all build settings from the original target `example` except -for linked libraries and target dependencies. To get a linkable unity target, the required -libraries have to be added manually to the unity target with `target_link_libraries`. +By default, the `example_unity` target inherits all build settings from the original target +`example` except for linked libraries and target dependencies. To get a linkable unity target, +the required libraries have to be added manually to the unity target with `target_link_libraries`. +When using CMake 2.8.11 or later, it is possible to have the unity target inherit linked libraries +as well (see the section on the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` below). cotire generated files ---------------------- @@ -219,6 +221,17 @@ usable for the target and cannot be re-used for a different CMake target. cotire advanced usage --------------------- +### applying cotire to multiple targets at the same time + +The `cotire` function can be applied to multiple targets added in the same source directory in one +call: + + add_library(libA STATIC ...) + add_library(libB SHARED ...) + add_executable(example ...) + ... + cotire(example libA libB) + ### mixed-language targets Cotire is able to speed up the build process of mixed language targets, consisting of both C and @@ -418,7 +431,7 @@ the generated unity source file. ### configuring the generation of the unity source -By default cotire adds all target source file to the generated unity source. In most cases a +By default cotire adds all target source files to the generated unity source. In most cases a unity build will not work out of the box, because unity builds [break][EoUB] the use of some C and C++ language features. Unity build problems can be tackled in the following way: @@ -543,6 +556,37 @@ The `cotire` function can be applied to an object library target in a familiar f Because object library targets do not support `PRE_BUILD` actions, precompiled header usage cannot be enabled for them for Xcode projects generated with CMake. Unity builds work as expected, though. +### automatically setting up linked libraries in the unity target + +CMake 2.8.11 introduced a new target property `LINK_LIBRARIES`, which specifies the list of +libraries or targets which will be used for linking. Cotire can be configured to make use of this +property to automatically set up the linked libraries in the generated unity target. + +To have cotire copy the the list of linked libraries and targets from the original target to the +unity target, set the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` to `COPY`. + + cmake_minimum_required(VERSION 2.8.11) + ... + set_target_properties(example PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY") + ... + cotire(example) + +If the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` is set to `COPY_UNITY` instead, cotire +will copy all linked libraries and targets from the original target, but instead of copying a +target verbatim, it will prefer the target's corresponding unity target, provided one exists. + +For reasons of backwards compatibility, the `COTIRE_UNITY_LINK_LIBRARIES_INIT` property is left +empty by default. The required libraries have to be added manually to the unity target with +subsequent `target_link_libraries` calls. + +The property `COTIRE_UNITY_LINK_LIBRARIES_INIT` can also be set on directories. A target inherits +the property value from its enclosing directory. To make all targets in the project use the +`COPY_UNITY` strategy, the directory property can be set in the outermost `CMakeList.txt` file: + + include(cotire) + ... + set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + cotire usage restrictions ------------------------- diff --git a/Patches/clang-3.3.src.patch b/Patches/clang-3.3.src.patch new file mode 100644 index 0000000..bbfc83d --- /dev/null +++ b/Patches/clang-3.3.src.patch @@ -0,0 +1,46 @@ +diff -rupN cfe-3.3.src/CMakeLists.txt cfe-3.3.src.cotire/CMakeLists.txt +--- cfe-3.3.src/CMakeLists.txt 2013-04-22 16:51:21.000000000 +0200 ++++ cfe-3.3.src.cotire/CMakeLists.txt 2013-10-13 12:02:05.000000000 +0200 +@@ -2,7 +2,7 @@ + # standalone project, using LLVM as an external library: + if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + project(Clang) +- cmake_minimum_required(VERSION 2.8) ++ cmake_minimum_required(VERSION 2.8.11) + + set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH + "Path to LLVM source code. Not necessary if using an installed LLVM.") +@@ -36,6 +36,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + include(TableGen) + include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") + include(HandleLLVMOptions) ++ include(cotire) ++ set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + +@@ -234,6 +236,12 @@ macro(add_clang_library name) + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} + RUNTIME DESTINATION bin) + set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") ++ if (COMMAND cotire) ++ if (NOT "${name}" MATCHES "libclang") ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++ endif() ++ endif() + endmacro(add_clang_library) + + macro(add_clang_executable name) +diff -rupN cfe-3.3.src/tools/libclang/CMakeLists.txt cfe-3.3.src.cotire/tools/libclang/CMakeLists.txt +--- cfe-3.3.src/tools/libclang/CMakeLists.txt 2013-03-29 22:51:40.000000000 +0100 ++++ cfe-3.3.src.cotire/tools/libclang/CMakeLists.txt 2013-10-13 11:32:48.000000000 +0200 +@@ -114,3 +114,8 @@ if( NOT BUILD_SHARED_LIBS AND NOT WIN32 + PROPERTIES + OUTPUT_NAME "clang") + endif() ++ ++if (COMMAND cotire) ++ cotire(libclang) ++ cotire(${LIBCLANG_STATIC_TARGET_NAME}) ++endif() diff --git a/Patches/llvm-3.3.src.patch b/Patches/llvm-3.3.src.patch new file mode 100644 index 0000000..f1109f4 --- /dev/null +++ b/Patches/llvm-3.3.src.patch @@ -0,0 +1,128 @@ +diff -rupN llvm-3.3.src/CMakeLists.txt llvm-3.3.src.cotire/CMakeLists.txt +--- llvm-3.3.src/CMakeLists.txt 2013-05-06 18:23:07.000000000 +0200 ++++ llvm-3.3.src.cotire/CMakeLists.txt 2013-10-13 10:05:20.000000000 +0200 +@@ -1,7 +1,7 @@ + # See docs/CMake.html for instructions about how to build LLVM with CMake. + + project(LLVM) +-cmake_minimum_required(VERSION 2.8) ++cmake_minimum_required(VERSION 2.8.11) + + # Add path for custom modules + set(CMAKE_MODULE_PATH +@@ -21,6 +21,8 @@ if ( LLVM_USE_FOLDERS ) + endif() + + include(VersionFromVCS) ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + option(LLVM_APPEND_VC_REV + "Append the version control system revision id to LLVM version" OFF) +@@ -187,7 +189,7 @@ option(LLVM_USE_OPROFILE + # If enabled, verify we are on a platform that supports oprofile. + if( LLVM_USE_OPROFILE ) + if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) +- message(FATAL_ERROR "OProfile support is available on Linux only.") ++ message(FATAL_ERROR "OProfile support is available on Linux only.") + endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) + endif( LLVM_USE_OPROFILE ) + +diff -rupN llvm-3.3.src/cmake/modules/AddLLVM.cmake llvm-3.3.src.cotire/cmake/modules/AddLLVM.cmake +--- llvm-3.3.src/cmake/modules/AddLLVM.cmake 2013-04-21 11:04:59.000000000 +0200 ++++ llvm-3.3.src.cotire/cmake/modules/AddLLVM.cmake 2013-10-13 10:43:04.000000000 +0200 +@@ -34,6 +34,10 @@ macro(add_llvm_library name) + # property has been set to an empty value. + get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name}) + target_link_libraries(${name} ${lib_deps}) ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_library name) + + macro(add_llvm_loadable_module name) +@@ -69,6 +73,10 @@ ${name} ignored.") + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") +@@ -101,6 +109,10 @@ macro(add_llvm_tool name) + install(TARGETS ${name} RUNTIME DESTINATION bin) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Tools") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_tool name) + + +@@ -114,12 +126,20 @@ macro(add_llvm_example name) + install(TARGETS ${name} RUNTIME DESTINATION examples) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Examples") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_example name) + + + macro(add_llvm_utility name) + add_llvm_executable(${name} ${ARGN}) + set_target_properties(${name} PROPERTIES FOLDER "Utils") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_utility name) + + +@@ -198,6 +218,10 @@ function(add_unittest test_suite test_na + set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros") + endif () + set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endfunction() + + # This function provides an automatic way to 'configure'-like generate a file +diff -rupN llvm-3.3.src/include/llvm/Transforms/Utils/BlackList.h llvm-3.3.src.cotire/include/llvm/Transforms/Utils/BlackList.h +--- llvm-3.3.src/include/llvm/Transforms/Utils/BlackList.h 2013-04-11 15:20:00.000000000 +0200 ++++ llvm-3.3.src.cotire/include/llvm/Transforms/Utils/BlackList.h 2013-10-13 11:52:41.000000000 +0200 +@@ -30,6 +30,9 @@ + //===----------------------------------------------------------------------===// + // + ++#ifndef LLVM_TRANSFORMS_UTILS_BLACKLIST_H ++#define LLVM_TRANSFORMS_UTILS_BLACKLIST_H ++ + #include "llvm/ADT/StringMap.h" + + namespace llvm { +@@ -57,3 +60,5 @@ class BlackList { + }; + + } // namespace llvm ++ ++#endif +diff -rupN llvm-3.3.src/lib/Support/CMakeLists.txt llvm-3.3.src.cotire/lib/Support/CMakeLists.txt +--- llvm-3.3.src/lib/Support/CMakeLists.txt 2013-04-23 10:28:39.000000000 +0200 ++++ llvm-3.3.src.cotire/lib/Support/CMakeLists.txt 2013-10-13 10:25:45.000000000 +0200 +@@ -1,3 +1,7 @@ ++if (COMMAND cotire) ++ set_source_files_properties (IsInf.cpp IsNAN.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMSupport + APFloat.cpp + APInt.cpp diff --git a/README.md b/README.md index d155ca2..2a15ad7 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,14 @@ target, add another `target_link_libraries` call: cotire(MyExecutable) target_link_libraries(MyExecutable_unity ${MyExecutableLibraries}) +If CMake version 2.8.11 or later is used, it is possible to also inherit linked libraries from +the original target by setting the property `COTIRE_UNITY_LINK_LIBRARIES_INIT`: + + set_target_properties(MyExecutable PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY") + cotire(MyExecutable) + +See the [cotire manual][manual] for more information. + For Makefile based generators you can then invoke a unity build that produces the same output as the original target, but does so much faster by entering: @@ -135,4 +143,4 @@ known issues [EoUB]:http://leewinder.co.uk/blog/?p=394 [jom]:http://qt-project.org/wiki/jom [intel]:http://software.intel.com/en-us/c-compilers -[XGE]:http://www.incredibuild.com \ No newline at end of file +[XGE]:http://www.incredibuild.com From 845e0a4497f23bb5c0cd37e870d03cd29c2c0a54 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 12 Nov 2013 20:17:42 +0100 Subject: [PATCH 042/169] cotire 1.5.1 --- CMake/cotire.cmake | 10 +++++----- HISTORY.md | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index c17783b..a7d8a64 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.5.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.5.1") include(CMakeParseArguments) include(ProcessorCount) @@ -564,7 +564,7 @@ function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) math (EXPR _len "${_len} - 1") foreach (_index RANGE ${_index} ${_len}) list (GET _extraProperties ${_index} _value) - if ("${_value}" MATCHES "${_pattern}") + if (_value MATCHES "${_pattern}") list (APPEND _result "${_value}") else() break() @@ -793,7 +793,7 @@ macro (cotire_parse_line _line _headerFileVar _headerDepthVar) # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : characters - if ("${_line}" MATCHES ":( +)([^:]+:[^:]+)$") + if (_line MATCHES ":( +)([^:]+:[^:]+)$") # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) @@ -802,7 +802,7 @@ macro (cotire_parse_line _line _headerFileVar _headerDepthVar) set (${_headerDepthVar} 0) endif() else() - if ("${_line}" MATCHES "^(\\.+) (.*)$") + if (_line MATCHES "^(\\.+) (.*)$") # GCC like output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) if (IS_ABSOLUTE "${CMAKE_MATCH_2}") @@ -1077,7 +1077,7 @@ function (cotire_generate_unity_source _unityFile) list (APPEND _compileUndefinitions ${_option_POST_UNDEFS}) endif() foreach (_definition ${_compileDefinitions}) - if ("${_definition}" MATCHES "^([a-zA-Z0-9_]+)=(.+)$") + if (_definition MATCHES "^([a-zA-Z0-9_]+)=(.+)$") list (APPEND _contents "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}") list (INSERT _compileUndefinitions 0 "${CMAKE_MATCH_1}") else() diff --git a/HISTORY.md b/HISTORY.md index 7762958..19a87c8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.5.1 (2013-11-12) + +* fixed string quoting bugs. + ## 1.5.0 (2013-10-13) * CMake 2.8.12 compatibility fixes. From 862630a8b4c9608bc3216169e338db5df5699d52 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 17 Jan 2014 21:36:00 +0100 Subject: [PATCH 043/169] cotire 1.5.2 --- CMake/cotire.cmake | 38 +++++++++++--- HISTORY.md | 6 +++ Patches/clang-3.4.src.patch | 48 +++++++++++++++++ Patches/llvm-3.4.src.patch | 100 ++++++++++++++++++++++++++++++++++++ README.md | 4 +- license | 2 +- 6 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 Patches/clang-3.4.src.patch create mode 100644 Patches/llvm-3.4.src.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a7d8a64..1661cbb 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2013 Sascha Kratky +# Copyright 2012-2014 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.5.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.5.2") include(CMakeParseArguments) include(ProcessorCount) @@ -383,13 +383,19 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ foreach (_arch ${_architectures}) list (APPEND _compileFlags "-arch" "${_arch}") endforeach() - if (CMAKE_OSX_SYSROOT AND CMAKE_OSX_SYSROOT_DEFAULT AND CMAKE_${_language}_HAS_ISYSROOT) - if (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "${CMAKE_OSX_SYSROOT_DEFAULT}") + if (CMAKE_OSX_SYSROOT) + if (CMAKE_${_language}_SYSROOT_FLAG) + list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}") + else() list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}") endif() endif() - if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG) - list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") + if (CMAKE_OSX_DEPLOYMENT_TARGET) + if (CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG) + list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") + else() + list (APPEND _compileFlags "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() endif() endif() if (COTIRE_DEBUG AND _compileFlags) @@ -683,6 +689,24 @@ macro (cotire_add_includes_to_cmd _cmdVar _language) endforeach() endmacro() +macro (cotire_add_frameworks_to_cmd _cmdVar _language) + if (APPLE) + set (_frameWorkDirs "") + foreach (_include ${ARGN}) + if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") + get_filename_component(_frameWorkDir "${_include}" PATH) + list (APPEND _frameWorkDirs "${_frameWorkDir}") + endif() + endforeach() + if (_frameWorkDirs) + list (REMOVE_DUPLICATES _frameWorkDirs) + foreach (_frameWorkDir ${_frameWorkDirs}) + list (APPEND ${_cmdVar} "-F${_frameWorkDir}") + endforeach() + endif() + endif() +endmacro() + macro (cotire_add_compile_flags_to_cmd _cmdVar) foreach (_flag ${ARGN}) list (APPEND ${_cmdVar} "${_flag}") @@ -936,6 +960,7 @@ function (cotire_scan_includes _includesVar) cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning set (_existingSourceFiles "") @@ -1478,6 +1503,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) diff --git a/HISTORY.md b/HISTORY.md index 19a87c8..8279d2c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.5.2 (2014-01-17) + +* honor framework includes under OS X correctly. +* fix handling of OS X specific variables `CMAKE_OSX_SYSROOT` and `CMAKE_OSX_DEPLOYMENT_TARGET`. +* add new examples to the `Patches` directory. + ## 1.5.1 (2013-11-12) * fixed string quoting bugs. diff --git a/Patches/clang-3.4.src.patch b/Patches/clang-3.4.src.patch new file mode 100644 index 0000000..9e092e8 --- /dev/null +++ b/Patches/clang-3.4.src.patch @@ -0,0 +1,48 @@ +diff -rupN clang-3.4.src/CMakeLists.txt clang-3.4.src.cotire/CMakeLists.txt +--- clang-3.4.src/CMakeLists.txt 2013-11-06 09:37:50.000000000 +0100 ++++ clang-3.4.src.cotire/CMakeLists.txt 2014-01-17 20:33:42.000000000 +0100 +@@ -2,7 +2,7 @@ + # standalone project, using LLVM as an external library: + if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + project(Clang) +- cmake_minimum_required(VERSION 2.8) ++ cmake_minimum_required(VERSION 2.8.11) + + set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH + "Path to LLVM source code. Not necessary if using an installed LLVM.") +@@ -40,6 +40,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + include(TableGen) + include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") + include(HandleLLVMOptions) ++ include(cotire) ++ set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + +@@ -286,6 +288,12 @@ macro(add_clang_library name) + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") ++ if (COMMAND cotire) ++ if (NOT "${name}" MATCHES "libclang") ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++ endif() ++ endif() + endmacro(add_clang_library) + + macro(add_clang_executable name) +diff -rupN clang-3.4.src/tools/libclang/CMakeLists.txt clang-3.4.src.cotire/tools/libclang/CMakeLists.txt +--- clang-3.4.src/tools/libclang/CMakeLists.txt 2013-11-13 23:26:04.000000000 +0100 ++++ clang-3.4.src.cotire/tools/libclang/CMakeLists.txt 2014-01-17 20:37:53.000000000 +0100 +@@ -124,3 +124,10 @@ if( (NOT LLVM_ENABLE_PIC OR LIBCLANG_BUI + PROPERTIES + OUTPUT_NAME "clang") + endif() ++ ++if (COMMAND cotire) ++ cotire(libclang) ++ if (TARGET ${LIBCLANG_STATIC_TARGET_NAME}) ++ cotire(${LIBCLANG_STATIC_TARGET_NAME}) ++ endif() ++endif() diff --git a/Patches/llvm-3.4.src.patch b/Patches/llvm-3.4.src.patch new file mode 100644 index 0000000..631d1c7 --- /dev/null +++ b/Patches/llvm-3.4.src.patch @@ -0,0 +1,100 @@ +diff -rupN llvm-3.4.src/CMakeLists.txt llvm-3.4.src.cotire/CMakeLists.txt +--- llvm-3.4.src/CMakeLists.txt 2013-11-25 19:34:26.000000000 +0100 ++++ llvm-3.4.src.cotire/CMakeLists.txt 2014-01-06 20:25:12.000000000 +0100 +@@ -1,7 +1,7 @@ + # See docs/CMake.html for instructions about how to build LLVM with CMake. + + project(LLVM) +-cmake_minimum_required(VERSION 2.8) ++cmake_minimum_required(VERSION 2.8.12) + + # Add path for custom modules + set(CMAKE_MODULE_PATH +@@ -25,6 +25,8 @@ if ( LLVM_USE_FOLDERS ) + endif() + + include(VersionFromVCS) ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + option(LLVM_APPEND_VC_REV + "Append the version control system revision id to LLVM version" OFF) +diff -rupN llvm-3.4.src/cmake/modules/AddLLVM.cmake llvm-3.4.src.cotire/cmake/modules/AddLLVM.cmake +--- llvm-3.4.src/cmake/modules/AddLLVM.cmake 2013-08-27 21:25:01.000000000 +0200 ++++ llvm-3.4.src.cotire/cmake/modules/AddLLVM.cmake 2014-01-06 20:25:50.000000000 +0100 +@@ -41,6 +41,10 @@ macro(add_llvm_library name) + # property has been set to an empty value. + get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name}) + target_link_libraries(${name} ${lib_deps}) ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_library name) + + macro(add_llvm_loadable_module name) +@@ -78,6 +82,10 @@ ${name} ignored.") + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() + endif() ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") +@@ -119,6 +127,10 @@ macro(add_llvm_tool name) + endif() + endif() + set_target_properties(${name} PROPERTIES FOLDER "Tools") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_tool name) + + +@@ -132,12 +144,20 @@ macro(add_llvm_example name) + install(TARGETS ${name} RUNTIME DESTINATION examples) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Examples") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_example name) + + + macro(add_llvm_utility name) + add_llvm_executable(${name} ${ARGN}) + set_target_properties(${name} PROPERTIES FOLDER "Utils") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_utility name) + + +@@ -245,6 +265,10 @@ function(add_unittest test_suite test_na + set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros") + endif () + set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endfunction() + + # This function provides an automatic way to 'configure'-like generate a file +diff -rupN llvm-3.4.src/lib/Support/CMakeLists.txt llvm-3.4.src.cotire/lib/Support/CMakeLists.txt +--- llvm-3.4.src/lib/Support/CMakeLists.txt 2013-09-04 18:00:12.000000000 +0200 ++++ llvm-3.4.src.cotire/lib/Support/CMakeLists.txt 2014-01-06 20:27:36.000000000 +0100 +@@ -1,3 +1,7 @@ ++if (COMMAND cotire) ++ set_source_files_properties (IsInf.cpp IsNAN.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMSupport + APFloat.cpp + APInt.cpp diff --git a/README.md b/README.md index 2a15ad7..7b43e09 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ features -------- * Non-intrusive. Requires no source code modification and only minimal changes to CMake list files. -* Automatically generates a single compilation unit (aka unity source file) for a CMake target. +* Automatically generates a [single compilation unit][scu] (aka unity source file) for a CMake target. * Automatically generates a [prefix header][pfh] by tracking includes used by a CMake target. -* Automatically precompiles prefix header and applies resulting precompiled header to a CMake target. +* Automatically precompiles prefix header and applies resulting [precompiled header][pch] to a CMake target. * Alternatively, allows for using manually maintained unity source and prefix header files. * Supports C/C++ compilers Clang, GCC, Intel and Visual Studio C++. * Supports mixed language CMake targets. diff --git a/license b/license index 6c03be0..f199abe 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012-2013 Sascha Kratky +Copyright (c) 2012-2014 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From c1f6960db85ef7a9a2deac0ac086cc23eaed9ac6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 23 Feb 2014 11:08:03 +0100 Subject: [PATCH 044/169] add note on ccache usage to manual --- MANUAL.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MANUAL.md b/MANUAL.md index 2ff95e1..bdcb4f6 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -535,6 +535,15 @@ enabled in the following way upon configuring the project: $ export CXX="/usr/local/bin/ccache /usr/bin/g++" $ cmake .. +Note that with ccache in order for precompiled headers to work properly, it is necessary to set +the environment variable `CCACHE_SLOPPINESS` to `time_macros`. Otherwise the build process may +abort with the following error message: + + fatal error: file 'example_CXX_prefix.hxx' has been modified since the precompiled header + 'example_CXX_prefix.hxx.gch' was built + +Also see the [ccache manual][ccch_pch]. + ### applying cotire to object library targets CMake 2.8.8 introduced a new type of library target called [object library][objlib]. An object From 8b8cab8f2c339f40945c6e42dbe7a934a1b4d031 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 23 Feb 2014 11:09:55 +0100 Subject: [PATCH 045/169] add missing link to manual --- MANUAL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MANUAL.md b/MANUAL.md index bdcb4f6..82c1bd3 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -634,6 +634,7 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ +[ccch_pch]:http://ccache.samba.org/manual.html#_precompiled_headers [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders [gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake From 550c590ec91b78a0076831ea4c22dbc5c486b35c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 16 Mar 2014 14:44:54 +0100 Subject: [PATCH 046/169] cotire 1.6.0 --- CMake/cotire.cmake | 51 +++++++++++++++++++++++++++++++++++----------- HISTORY.md | 7 +++++++ MANUAL.md | 40 ++++++++++++++++++++---------------- 3 files changed, 69 insertions(+), 29 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 1661cbb..3b9104c 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.5.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.0") include(CMakeParseArguments) include(ProcessorCount) @@ -1146,8 +1146,16 @@ function (cotire_generate_prefix_header _prefixFile) return() endif() endif() + set (_prologue "") set (_epilogue "") - if (_option_COMPILER_ID MATCHES "Intel") + if (_option_COMPILER_ID MATCHES "Clang") + set (_prologue "#pragma clang system_header") + elseif (_option_COMPILER_ID MATCHES "GNU") + set (_prologue "#pragma GCC system_header") + elseif (_option_COMPILER_ID MATCHES "MSVC") + set (_prologue "#pragma warning(push, 0)") + set (_epilogue "#pragma warning(pop)") + elseif (_option_COMPILER_ID MATCHES "Intel") # Intel compiler requires hdrstop pragma to stop generating PCH file set (_epilogue "#pragma hdrstop") endif() @@ -1164,7 +1172,8 @@ function (cotire_generate_prefix_header _prefixFile) INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} UNPARSED_LINES _unparsedLines) - cotire_generate_unity_source("${_prefixFile}" EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) + cotire_generate_unity_source("${_prefixFile}" + PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) set (_unparsedLinesFile "${_prefixFile}.log") if (_unparsedLines) if (COTIRE_VERBOSE OR NOT _selectedHeaders) @@ -1291,6 +1300,7 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio endif() elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used + # -w disable all warnings # -x specify the source language # -c compile but do not link # -o place output in file @@ -1298,10 +1308,10 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (_xLanguage_CXX "c++-header") if (_flags) # append to list - list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + list (APPEND _flags "-w" "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string - set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + set (_flags "-w -x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1398,23 +1408,29 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used + # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) + get_filename_component(_prefixDir "${_prefixFile}" PATH) + get_filename_component(_prefixName "${_prefixFile}" NAME) if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-Winvalid-pch") + list (APPEND _flags "-Winvalid-pch" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") else() # return as a flag string - set (_flags "-include \"${_prefixFile}\" -Winvalid-pch") + set (_flags "-Winvalid-pch -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") endif() elseif (_compilerID MATCHES "Clang") # Clang options used # -include process include file as the first line of the primary source file # -Qunused-arguments don't emit warning for unused driver arguments + # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) + get_filename_component(_prefixDir "${_prefixFile}" PATH) + get_filename_component(_prefixName "${_prefixFile}" NAME) if (_flags) # append to list - list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") + list (APPEND _flags "-Qunused-arguments" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") else() # return as a flag string - set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + set (_flags "-Qunused-arguments -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1705,8 +1721,11 @@ function (cotire_make_pch_file_path _language _targetSourceDir _target _pchFileV if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # MSVC uses the extension .pch added to the prefix header base name set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE) - elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") - # GCC / Clang look for a precompiled header corresponding to the prefix header with the extension .gch appended + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") + # Clang looks for a precompiled header corresponding to the prefix header with the extension .pch appended + set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.pch" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") + # GCC looks for a precompiled header corresponding to the prefix header with the extension .gch appended set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel uses the extension .pchi added to the prefix header base name @@ -1768,6 +1787,14 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") + # Clang raises a fatal error if a file is not found during preprocessing + # thus we depend on target's generated source files for prefix header generation + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) + if (_generatedSources) + list (APPEND _dependencySources ${_generatedSources}) + endif() + endif() if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_language} ${_target} prefix header DEPENDS ${_dependencySources}") endif() @@ -2214,7 +2241,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() - if (_targetUsePCH AND "${_language}" STREQUAL "C" OR "${_language}" STREQUAL "CXX") + if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$") cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _disableMsg) if (_disableMsg) set (_targetUsePCH FALSE) diff --git a/HISTORY.md b/HISTORY.md index 8279d2c..49bfa00 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.6.0 (2014-03-16) + +* suppress compiler warnings from precompiled headers. +* fix Clang compatibility issue with prefix header generation. +* use file extension `.pch` for precompiled headers generated with Clang. +* manual updates. + ## 1.5.2 (2014-01-17) * honor framework includes under OS X correctly. diff --git a/MANUAL.md b/MANUAL.md index 82c1bd3..8f6d24d 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -117,7 +117,7 @@ It consists of preprocessor include directives for each of the target source fil are included in the same order that is used in the CMake `add_executable` or `add_library` call. Header files are omitted. -This is a unity source generated for the example project under Mac OS X: +This is a unity source generated for the example project under OS X: #ifdef __cplusplus #include "/Users/sakra/Documents/cotire/src/main.cpp" @@ -152,16 +152,19 @@ Generating the prefix header from the unity source is much faster than running e target source file through the preprocessor, because the coalesced unity source will make the preprocessor process most header files only once. -This is a prefix header produced for the example project with Visual Studio 2008 under Windows: +This is a prefix header produced for the example project with Visual Studio 2013 under Windows 7: + #pragma warning(push, 0) #ifdef __cplusplus - #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string" - #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\algorithm" - #include "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iostream" + #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\string" + #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\algorithm" + #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\iostream" #endif + #pragma warning(pop) -Generating the prefix file under Ubuntu Linux with GCC 4.6 yields the following result: +Generating the prefix file under Ubuntu 12.04 with GCC 4.6 yields the following result: + #pragma GCC system_header #ifdef __cplusplus #include "/usr/include/c++/4.6/string" #include "/usr/include/c++/4.6/algorithm" @@ -169,14 +172,17 @@ Generating the prefix file under Ubuntu Linux with GCC 4.6 yields the following #include "/usr/include/c++/4.6/iostream" #endif -Using Clang 3.1 under Mac OS X 10.7 this is the resulting prefix header: +Using Xcode 5.1 under OS X 10.9, this is the resulting prefix header: + #pragma clang system_header #ifdef __cplusplus - #include "/usr/include/c++/4.2.1/string" - #include "/usr/include/c++/4.2.1/iostream" - #include "/usr/include/c++/4.2.1/iterator" + #include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/string" + #include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iostream" #endif +Besides include directives, cotire also adds compiler specific pragmas to the generated prefix +header to suppress compiler warnings upon inclusion. + Cotire attempts to produce a minimal list of header files by omitting header files indirectly included by a header that is already part of the prefix header. Header files with nonstandard file extensions like `.inl`, `.inc` of `.ipp` are omitted by default. @@ -200,11 +206,11 @@ build rule and generates the precompiled header as described in the documentatio [GCC][gcc_pch] and [Clang][clang_pch]. Cotire then modifies the `COMPILE_FLAGS` property of the target to force the inclusion of the prefix header. -Visual Studio C++ and Intel C++ use a [different approach][msvc_pch] to pre-compiling. Both compilers -require a host source file to generate the precompiled header as a side effect of producing an object file. -Cotire modifies the `COMPILE_FLAGS` of the first target source file to [generate][msvc_pch_create] -the precompiled header and then modifies the `COMPILE_FLAGS` of the remaining target source files -to [include][msvc_pch_use] the generated precompiled header. +Visual Studio C++ and Intel C++ use a [different approach][msvc_pch] to pre-compiling. Both +compilers require a host source file to generate the precompiled header as a side effect of +producing an object file. Cotire modifies the `COMPILE_FLAGS` of the first target source file to +[generate][msvc_pch_create] the precompiled header and then modifies the `COMPILE_FLAGS` of the +remaining target source files to [include][msvc_pch_use] the generated precompiled header. For Xcode projects generated with CMake, cotire completely hands off the pre-compilation of the prefix header and the inclusion of the precompiled header to the IDE. Cotire attaches a @@ -621,8 +627,8 @@ files ending with .m and .mm are excluded by default through the initial default ### Intel C++ -Intel C++ support has only been tested with [Intel C++ Composer XE 2013 for Linux][icc_linux] and may -not work with other platforms or versions. +Intel C++ support has only been tested with [Intel C++ Composer XE 2013 for Linux][icc_linux] and +may not work with other platforms or versions. The Intel compiler may issue incorrect warnings #672 (the command line options do not match those used when precompiled header was created) or #673 (the initial sequence of preprocessing directives From 03f64d36a04b3ba2d83f61c87a8097851933be98 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 20 Apr 2014 13:56:22 +0200 Subject: [PATCH 047/169] cotire 1.6.1 --- CMake/cotire.cmake | 44 +++++++++++++++++++++++++++++--------------- HISTORY.md | 5 +++++ MANUAL.md | 1 + src/CMakeLists.txt | 15 +++++++++++++-- src/main.cpp | 2 +- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3b9104c..ddfe4bf 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.1") include(CMakeParseArguments) include(ProcessorCount) @@ -856,7 +856,7 @@ function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honore # remove duplicate lines to speed up parsing list (REMOVE_DUPLICATES _scanOutput) list (LENGTH _scanOutput _uniqueLen) - if (COTIRE_VERBOSE) + if (COTIRE_VERBOSE OR COTIRE_DEBUG) message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes") if (_ignoredExtensions) message (STATUS "Ignored extensions: ${_ignoredExtensions}") @@ -1408,29 +1408,36 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used - # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) - get_filename_component(_prefixDir "${_prefixFile}" PATH) - get_filename_component(_prefixName "${_prefixFile}" NAME) if (_flags) # append to list - list (APPEND _flags "-Winvalid-pch" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") + list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") else() # return as a flag string - set (_flags "-Winvalid-pch -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") + set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Clang") # Clang options used # -include process include file as the first line of the primary source file + # -include-pch include precompiled header file # -Qunused-arguments don't emit warning for unused driver arguments - # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) - get_filename_component(_prefixDir "${_prefixFile}" PATH) - get_filename_component(_prefixName "${_prefixFile}" NAME) - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") + if (_pchFile AND NOT CMAKE_${_language}_COMPILER MATCHES "ccache") + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include-pch" "${_pchFile}") + else() + # return as a flag string + set (_flags "-Qunused-arguments -include-pch \"${_pchFile}\"") + endif() else() - # return as a flag string - set (_flags "-Qunused-arguments -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") + # no precompiled header, force inclusion of prefix header + # ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1570,6 +1577,13 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() + if (CMAKE_${_language}_COMPILER MATCHES "ccache") + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to time_macros." + PARENT_SCOPE) + endif() + endif() if (APPLE) # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) if (CMAKE_CONFIGURATION_TYPES) diff --git a/HISTORY.md b/HISTORY.md index 49bfa00..caed07f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.6.1 (2014-04-20) + +* fixed bug where precompiled headers did not work with Clang (thanks to nh2 for reporting). +* when using ccache, require that environment variable `CCACHE_SLOPPINESS` is set to `time_macros`. + ## 1.6.0 (2014-03-16) * suppress compiler warnings from precompiled headers. diff --git a/MANUAL.md b/MANUAL.md index 8f6d24d..310057e 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -539,6 +539,7 @@ enabled in the following way upon configuring the project: $ export CC="/usr/local/bin/ccache /usr/bin/gcc" $ export CXX="/usr/local/bin/ccache /usr/bin/g++" + $ export CCACHE_SLOPPINESS=time_macros $ cmake .. Note that with ccache in order for precompiled headers to work properly, it is necessary to set diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce6c105..980541e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,8 +2,19 @@ add_executable(example main.cpp example.cpp log.cpp log.h example.h) -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall") +# enable warnings +if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set_target_properties(example PROPERTIES COMPILE_FLAGS "/Wall") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Weverything") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -Wextra") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") + if (UNIX) + set_target_properties(example PROPERTIES COMPILE_FLAGS "-w5") + elseif (WIN32) + set_target_properties(example PROPERTIES COMPILE_FLAGS "/W5") + endif() endif() cotire(example) diff --git a/src/main.cpp b/src/main.cpp index 6c7aadc..2ea1af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include "example.h" #include "log.h" -int main(int argc, char** argv) +int main() { std::string msg = example::get_message(); logging::info(msg); From 9480ee2deefb089e477f199f5fb65efe56e861c3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 9 Jun 2014 17:59:16 +0200 Subject: [PATCH 048/169] cotire 1.6.2 --- CMake/cotire.cmake | 126 ++++++++++++++++++++++++++++++++------------- CMakeLists.txt | 2 +- HISTORY.md | 9 ++++ MANUAL.md | 3 ++ src/CMakeLists.txt | 6 --- 5 files changed, 104 insertions(+), 42 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ddfe4bf..fbe3995 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.2") include(CMakeParseArguments) include(ProcessorCount) @@ -59,13 +59,15 @@ function (cotire_determine_compiler_version _language _versionPrefix) # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} + execute_process ( + COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" ${_versionPrefix}_VERSION "${_versionLine}") else() # assume GCC like command line interface string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process (COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" + execute_process ( + COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" OUTPUT_VARIABLE ${_versionPrefix}_VERSION RESULT_VARIABLE _result OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) @@ -366,6 +368,14 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (_targetOptions) set (_compileFlags "${_compileFlags} ${_targetOptions}") endif() + # interface compile options from linked library targets + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + foreach (_library ${_linkLibraries}) + get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) + if (_targetOptions) + set (_compileFlags "${_compileFlags} ${_targetOptions}") + endif() + endforeach() endif() if (UNIX) separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") @@ -424,8 +434,18 @@ function (cotire_get_target_include_directories _config _language _targetSourceD get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _dirs ${_targetDirs}) - list (REMOVE_DUPLICATES _dirs) endif() + # interface include directories from linked library targets + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + foreach (_library ${_linkLibraries}) + get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + endforeach() + endif() + if (dirs) + list (REMOVE_DUPLICATES _dirs) endif() list (LENGTH _includeDirs _projectInsertIndex) foreach (_dir ${_dirs}) @@ -513,6 +533,14 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() + # interface compile definitions from linked library targets + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + foreach (_library ${_linkLibraries}) + get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + endforeach() # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled set (_targetFlags "") @@ -984,7 +1012,8 @@ function (cotire_scan_includes _includesVar) # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() - execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + execute_process( + COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result OUTPUT_QUIET ERROR_VARIABLE _output) if (_result) message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.") @@ -1143,6 +1172,8 @@ function (cotire_generate_prefix_header _prefixFile) if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) if (_prefixFileIsUpToDate) + set (_unparsedLinesFile "${_prefixFile}.log") + file (WRITE "${_unparsedLinesFile}" "") return() endif() endif() @@ -1300,18 +1331,19 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio endif() elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used - # -w disable all warnings # -x specify the source language # -c compile but do not link # -o place output in file + # note that we cannot use -w to suppress all warnings upon pre-compiling, because turning off a warning may + # alter compile flags as a side effect (e.g., -Wwrite-string implies -fconst-strings) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") if (_flags) # append to list - list (APPEND _flags "-w" "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string - set (_flags "-w -x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1408,6 +1440,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used + # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") @@ -1420,24 +1453,13 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # -include process include file as the first line of the primary source file # -include-pch include precompiled header file # -Qunused-arguments don't emit warning for unused driver arguments - if (_pchFile AND NOT CMAKE_${_language}_COMPILER MATCHES "ccache") - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-include-pch" "${_pchFile}") - else() - # return as a flag string - set (_flags "-Qunused-arguments -include-pch \"${_pchFile}\"") - endif() + # note: ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") else() - # no precompiled header, force inclusion of prefix header - # ccache requires the -include flag to be used in order to process precompiled header correctly - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") - else() - # return as a flag string - set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") - endif() + # return as a flag string + set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1540,7 +1562,10 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() - execute_process(COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result) + execute_process( + COMMAND ${_cmd} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE _result) if (_result) message (FATAL_ERROR "Error ${_result} precompiling ${_prefixFile}.") endif() @@ -1618,6 +1643,8 @@ macro (cotire_setup_file_extension_variables) set (_unityFileExt_CXX ".cxx") set (_prefixFileExt_C ".h") set (_prefixFileExt_CXX ".hxx") + set (_prefixSourceFileExt_C ".c") + set (_prefixSourceFileExt_CXX ".cxx") endmacro() function (cotire_make_single_unity_source_file_path _language _target _unityFileVar) @@ -1691,6 +1718,16 @@ function (cotire_unity_to_prefix_file_path _language _target _unityFile _prefixF set (${_prefixFileVar} "${_prefixFile}" PARENT_SCOPE) endfunction() +function (cotire_prefix_header_to_source_file_path _language _prefixHeaderFile _prefixSourceFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _prefixSourceFileExt_${_language}) + set (${_prefixSourceFileVar} "" PARENT_SCOPE) + return() + endif() + string (REGEX REPLACE "${_prefixFileExt_${_language}}$" "${_prefixSourceFileExt_${_language}}" _prefixSourceFile "${_prefixHeaderFile}") + set (${_prefixSourceFileVar} "${_prefixSourceFile}" PARENT_SCOPE) +endfunction() + function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar) cotire_setup_file_extension_variables() if (NOT _language) @@ -1888,17 +1925,24 @@ function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _ # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + else() + set (_prefixSourceFile "${_prefixFile}") + endif() list (GET _sourceFiles 0 _hostFile) - list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixSourceFile}" "${_pchFile}" "${_hostFile}") file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixSourceFile} IMPLICIT_DEPENDS ${_language} ${_prefixSourceFile}") endif() set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) - add_custom_command(OUTPUT "${_pchFile}" + add_custom_command( + OUTPUT "${_pchFile}" COMMAND ${_cmds} - DEPENDS "${_prefixFile}" - IMPLICIT_DEPENDS ${_language} "${_prefixFile}" + DEPENDS "${_prefixSourceFile}" + IMPLICIT_DEPENDS ${_language} "${_prefixSourceFile}" WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) endif() @@ -1996,11 +2040,16 @@ function (cotire_setup_combine_command _language _sourceDir _targetScript _joine endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") - get_filename_component(_joinedFileName "${_joinedFileRelPath}" NAME_WE) - if (_language AND _joinedFileName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") + get_filename_component(_joinedFileBaseName "${_joinedFileRelPath}" NAME_WE) + get_filename_component(_joinedFileExt "${_joinedFileRelPath}" EXT) + if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") set (_comment "Generating ${_language} unity source ${_joinedFileRelPath}") - elseif (_language AND _joinedFileName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") - set (_comment "Generating ${_language} prefix header ${_joinedFileRelPath}") + elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$") + if (_joinedFileExt MATCHES "^\\.c") + set (_comment "Generating ${_language} prefix source ${_joinedFileRelPath}") + else() + set (_comment "Generating ${_language} prefix header ${_joinedFileRelPath}") + endif() else() set (_comment "Generating ${_joinedFileRelPath}") endif() @@ -2138,6 +2187,9 @@ function (cotire_setup_multi_prefix_generation_command _language _target _target ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) endif() + # create a prefix source file from prefix header + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" ${_cmdsVar} ${_prefixFile}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2381,7 +2433,11 @@ function (cotire_process_target_language _language _configurations _targetSource # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) + # create prefix header form user provided header files cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) + # create a prefix source file from prefix header + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixFile}) else() cotire_setup_multi_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) diff --git a/CMakeLists.txt b/CMakeLists.txt index a522c9a..eeb1372 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # cotire example project -cmake_minimum_required(VERSION 2.8.5) +cmake_minimum_required(VERSION 2.8.6) project (CotireExample) diff --git a/HISTORY.md b/HISTORY.md index caed07f..fa5fe62 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,12 @@ +## 1.6.2 (2014-06-09) + +* don't use `-w` flag for pre-compiling the prefix header, because it has unwanted side effects. +* correctly handle linked targets' `INTERFACE_COMPILE_OPTIONS`, `INTERFACE_INCLUDE_DIRECTORIES` + and `INTERFACE_COMPILE_DEFINITIONS` properties upon pre-compiling and prefix header generation. +* For Clang and GCC, pre-compile prefix header through indirect inclusion via a prefix source file, + to make both compilers honor the `system_header` pragma in the prefix header correctly. +* fix ccache incompatibility. + ## 1.6.1 (2014-04-20) * fixed bug where precompiled headers did not work with Clang (thanks to nh2 for reporting). diff --git a/MANUAL.md b/MANUAL.md index 310057e..d309edf 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -198,6 +198,9 @@ machines. It is automatically recreated by the build system if it goes missing. The generated prefix header can be applied to a different target added in the same source directory (see below). +Optionally, cotire may also create a prefix source file that consists of a single include directive +for the prefix header. This file is needed for pre-compiling the prefix header with Clang or GCC. + ### the precompiled header The precompiled header is produced from the generated prefix header by using the proprietary diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 980541e..deb2b79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,12 +9,6 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set_target_properties(example PROPERTIES COMPILE_FLAGS "-Weverything") elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -Wextra") -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") - if (UNIX) - set_target_properties(example PROPERTIES COMPILE_FLAGS "-w5") - elseif (WIN32) - set_target_properties(example PROPERTIES COMPILE_FLAGS "/W5") - endif() endif() cotire(example) From 9f6e5b0c73c0951a8acdf1bc8c4d7ffdaefc5a57 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 11 Jun 2014 22:02:56 +0200 Subject: [PATCH 049/169] cotire 1.6.3 --- CMake/cotire.cmake | 102 ++++++++++++++++++++++++++++++--------------- HISTORY.md | 5 +++ MANUAL.md | 5 ++- 3 files changed, 77 insertions(+), 35 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index fbe3995..0a55002 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.3") include(CMakeParseArguments) include(ProcessorCount) @@ -257,6 +257,24 @@ function (cotire_copy_set_properites _configurations _type _source _target) endforeach() endfunction() +function (cotire_get_target_link_libraries_for_usage_requirements _target _targetLinkLibrariesVar) + set (_targetLinkLibraries "") + get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) + while (_librariesToProcess) + # remove from head + list (GET _librariesToProcess 0 _library) + list (REMOVE_AT _librariesToProcess 0) + list (FIND _targetLinkLibraries ${_library} _index) + if (_index LESS 0) + list (APPEND _targetLinkLibraries ${_library}) + # process transitive libraries + get_target_property(_libraries ${_library} LINK_LIBRARIES) + list (APPEND _librariesToProcess ${_libraries}) + endif() + endwhile() + set (${_targetLinkLibrariesVar} ${_targetLinkLibraries} PARENT_SCOPE) +endfunction() + function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") set (_flagPrefix "[/-]") @@ -369,7 +387,7 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (_compileFlags "${_compileFlags} ${_targetOptions}") endif() # interface compile options from linked library targets - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) @@ -436,7 +454,7 @@ function (cotire_get_target_include_directories _config _language _targetSourceD list (APPEND _dirs ${_targetDirs}) endif() # interface include directories from linked library targets - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) if (_targetDirs) @@ -534,7 +552,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta list (APPEND _configDefinitions ${_definitions}) endif() # interface compile definitions from linked library targets - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) if (_definitions) @@ -1925,24 +1943,18 @@ function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _ # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) - if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") - # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma - cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) - else() - set (_prefixSourceFile "${_prefixFile}") - endif() list (GET _sourceFiles 0 _hostFile) - list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixSourceFile}" "${_pchFile}" "${_hostFile}") + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixSourceFile} IMPLICIT_DEPENDS ${_language} ${_prefixSourceFile}") + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") endif() set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) add_custom_command( OUTPUT "${_pchFile}" COMMAND ${_cmds} - DEPENDS "${_prefixSourceFile}" - IMPLICIT_DEPENDS ${_language} "${_prefixSourceFile}" + DEPENDS "${_prefixFile}" + IMPLICIT_DEPENDS ${_language} "${_prefixFile}" WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) endif() @@ -2040,8 +2052,8 @@ function (cotire_setup_combine_command _language _sourceDir _targetScript _joine endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") - get_filename_component(_joinedFileBaseName "${_joinedFileRelPath}" NAME_WE) - get_filename_component(_joinedFileExt "${_joinedFileRelPath}" EXT) + get_filename_component(_joinedFileBaseName "${_joinedFile}" NAME_WE) + get_filename_component(_joinedFileExt "${_joinedFile}" EXT) if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") set (_comment "Generating ${_language} unity source ${_joinedFileRelPath}") elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$") @@ -2153,7 +2165,7 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_single_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFile _cmdsVar) +function (cotire_setup_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFile _cmdsVar) set (_sourceFiles ${ARGN}) set (_dependencySources "") cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) @@ -2164,32 +2176,59 @@ function (cotire_setup_single_prefix_generation_command _language _target _targe message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_targetScript} ${_unityFile} ${_dependencySources}") endif() file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + get_filename_component(_prefixFileExt "${_prefixFile}" EXT) + if (_prefixFileExt MATCHES "^\\.c") + set (_comment "Generating ${_language} prefix source ${_prefixFileRelPath}") + else() + set (_comment "Generating ${_language} prefix header ${_prefixFileRelPath}") + endif() add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} DEPENDS "${_targetScript}" "${_unityFile}" ${_dependencySources} - COMMENT "Generating ${_language} prefix header ${_prefixFileRelPath}" + COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_multi_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) +function (cotire_setup_prefix_generation_from_unity_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) set (_sourceFiles ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + else() + set (_prefixSourceFile "${_prefixFile}") + endif() list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_single_prefix_generation_command( + cotire_setup_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" - "${_prefixFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) + "${_prefixSourceFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) else() - cotire_setup_single_prefix_generation_command( + cotire_setup_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" - "${_prefixFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) + "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) + endif() + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixSourceFile}) + endif() + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_prefix_generation_from_provided_command _language _target _targetSourceDir _targetScript _prefixFile _cmdsVar) + set (_prefixHeaderFiles ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + else() + set (_prefixSourceFile "${_prefixFile}") + endif() + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) endif() - # create a prefix source file from prefix header - cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" ${_cmdsVar} ${_prefixFile}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2433,13 +2472,10 @@ function (cotire_process_target_language _language _configurations _targetSource # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) - # create prefix header form user provided header files - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) - # create a prefix source file from prefix header - cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixFile}) + cotire_setup_prefix_generation_from_provided_command( + ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() - cotire_setup_multi_prefix_generation_command( + cotire_setup_prefix_generation_from_unity_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) @@ -2755,7 +2791,7 @@ function (cotire_target _target) endif() endfunction(cotire_target) -function(cotire_target_link_libraries _target) +function (cotire_target_link_libraries _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_unityTargetName}") get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) diff --git a/HISTORY.md b/HISTORY.md index fa5fe62..e273776 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.6.3 (2014-06-11) + +* correctly handle usage requirements for transitive link targets. +* use indirect inclusion for prefix header when using generator Xcode. + ## 1.6.2 (2014-06-09) * don't use `-w` flag for pre-compiling the prefix header, because it has unwanted side effects. diff --git a/MANUAL.md b/MANUAL.md index d309edf..16e6d5a 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -198,8 +198,9 @@ machines. It is automatically recreated by the build system if it goes missing. The generated prefix header can be applied to a different target added in the same source directory (see below). -Optionally, cotire may also create a prefix source file that consists of a single include directive -for the prefix header. This file is needed for pre-compiling the prefix header with Clang or GCC. +Optionally, cotire will also create a prefix source file that consists of a single include directive +for the prefix header. This file is needed for pre-compiling the prefix header with Clang or GCC +to make both compilers handle the `system_header` pragma correctly. ### the precompiled header From 7398cb28192bc56250fbd6102b5554345aa6de84 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Thu, 12 Jun 2014 02:10:11 -0700 Subject: [PATCH 050/169] Check if variable is set before adding to list --- CMake/cotire.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 0a55002..9be5619 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -269,7 +269,9 @@ function (cotire_get_target_link_libraries_for_usage_requirements _target _targe list (APPEND _targetLinkLibraries ${_library}) # process transitive libraries get_target_property(_libraries ${_library} LINK_LIBRARIES) - list (APPEND _librariesToProcess ${_libraries}) + if (_libraries) + list (APPEND _librariesToProcess ${_libraries}) + endif() endif() endwhile() set (${_targetLinkLibrariesVar} ${_targetLinkLibraries} PARENT_SCOPE) From 9816302c51f3bdcdcbeb7ef477728deb3a2f7a03 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Thu, 12 Jun 2014 02:11:02 -0700 Subject: [PATCH 051/169] Use (public) interface link libraries --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 9be5619..74e3e92 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -268,7 +268,7 @@ function (cotire_get_target_link_libraries_for_usage_requirements _target _targe if (_index LESS 0) list (APPEND _targetLinkLibraries ${_library}) # process transitive libraries - get_target_property(_libraries ${_library} LINK_LIBRARIES) + get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) if (_libraries) list (APPEND _librariesToProcess ${_libraries}) endif() From 64e710122b836161e4309f04ddddb01e8eacd60d Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 15 Jun 2014 09:38:45 +0200 Subject: [PATCH 052/169] Preserve system flag for includes when generating PCH If the compiler understands system include paths it exposes the necessary flag within the CMAKE_INCLUDE_SYSTEM_FLAG_${LANG} variable. System include paths for targets could be queried via the target property INTERFACE_SYSTEM_INCLUDE_DIRECTORIES. Here the system include paths are listed in addition of being available in the INTERFACE_INCLUDE_DIRECTORIES property. Note: Currently there is no way to query the SYSTEM flag for directory include properties. --- CMake/cotire.cmake | 54 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 74e3e92..990f277 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -434,8 +434,9 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() -function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar) +function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar _systemIncludeDirsVar) set (_includeDirs "") + set (_systemIncludeDirs "") # default include dirs if (CMAKE_INCLUDE_CURRENT_DIR) list (APPEND _includeDirs "${_targetBinaryDir}") @@ -455,6 +456,11 @@ function (cotire_get_target_include_directories _config _language _targetSourceD if (_targetDirs) list (APPEND _dirs ${_targetDirs}) endif() + get_target_property(_targetDirs ${_target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) + endif() + # interface include directories from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) @@ -462,6 +468,10 @@ function (cotire_get_target_include_directories _config _language _targetSourceD if (_targetDirs) list (APPEND _dirs ${_targetDirs}) endif() + get_target_property(_targetDirs ${_library} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) + endif() endforeach() endif() if (dirs) @@ -487,6 +497,7 @@ function (cotire_get_target_include_directories _config _language _targetSourceD endif() endforeach() list (REMOVE_DUPLICATES _includeDirs) + list (REMOVE_DUPLICATES _systemIncludeDirs) if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() @@ -494,6 +505,10 @@ function (cotire_get_target_include_directories _config _language _targetSourceD message (STATUS "Target ${_target} include dirs ${_includeDirs}") endif() set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE) + if (COTIRE_DEBUG AND _systemIncludeDirs) + message (STATUS "Target ${_target} system include dirs ${_systemIncludeDirs}") + endif() + set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE) endfunction() macro (cotire_make_C_identifier _identifierVar _str) @@ -726,13 +741,18 @@ macro (cotire_add_definitions_to_cmd _cmdVar _language) endforeach() endmacro() -macro (cotire_add_includes_to_cmd _cmdVar _language) - foreach (_include ${ARGN}) +macro (cotire_add_includes_to_cmd _cmdVar _language _includeSystemFlag _includesVar _systemIncludesVar) + foreach (_include ${${_includesVar}}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) list (APPEND ${_cmdVar} "/I${_include}") else() - list (APPEND ${_cmdVar} "-I${_include}") + list(FIND ${_systemIncludesVar} ${_include} _index) + if(_index GREATER -1 AND NOT "${_includeSystemFlag}" STREQUAL "") + list (APPEND ${_cmdVar} "${_includeSystemFlag} ${_include}") + else() + list (APPEND ${_cmdVar} "-I${_include}") + endif() endif() endforeach() endmacro() @@ -993,8 +1013,8 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") - set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION LANGUAGE UNPARSED_LINES) - set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE UNPARSED_LINES) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_LANGUAGE) @@ -1007,7 +1027,7 @@ function (cotire_scan_includes _includesVar) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning @@ -1185,9 +1205,9 @@ endfunction() function (cotire_generate_prefix_header _prefixFile) set(_options "") - set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION) + set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS - INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) @@ -1219,6 +1239,8 @@ function (cotire_generate_prefix_header _prefixFile) COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} COMPILE_FLAGS ${_option_COMPILE_FLAGS} INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES} + INCLUDE_SYSTEM_FLAG ${_option_INCLUDE_SYSTEM_FLAG} + SYSTEM_INCLUDE_DIRECTORIES ${_option_SYSTEM_INCLUDE_DIRECTORIES} IGNORE_PATH ${_option_IGNORE_PATH} INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} @@ -1555,8 +1577,8 @@ endfunction() function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) set(_options "") - set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION LANGUAGE) - set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES) + set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") @@ -1567,7 +1589,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" @@ -1890,11 +1912,12 @@ function (cotire_generate_target_script _language _configurations _targetSourceD get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) + set (COTIRE_INCLUDE_SYSTEM_FLAG ${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}) set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) cotire_get_target_include_directories( - "${_config}" "${_language}" "${_targetSourceDir}" "${_targetBinaryDir}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}) + "${_config}" "${_language}" "${_targetSourceDir}" "${_targetBinaryDir}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}) cotire_get_target_compile_definitions( "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) cotire_get_target_compiler_flags( @@ -2959,6 +2982,7 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() string (TOUPPER "${COTIRE_BUILD_TYPE}" _upperConfig) set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}}) + set (_systemIncludeDirs ${COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}}) set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}}) set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}}) # check if target has been cotired for actual build type COTIRE_BUILD_TYPE @@ -3011,7 +3035,9 @@ if (CMAKE_SCRIPT_MODE_FILE) IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" + INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} + SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) @@ -3031,7 +3057,9 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} + SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) From 63fe98d5089ffcaf1e5a3d8e107c01cd5b47925a Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 14 Jul 2014 20:16:12 +0200 Subject: [PATCH 053/169] cotire 1.6.4 --- CMake/cotire.cmake | 44 ++++++++++++++++++++++++++------------------ HISTORY.md | 6 ++++++ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 990f277..e72758c 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.3") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.4") include(CMakeParseArguments) include(ProcessorCount) @@ -268,9 +268,11 @@ function (cotire_get_target_link_libraries_for_usage_requirements _target _targe if (_index LESS 0) list (APPEND _targetLinkLibraries ${_library}) # process transitive libraries - get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) - if (_libraries) - list (APPEND _librariesToProcess ${_libraries}) + if (TARGET ${_library}) + get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) + if (_libraries) + list (APPEND _librariesToProcess ${_libraries}) + endif() endif() endif() endwhile() @@ -391,9 +393,11 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ # interface compile options from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) - get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) - if (_targetOptions) - set (_compileFlags "${_compileFlags} ${_targetOptions}") + if (TARGET ${_library}) + get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) + if (_targetOptions) + set (_compileFlags "${_compileFlags} ${_targetOptions}") + endif() endif() endforeach() endif() @@ -464,13 +468,15 @@ function (cotire_get_target_include_directories _config _language _targetSourceD # interface include directories from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) - get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) - if (_targetDirs) - list (APPEND _dirs ${_targetDirs}) - endif() - get_target_property(_targetDirs ${_library} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) - if (_targetDirs) - list (APPEND _systemIncludeDirs ${_targetDirs}) + if (TARGET ${_library}) + get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_library} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) + endif() endif() endforeach() endif() @@ -519,7 +525,7 @@ macro (cotire_make_C_identifier _identifierVar _str) endif() string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") else() - string (MAKE_C_IDENTIFIER "${_identifierVar}" "${_str}") + string (MAKE_C_IDENTIFIER "${_str}" "${_identifierVar}") endif() endmacro() @@ -571,9 +577,11 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta # interface compile definitions from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) - get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) - if (_definitions) - list (APPEND _configDefinitions ${_definitions}) + if (TARGET ${_library}) + get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() endif() endforeach() # parse additional compile definitions from target compile flags diff --git a/HISTORY.md b/HISTORY.md index e273776..f169be0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.6.4 (2014-07-14) + +* fix CMake 3.0 compatibility issues. +* preserve system flag for includes when generating PCH (thanks gjasny). +* fix bug with setting up `EXPORTS` symbol for shared libraries. + ## 1.6.3 (2014-06-11) * correctly handle usage requirements for transitive link targets. From c75d78779127236d484c5e50215689ebad13792e Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Tue, 15 Jul 2014 15:29:28 +0800 Subject: [PATCH 054/169] Check for empty architectures before setting -arch flag. --- CMake/cotire.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 990f277..dd7795a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -410,9 +410,11 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (NOT _architectures) get_target_property(_architectures ${_target} OSX_ARCHITECTURES) endif() - foreach (_arch ${_architectures}) - list (APPEND _compileFlags "-arch" "${_arch}") - endforeach() + if (_architectures) + foreach (_arch ${_architectures}) + list (APPEND _compileFlags "-arch" "${_arch}") + endforeach() + endif (_architectures) if (CMAKE_OSX_SYSROOT) if (CMAKE_${_language}_SYSROOT_FLAG) list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}") From b49d6caa3ae2b1111cb52755622e4e1337339ae2 Mon Sep 17 00:00:00 2001 From: dpantele Date: Thu, 24 Jul 2014 21:31:09 -0400 Subject: [PATCH 055/169] Update a link to problems with unity builds Lee Winder have moved hist blog to the new place, old link doesn't work now, but I believe I have found the correct one --- MANUAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANUAL.md b/MANUAL.md index 16e6d5a..d8641b9 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -652,7 +652,7 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx [msvc_pch_create]:http://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx [msvc_pch_use]:http://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx -[EoUB]:http://leewinder.co.uk/blog/?p=394 +[EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit [objlib]:http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library From d8a2560c310afb67edb3d5aed6f777da5913db81 Mon Sep 17 00:00:00 2001 From: Nicholas Hutchinson Date: Sun, 17 Aug 2014 12:21:11 +0100 Subject: [PATCH 056/169] Fix `-isystem` includes being incorrectly passed to execute_process() The external command was being invoked with arguments: ["clang", ..., "-isystem /foo/bar/baz", ...], which meant that the compiler treated the whitespace between the flag and the path as being part of the path itself. (i.e. it was looking for " /foo/bar/baz"). Fixed by passing the argument to execute_process() as '-isystem/foo/bar/baz'; I also needed to ensure we normalized the value of CMAKE_INCLUDE_SYSTEM_FLAG_, which itself contains trailing whitespace in some cases. --- CMake/cotire.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index cc6bbb4..50dc362 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -759,7 +759,7 @@ macro (cotire_add_includes_to_cmd _cmdVar _language _includeSystemFlag _includes else() list(FIND ${_systemIncludesVar} ${_include} _index) if(_index GREATER -1 AND NOT "${_includeSystemFlag}" STREQUAL "") - list (APPEND ${_cmdVar} "${_includeSystemFlag} ${_include}") + list (APPEND ${_cmdVar} "${_includeSystemFlag}${_include}") else() list (APPEND ${_cmdVar} "-I${_include}") endif() @@ -1922,7 +1922,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) - set (COTIRE_INCLUDE_SYSTEM_FLAG ${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}) + string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" COTIRE_INCLUDE_SYSTEM_FLAG) set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) From 4e000931f7d2e24294f542c61e6609ee6eaccd99 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 26 Aug 2014 16:03:30 +0200 Subject: [PATCH 057/169] cotire 1.6.5 --- CMake/cotire.cmake | 75 +++++++++++++++++++++++++++++----------------- HISTORY.md | 7 +++++ 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 50dc362..b00b0d4 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.4") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.5") include(CMakeParseArguments) include(ProcessorCount) @@ -418,7 +418,7 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ foreach (_arch ${_architectures}) list (APPEND _compileFlags "-arch" "${_arch}") endforeach() - endif (_architectures) + endif() if (CMAKE_OSX_SYSROOT) if (CMAKE_${_language}_SYSROOT_FLAG) list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}") @@ -757,9 +757,9 @@ macro (cotire_add_includes_to_cmd _cmdVar _language _includeSystemFlag _includes file (TO_NATIVE_PATH "${_include}" _include) list (APPEND ${_cmdVar} "/I${_include}") else() - list(FIND ${_systemIncludesVar} ${_include} _index) + list (FIND ${_systemIncludesVar} ${_include} _index) if(_index GREATER -1 AND NOT "${_includeSystemFlag}" STREQUAL "") - list (APPEND ${_cmdVar} "${_includeSystemFlag}${_include}") + list (APPEND ${_cmdVar} "${_includeSystemFlag}${_include}") else() list (APPEND ${_cmdVar} "-I${_include}") endif() @@ -1353,7 +1353,7 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags endif() endif() else() - message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() @@ -1456,7 +1456,7 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio endif() endif() else() - message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() @@ -1580,7 +1580,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV endif() endif() else() - message (FATAL_ERROR "Unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() @@ -1619,7 +1619,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result) if (_result) - message (FATAL_ERROR "Error ${_result} precompiling ${_prefixFile}.") + message (FATAL_ERROR "cotire: error ${_result} precompiling ${_prefixFile}.") endif() endfunction() @@ -1904,10 +1904,8 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() -function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar) +function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar _targetConfigScriptVar) set (COTIRE_TARGET_SOURCES ${ARGN}) - get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) - set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) # set up variables to be configured @@ -1940,6 +1938,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD # remove COTIRE_VERBOSE which is passed as a CMake define on command line list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) set (_contents "") + set (_contentsHasGeneratorExpressions FALSE) foreach (_var IN LISTS _matchVars ITEMS MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 @@ -1947,10 +1946,32 @@ function (cotire_generate_target_script _language _configurations _targetSourceD if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") set (_contents "${_contents}set (${_var} \"${_value}\")\n") + if (NOT _contentsHasGeneratorExpressions) + if ("${_value}" MATCHES "\\$<.*>") + set (_contentsHasGeneratorExpressions TRUE) + endif() + endif() endif() endforeach() + get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) + set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) + if (_contentsHasGeneratorExpressions) + # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time + if (NOT CMAKE_VERSION VERSION_LESS "2.8.12") + # the file(GENERATE ...) command requires cmake 2.8.12 or later + set (_configNameOrNoneGeneratorExpression "$<$:None>$<$>:$>") + set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") + file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") + else() + message (WARNING "cotire: generator expression used in target ${_target}. This requires CMake 2.8.12 or later.") + set (_targetCotireConfigScript "${_targetCotireScript}") + endif() + else() + set (_targetCotireConfigScript "${_targetCotireScript}") + endif() set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) + set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) endfunction() function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _targetScript _prefixFile _pchFile) @@ -2160,7 +2181,7 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who endif() endfunction() -function (cotire_setup_unity_generation_commands _language _targetSourceDir _target _targetScript _unityFiles _cmdsVar) +function (cotire_setup_unity_generation_commands _language _targetSourceDir _target _targetScript _targetConfigScript _unityFiles _cmdsVar) set (_dependencySources "") cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) foreach (_unityFile ${_unityFiles}) @@ -2179,7 +2200,7 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) - list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetScript}" "${_unityFile}") + list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}") if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript}") endif() @@ -2195,7 +2216,7 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) + cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetConfigScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2208,7 +2229,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" "${_unityFile}") set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_targetScript} ${_unityFile} ${_dependencySources}") + message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") endif() file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") get_filename_component(_prefixFileExt "${_prefixFile}" EXT) @@ -2220,7 +2241,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} - DEPENDS "${_targetScript}" "${_unityFile}" ${_dependencySources} + DEPENDS "${_unityFile}" ${_dependencySources} COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) @@ -2377,7 +2398,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER) get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE) if (_prefixHeader OR _unityBuildFile) - message (STATUS "Target ${_target} has already been cotired.") + message (STATUS "cotire: target ${_target} has already been cotired.") set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() @@ -2494,31 +2515,31 @@ function (cotire_process_target_language _language _configurations _targetSource set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources}) endif() cotire_generate_target_script( - ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript ${_unitySourceFiles}) + ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() endif() cotire_setup_unity_generation_commands( - ${_language} "${_targetSourceDir}" ${_target} "${_targetScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} "${_targetSourceDir}" ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) if (_prefixFile) # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) cotire_setup_prefix_generation_from_provided_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) + ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_prefix_generation_from_unity_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) if (_excludedSources) set (_wholeTarget FALSE) endif() @@ -2594,7 +2615,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") set (_unityTargetSubType "${CMAKE_MATCH_1}") else() - message (WARNING "Unknown target type ${_targetType}.") + message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.") return() endif() # determine unity target sources @@ -2765,7 +2786,7 @@ function (cotire_target _target) # trivial checks get_target_property(_imported ${_target} IMPORTED) if (_imported) - message (WARNING "Imported target ${_target} cannot be cotired.") + message (WARNING "cotire: imported target ${_target} cannot be cotired.") return() endif() # resolve alias @@ -2835,7 +2856,7 @@ function (cotire_target_link_libraries _target) endif() if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") if (CMAKE_VERSION VERSION_LESS "2.8.11") - message (WARNING "Unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") + message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") return() endif() get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) @@ -2945,7 +2966,7 @@ function (cotire) cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS} SOURCE_DIR "${_option_SOURCE_DIR}" BINARY_DIR "${_option_BINARY_DIR}") else() - message (WARNING "${_target} is not a target.") + message (WARNING "cotire: ${_target} is not a target.") endif() endforeach() foreach (_target ${_targets}) @@ -3097,7 +3118,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}") else() - message (FATAL_ERROR "Unknown cotire command \"${COTIRE_ARGV1}\".") + message (FATAL_ERROR "cotire: unknown command \"${COTIRE_ARGV1}\".") endif() else() diff --git a/HISTORY.md b/HISTORY.md index f169be0..2d7baac 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.6.5 (2014-08-26) + +* correctly handle generator expressions used in compile definitions, compile flags and include + directories (requires CMake 2.8.12 or newer). +* fix `-isystem` includes being incorrectly passed to `execute_process` (thanks nickhutchinson). +* make some error messages more verbose. + ## 1.6.4 (2014-07-14) * fix CMake 3.0 compatibility issues. From 3d6d933f65578e2805335f1a946b6a850f111031 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 21 Sep 2014 11:00:06 +0200 Subject: [PATCH 058/169] cotire 1.6.6 --- CMake/cotire.cmake | 60 +++++++++++++++++-------------- HISTORY.md | 8 +++++ MANUAL.md | 8 +++++ Patches/fsedit-qt5.patch | 74 ++++++++++++++++++++++++++++++++++++++ Patches/fseditor-1.0.patch | 68 +++++++++++++++++++++++++++++++++++ README.md | 2 +- 6 files changed, 192 insertions(+), 28 deletions(-) create mode 100644 Patches/fsedit-qt5.patch create mode 100644 Patches/fseditor-1.0.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index b00b0d4..d855c1d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.6") include(CMakeParseArguments) include(ProcessorCount) @@ -1890,8 +1890,8 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) - if (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") - # Clang raises a fatal error if a file is not found during preprocessing + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GCC and clang raise a fatal error if a file is not found during preprocessing # thus we depend on target's generated source files for prefix header generation cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) if (_generatedSources) @@ -2712,9 +2712,10 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) # copy interface stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_STRING + COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES - INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + INTERFACE_AUTOUIC_OPTIONS) # copy link stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH @@ -2727,7 +2728,8 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour NO_SONAME SOVERSION VERSION) # copy Qt stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - AUTOMOC AUTOMOC_MOC_OPTIONS) + AUTOMOC AUTOMOC_MOC_OPTIONS AUTOUIC AUTOUIC_OPTIONS AUTORCC AUTORCC_OPTIONS + AUTOGEN_TARGET_DEPENDS) # copy cmake stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) @@ -2847,6 +2849,24 @@ function (cotire_target _target) endif() endfunction(cotire_target) +function (cotire_map_libraries _strategy _mappedLibrariesVar) + set (_mappedLibraries "") + foreach (_library ${ARGN}) + if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") + get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_libraryUnityTargetName}") + list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + else() + list (APPEND _mappedLibraries "${_library}") + endif() + else() + list (APPEND _mappedLibraries "${_library}") + endif() + endforeach() + list (REMOVE_DUPLICATES _mappedLibraries) + set (${_mappedLibrariesVar} ${_mappedLibraries} PARENT_SCOPE) +endfunction() + function (cotire_target_link_libraries _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_unityTargetName}") @@ -2857,29 +2877,15 @@ function (cotire_target_link_libraries _target) if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") if (CMAKE_VERSION VERSION_LESS "2.8.11") message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") - return() - endif() - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) - if (_linkLibraries) + else() + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries} ${_interfaceLinkLibraries}) if (COTIRE_DEBUG) - message (STATUS "target ${_target} link libraries: ${_linkLibraries}") + message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") endif() - set (_unityTargetLibraries "") - foreach (_library ${_linkLibraries}) - if (TARGET "${_library}" AND "${_linkLibrariesStrategy}" MATCHES "COPY_UNITY") - get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) - if (TARGET "${_libraryUnityTargetName}") - list (APPEND _unityTargetLibraries "${_libraryUnityTargetName}") - else() - list (APPEND _unityTargetLibraries "${_library}") - endif() - else() - list (APPEND _unityTargetLibraries "${_library}") - endif() - endforeach() - set_property(TARGET ${_unityTargetName} APPEND PROPERTY LINK_LIBRARIES ${_unityTargetLibraries}) - if (COTIRE_DEBUG) - message (STATUS "set unity target ${_unityTargetName} link libraries: ${_unityTargetLibraries}") + if (_unityLinkLibraries) + target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) endif() endif() endif() diff --git a/HISTORY.md b/HISTORY.md index 2d7baac..55c3ea4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,11 @@ +## 1.6.6 (2014-09-21) + +* fix GCC issue with prefix header generation when source files are missing. +* fix bug where some target properties were not properly propagated to the generated unity target. +* use `target_link_libraries` to set up the unity target link libraries. +* add Qt4 and Qt5 examples to the `Patches` directory. +* documentation updates. + ## 1.6.5 (2014-08-26) * correctly handle generator expressions used in compile definitions, compile flags and include diff --git a/MANUAL.md b/MANUAL.md index d8641b9..b842f74 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -607,6 +607,12 @@ the property value from its enclosing directory. To make all targets in the proj ... set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") +### using cotire with Qt + +Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build system. The `Patches` +directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based variants of the +*FSEditor* sample Qt application. + cotire usage restrictions ------------------------- @@ -647,6 +653,8 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [ccch]:http://ccache.samba.org/ [ccch_pch]:http://ccache.samba.org/manual.html#_precompiled_headers [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders +[fsedit_qt4]:http://www.vikingsoft.eu/fseditor.html +[fsedit_qt5]:https://github.com/joonhwan/fsedit-qt5 [gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx diff --git a/Patches/fsedit-qt5.patch b/Patches/fsedit-qt5.patch new file mode 100644 index 0000000..c76aeab --- /dev/null +++ b/Patches/fsedit-qt5.patch @@ -0,0 +1,74 @@ +diff -rupN fsedit-qt5-master/CMakeLists.txt fsedit-qt5-cotire/CMakeLists.txt +--- fsedit-qt5-master/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/CMakeLists.txt 2014-08-28 17:59:58.000000000 +0200 +@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8 FATAL + cmake_policy(SET CMP0020 NEW) + project(FSEditor) + ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") ++ + include(InstallRequiredSystemLibraries) + + set(VERSION_MAJOR 1) +diff -rupN fsedit-qt5-master/source/application/CMakeLists.txt fsedit-qt5-cotire/source/application/CMakeLists.txt +--- fsedit-qt5-master/source/application/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/application/CMakeLists.txt 2014-08-28 16:48:42.000000000 +0200 +@@ -20,3 +20,7 @@ install(TARGETS fseditor DESTINATION bin + + include(tr_sources) + add_tr_sources(${sources}) ++ ++if (COMMAND cotire) ++ cotire(fseditor) ++endif() +diff -rupN fsedit-qt5-master/source/libfstest/CMakeLists.txt fsedit-qt5-cotire/source/libfstest/CMakeLists.txt +--- fsedit-qt5-master/source/libfstest/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libfstest/CMakeLists.txt 2014-08-28 16:49:11.000000000 +0200 +@@ -3,8 +3,12 @@ + + add_library(fstest STATIC fstest.h fstest.cpp) + target_link_libraries(fstest +- Qt5::Widgets # ${QT_LIBRARIES} ++ Qt5::Widgets Qt5::Test # ${QT_LIBRARIES} + ) + set_target_properties(fstest + PROPERTIES PROJECT_LABEL "libfstest" + ) ++ ++if (COMMAND cotire) ++ cotire(fstest) ++endif() +diff -rupN fsedit-qt5-master/source/libmodel/CMakeLists.txt fsedit-qt5-cotire/source/libmodel/CMakeLists.txt +--- fsedit-qt5-master/source/libmodel/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libmodel/CMakeLists.txt 2014-08-28 16:49:18.000000000 +0200 +@@ -37,3 +37,7 @@ fstest(test_libmodel LibModel) + + include(tr_sources) + add_tr_sources(${sources} ${headers} ${moc_headers}) ++ ++if (COMMAND cotire) ++ cotire(model) ++endif() +diff -rupN fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt +--- fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt 2014-08-28 16:49:25.000000000 +0200 +@@ -21,3 +21,7 @@ target_link_libraries(modelcommands + + include(tr_sources) + add_tr_sources(${sources} ${headers}) ++ ++if (COMMAND cotire) ++ cotire(modelcommands) ++endif() +diff -rupN fsedit-qt5-master/source/libui/CMakeLists.txt fsedit-qt5-cotire/source/libui/CMakeLists.txt +--- fsedit-qt5-master/source/libui/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libui/CMakeLists.txt 2014-08-28 12:03:28.000000000 +0200 +@@ -48,3 +48,7 @@ target_link_libraries(ui + + include(tr_sources) + add_tr_sources(${sources} ${headers} ${moc_headers} ${forms}) ++ ++if (COMMAND cotire) ++ cotire(ui) ++endif() diff --git a/Patches/fseditor-1.0.patch b/Patches/fseditor-1.0.patch new file mode 100644 index 0000000..32598b0 --- /dev/null +++ b/Patches/fseditor-1.0.patch @@ -0,0 +1,68 @@ +diff -rupN fseditor-1.0/CMakeLists.txt fseditor-1.0.cotire/CMakeLists.txt +--- fseditor-1.0/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/CMakeLists.txt 2014-08-28 18:28:39.000000000 +0200 +@@ -1,6 +1,9 @@ + CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + PROJECT(FSEditor) + ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") ++ + INCLUDE(InstallRequiredSystemLibraries) + + SET(VERSION_MAJOR 1) +diff -rupN fseditor-1.0/source/application/CMakeLists.txt fseditor-1.0.cotire/source/application/CMakeLists.txt +--- fseditor-1.0/source/application/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/application/CMakeLists.txt 2014-08-28 18:24:56.000000000 +0200 +@@ -17,3 +17,7 @@ INSTALL(TARGETS fseditor DESTINATION bin + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources}) ++ ++if (COMMAND cotire) ++ cotire(fseditor) ++endif() +diff -rupN fseditor-1.0/source/libfstest/CMakeLists.txt fseditor-1.0.cotire/source/libfstest/CMakeLists.txt +--- fseditor-1.0/source/libfstest/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libfstest/CMakeLists.txt 2014-08-28 18:25:41.000000000 +0200 +@@ -3,3 +3,7 @@ INCLUDE(${QT_USE_FILE}) + + ADD_LIBRARY(fstest STATIC fstest.h fstest.cpp) + SET_TARGET_PROPERTIES(fstest PROPERTIES PROJECT_LABEL "libfstest") ++ ++if (COMMAND cotire) ++ cotire(fstest) ++endif() +diff -rupN fseditor-1.0/source/libmodel/CMakeLists.txt fseditor-1.0.cotire/source/libmodel/CMakeLists.txt +--- fseditor-1.0/source/libmodel/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libmodel/CMakeLists.txt 2013-10-06 20:05:06.000000000 +0200 +@@ -34,3 +34,7 @@ FSTEST(test_libmodel LibModel) + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers} ${moc_headers}) ++ ++if (COMMAND cotire) ++ cotire(model) ++endif() +diff -rupN fseditor-1.0/source/libmodelcommands/CMakeLists.txt fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt +--- fseditor-1.0/source/libmodelcommands/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt 2013-10-06 20:05:11.000000000 +0200 +@@ -18,3 +18,7 @@ TARGET_LINK_LIBRARIES(modelcommands mode + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers}) ++ ++if (COMMAND cotire) ++ cotire(modelcommands) ++endif() +diff -rupN fseditor-1.0/source/libui/CMakeLists.txt fseditor-1.0.cotire/source/libui/CMakeLists.txt +--- fseditor-1.0/source/libui/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libui/CMakeLists.txt 2013-10-06 20:05:18.000000000 +0200 +@@ -44,3 +44,7 @@ TARGET_LINK_LIBRARIES(ui model modelcomm + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers} ${moc_headers} ${forms}) ++ ++if (COMMAND cotire) ++ cotire(ui) ++endif() diff --git a/README.md b/README.md index 7b43e09..69a67d2 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ known issues [vslstd]:http://msdn.microsoft.com/vstudio/ [xcdt]:http://developer.apple.com/tools/xcode/ [PCHH]:http://gcc.gnu.org/wiki/PCHHaters -[EoUB]:http://leewinder.co.uk/blog/?p=394 +[EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [jom]:http://qt-project.org/wiki/jom [intel]:http://software.intel.com/en-us/c-compilers [XGE]:http://www.incredibuild.com From 9d91facfdd376e771536967d6a43a3aa4790bc45 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 22 Sep 2014 08:57:50 +0200 Subject: [PATCH 059/169] add link to blog --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 69a67d2..7b8dead 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,8 @@ modifications, because they [break][EoUB] the use of some C and C++ language fea Generally, modern C++ code which makes heavy use of header-only libraries will profit the most from cotiring. +This [blog post][shrp] discusses speedup results obtained for real-world projects. + known issues ------------ @@ -144,3 +146,4 @@ known issues [jom]:http://qt-project.org/wiki/jom [intel]:http://software.intel.com/en-us/c-compilers [XGE]:http://www.incredibuild.com +[shrp]:http://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html From 880b748f37e61ae0f02cfc94d579e36aa876529c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 21 Dec 2014 20:42:00 +0100 Subject: [PATCH 060/169] cotire 1.6.7 --- CMake/cotire.cmake | 202 ++++++++++++++++++++++++------------ HISTORY.md | 11 ++ MANUAL.md | 64 +++++++++++- Patches/clang-3.5.src.patch | 39 +++++++ Patches/llvm-3.5.src.patch | 99 ++++++++++++++++++ README.md | 4 +- 6 files changed, 350 insertions(+), 69 deletions(-) create mode 100644 Patches/clang-3.5.src.patch create mode 100644 Patches/llvm-3.5.src.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index d855c1d..dd139e0 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,8 +44,15 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(POP) endif() +if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") + # include TARGET_OBJECTS expressions in a target's SOURCES property + cmake_policy(SET CMP0051 NEW) + # only interpret if() arguments as variables or keywords when unquoted + cmake_policy(SET CMP0054 NEW) +endif() + set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.6") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.7") include(CMakeParseArguments) include(ProcessorCount) @@ -85,6 +92,22 @@ function (cotire_determine_compiler_version _language _versionPrefix) endif() endfunction() +function (cotire_get_configuration_types _configsVar) + set (_configs "") + if (CMAKE_CONFIGURATION_TYPES) + list (APPEND _configs ${CMAKE_CONFIGURATION_TYPES}) + endif() + if (CMAKE_BUILD_TYPE) + list (APPEND _configs "${CMAKE_BUILD_TYPE}") + endif() + if (_configs) + list (REMOVE_DUPLICATES _configs) + set (${_configsVar} ${_configs} PARENT_SCOPE) + else() + set (${_configsVar} "None" PARENT_SCOPE) + endif() +endfunction() + function (cotire_get_source_file_extension _sourceFile _extVar) # get_filename_component returns extension from first occurrence of . in file name # this function computes the extension from last occurrence of . in file name @@ -135,7 +158,15 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") endif() - foreach (_sourceFile ${ARGN}) + if (CMAKE_VERSION VERSION_LESS "3.1.0") + set (_allSourceFiles ${ARGN}) + else() + # as of CMake 3.1 target sources may contain generator expressions + # since we cannot obtain required property information about source files added + # through generator expressions at configure time, we filter them out + string (GENEX_STRIP "${ARGN}" _allSourceFiles) + endif() + foreach (_sourceFile ${_allSourceFiles}) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) @@ -466,7 +497,6 @@ function (cotire_get_target_include_directories _config _language _targetSourceD if (_targetDirs) list (APPEND _systemIncludeDirs ${_targetDirs}) endif() - # interface include directories from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) @@ -1124,7 +1154,7 @@ function (cotire_generate_unity_source _unityFile) set(_options "") set(_oneValueArgs LANGUAGE) set(_multiValueArgs - DEPENDS SOURCES_COMPILE_DEFINITIONS + DEPENDS SOURCE_LOCATIONS SOURCES_COMPILE_DEFINITIONS PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) @@ -1158,6 +1188,7 @@ function (cotire_generate_unity_source _unityFile) endif() endif() set (_compileUndefinitions "") + set (_index 0) foreach (_sourceFile ${_sourceFiles}) cotire_get_source_compile_definitions( "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions @@ -1189,11 +1220,18 @@ function (cotire_generate_unity_source _unityFile) list (INSERT _compileUndefinitions 0 "${_definition}") endif() endforeach() - get_filename_component(_sourceFile "${_sourceFile}" ABSOLUTE) + if (_option_SOURCE_LOCATIONS) + # use explicitly provided source file location + list (GET _option_SOURCE_LOCATIONS ${_index} _sourceFileLocation) + else() + # use absolute path as source file location + get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE) + endif() if (WIN32) - file (TO_NATIVE_PATH "${_sourceFile}" _sourceFile) + file (TO_NATIVE_PATH "${_sourceFileLocation}" _sourceFileLocation) endif() - list (APPEND _contents "#include \"${_sourceFile}\"") + list (APPEND _contents "#include \"${_sourceFileLocation}\"") + math (EXPR _index "${_index} + 1") endforeach() if (_compileUndefinitions) cotire_append_undefs(_contents ${_compileUndefinitions}) @@ -1655,21 +1693,15 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() if (CMAKE_${_language}_COMPILER MATCHES "ccache") - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") set (${_msgVar} - "ccache requires the environment variable CCACHE_SLOPPINESS to be set to time_macros." + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." PARENT_SCOPE) endif() endif() if (APPLE) # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) - if (CMAKE_CONFIGURATION_TYPES) - set (_configs ${CMAKE_CONFIGURATION_TYPES}) - elseif (CMAKE_BUILD_TYPE) - set (_configs ${CMAKE_BUILD_TYPE}) - else() - set (_configs "None") - endif() + cotire_get_configuration_types(_configs) foreach (_config ${_configs}) set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) @@ -1906,6 +1938,7 @@ endfunction() function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar _targetConfigScriptVar) set (COTIRE_TARGET_SOURCES ${ARGN}) + cotire_get_source_file_property_values(COTIRE_TARGET_SOURCE_LOCATIONS LOCATION ${COTIRE_TARGET_SOURCES}) cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) # set up variables to be configured @@ -1940,7 +1973,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD set (_contents "") set (_contentsHasGeneratorExpressions FALSE) foreach (_var IN LISTS _matchVars ITEMS - MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES + XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) @@ -2169,13 +2202,15 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who # see cotire_setup_pch_file_inclusion if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) - get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) - set (_flags "") - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - cotire_add_prefix_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" - "${_prefixFile}" "${_pchFile}" _flags) - set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + if (_prefixFile) + set (_flags "") + cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + endif() endif() endif() endif() @@ -2187,13 +2222,19 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar foreach (_unityFile ${_unityFiles}) file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) - # set up compiled unity source dependencies + # set up compiled unity source dependencies via OBJECT_DEPENDS # this ensures that missing source files are generated before the unity file is compiled if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}") endif() if (_dependencySources) - set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) + # the OBJECT_DEPENDS property requires a list of full paths + set (_objectDependsPaths "") + foreach (_sourceFile ${_dependencySources}) + get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION) + list (APPEND _objectDependsPaths "${_sourceLocation}") + endforeach() + set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths}) endif() if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel @@ -2201,13 +2242,19 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar endif() cotire_set_cmd_to_prologue(_unityCmd) list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}") + if (CMAKE_VERSION VERSION_LESS "3.1.0") + set (_unityCmdDepends "${_targetScript}") + else() + # CMake 3.1.0 supports generator expressions in arguments to DEPENDS + set (_unityCmdDepends "${_targetConfigScript}") + endif() if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript}") + message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}") endif() add_custom_command( OUTPUT "${_unityFile}" COMMAND ${_unityCmd} - DEPENDS "${_targetScript}" + DEPENDS ${_unityCmdDepends} COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) @@ -2383,12 +2430,13 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) endfunction() -function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar) +function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar _wholeTargetVar) set (_languages ${ARGN}) set (_allSourceFiles "") set (_allExcludedSourceFiles "") set (_allCotiredSourceFiles "") set (_targetLanguages "") + set (_pchEligibleTargetLanguages "") get_target_property(_targetType ${_target} TYPE) get_target_property(_targetSourceFiles ${_target} SOURCES) get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) @@ -2418,6 +2466,10 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag if (_sourceFiles) list (APPEND _allSourceFiles ${_sourceFiles}) endif() + list (LENGTH _sourceFiles _numberOfSources) + if (NOT _numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + list (APPEND _pchEligibleTargetLanguages ${_language}) + endif() if (_excludedSources) list (APPEND _allExcludedSourceFiles ${_excludedSources}) endif() @@ -2433,11 +2485,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag set (_targetAddSCU FALSE) endif() if (_targetUsePCH) - list (LENGTH _allSourceFiles _numberOfSources) - if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) - set (_disableMsg "Too few applicable sources.") - set (_targetUsePCH FALSE) - elseif (_allCotiredSourceFiles) + if (_allCotiredSourceFiles) cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles}) list (REMOVE_DUPLICATES _cotireTargets) string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}") @@ -2446,6 +2494,9 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.") set (_targetMsgLevel SEND_ERROR) set (_targetUsePCH FALSE) + elseif (NOT _pchEligibleTargetLanguages) + set (_disableMsg "Too few applicable sources.") + set (_targetUsePCH FALSE) elseif (XCODE AND _allExcludedSourceFiles) # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target set (_disableMsg "Exclusion of source files not supported for generator Xcode.") @@ -2470,6 +2521,12 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag message (${_targetMsgLevel} "${_targetMsg}") endif() endif() + list (LENGTH _targetLanguages _numberOfLanguages) + if (_numberOfLanguages GREATER 1 OR _allExcludedSourceFiles) + set (${_wholeTargetVar} FALSE PARENT_SCOPE) + else() + set (${_wholeTargetVar} TRUE PARENT_SCOPE) + endif() set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) endfunction() @@ -2497,7 +2554,7 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) endfunction() -function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTargetVar _cmdsVar) +function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTarget _cmdsVar) set (${_cmdsVar} "" PARENT_SCOPE) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_sourceFiles "") @@ -2507,7 +2564,6 @@ function (cotire_process_target_language _language _configurations _targetSource if (NOT _sourceFiles AND NOT _cotiredSources) return() endif() - set (_wholeTarget ${${_wholeTargetVar}}) set (_cmds "") # check for user provided unity source file list get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT) @@ -2534,22 +2590,24 @@ function (cotire_process_target_language _language _configurations _targetSource cotire_setup_prefix_generation_from_unity_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() - get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + # check if selected language has enough sources at all + list (LENGTH _sourceFiles _numberOfSources) + if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + set (_targetUsePCH FALSE) + else() + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + endif() if (_targetUsePCH) cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) - if (_excludedSources) - set (_wholeTarget FALSE) - endif() cotire_setup_pch_file_inclusion( ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) endif() elseif (_prefixHeaderFiles) - # user provided prefix header must be included - cotire_setup_prefix_file_inclusion( - ${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) + # user provided prefix header must be included unconditionally + cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) endif() endif() # mark target as cotired for language @@ -2560,7 +2618,6 @@ function (cotire_process_target_language _language _configurations _targetSource set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}") endif() endif() - set (${_wholeTargetVar} ${_wholeTarget} PARENT_SCOPE) set (${_cmdsVar} ${_cmds} PARENT_SCOPE) endfunction() @@ -2777,13 +2834,7 @@ function (cotire_target _target) get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) endif() if (NOT _option_CONFIGURATIONS) - if (CMAKE_CONFIGURATION_TYPES) - set (_option_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) - elseif (CMAKE_BUILD_TYPE) - set (_option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}") - else() - set (_option_CONFIGURATIONS "None") - endif() + cotire_get_configuration_types(_option_CONFIGURATIONS) endif() # trivial checks get_target_property(_imported ${_target} IMPORTED) @@ -2816,20 +2867,14 @@ function (cotire_target _target) endif() endif() # choose languages that apply to the target - cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages ${_option_LANGUAGES}) + cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) if (NOT _targetLanguages) return() endif() - list (LENGTH _targetLanguages _numberOfLanguages) - if (_numberOfLanguages GREATER 1) - set (_wholeTarget FALSE) - else() - set (_wholeTarget TRUE) - endif() set (_cmds "") foreach (_language ${_targetLanguages}) cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" - "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} _wholeTarget _cmd) + "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} ${_wholeTarget} _cmd) if (_cmd) list (APPEND _cmds ${_cmd}) endif() @@ -2853,6 +2898,7 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) set (_mappedLibraries "") foreach (_library ${ARGN}) if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") + # use target's corresponding unity target, if available get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_libraryUnityTargetName}") list (APPEND _mappedLibraries "${_libraryUnityTargetName}") @@ -2878,9 +2924,16 @@ function (cotire_target_link_libraries _target) if (CMAKE_VERSION VERSION_LESS "2.8.11") message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") else() + set (_unityLinkLibraries "") get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + if (_linkLibraries) + list (APPEND _unityLinkLibraries ${_linkLibraries}) + endif() get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) - cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries} ${_interfaceLinkLibraries}) + if (_interfaceLinkLibraries) + list (APPEND _unityLinkLibraries ${_interfaceLinkLibraries}) + endif() + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_unityLinkLibraries}) if (COTIRE_DEBUG) message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") endif() @@ -3026,12 +3079,14 @@ if (CMAKE_SCRIPT_MODE_FILE) list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) if (_index GREATER -1) set (_sources ${COTIRE_TARGET_SOURCES}) + set (_sourceLocations ${COTIRE_TARGET_SOURCE_LOCATIONS}) set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) else() if (COTIRE_DEBUG) message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") endif() set (_sources "") + set (_sourceLocations "") set (_sourcesDefinitions "") endif() set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) @@ -3041,19 +3096,37 @@ if (CMAKE_SCRIPT_MODE_FILE) if ("${COTIRE_ARGV1}" STREQUAL "unity") + if (XCODE) + # executing pre-build action under Xcode, check dependency on target script + set (_dependsOption DEPENDS "${COTIRE_ARGV2}") + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) + cotire_generate_unity_source( "${COTIRE_ARGV3}" ${_sources} LANGUAGE "${COTIRE_TARGET_LANGUAGE}" - DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" + SOURCE_LOCATIONS ${_sourceLocations} SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} PRE_UNDEFS ${_targetPreUndefs} POST_UNDEFS ${_targetPostUndefs} SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} - SOURCES_POST_UNDEFS ${_sourcesPostUndefs}) + SOURCES_POST_UNDEFS ${_sourcesPostUndefs} + ${_dependsOption}) elseif ("${COTIRE_ARGV1}" STREQUAL "prefix") + if (XCODE) + # executing pre-build action under Xcode, check dependency on unity file and prefix dependencies + set (_dependsOption DEPENDS "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS}) + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + set (_files "") foreach (_index RANGE 4 ${COTIRE_ARGC}) if (COTIRE_ARGV${_index}) @@ -3068,7 +3141,6 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" - DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS} IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" @@ -3076,7 +3148,8 @@ if (CMAKE_SCRIPT_MODE_FILE) INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} - COMPILE_FLAGS ${_compileFlags}) + COMPILE_FLAGS ${_compileFlags} + ${_dependsOption}) elseif ("${COTIRE_ARGV1}" STREQUAL "precompile") @@ -3113,6 +3186,7 @@ if (CMAKE_SCRIPT_MODE_FILE) list (APPEND _files "${COTIRE_ARGV${_index}}") endif() endforeach() + if (COTIRE_TARGET_LANGUAGE) cotire_generate_unity_source(${_files} LANGUAGE "${COTIRE_TARGET_LANGUAGE}") else() diff --git a/HISTORY.md b/HISTORY.md index 55c3ea4..cb8baf6 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,14 @@ +## 1.6.7 (2014-12-21) + +* fix CMake 3.1 compatibility issues. +* fix ccache 3.2 compatibility issues. +* handle `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` correctly for mixed-language targets. +* correctly compute absolute paths of generated source files added to the unity source file. +* fix bug with checking unity source and prefix header dependencies under Xcode. +* fix bug with handling of unity source file dependencies. +* move code to determine build configurations to function of its own. +* documentation updates. + ## 1.6.6 (2014-09-21) * fix GCC issue with prefix header generation when source files are missing. diff --git a/MANUAL.md b/MANUAL.md index b842f74..6f0341a 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -313,6 +313,10 @@ If a unity build target should not be added by cotire, the target property set_target_properties(example PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) cotire(example) +The property `COTIRE_ADD_UNITY_BUILD` only affects the addition of the unity build target. Custom +build rules for the generation of the unity source file will always be set up, because the +unity source file is needed for the generation of the prefix header. + Both properties default to `TRUE`. If both are set to `FALSE`, cotire will only set up custom build rules for the generation of the unity source and the prefix header. @@ -543,12 +547,12 @@ enabled in the following way upon configuring the project: $ export CC="/usr/local/bin/ccache /usr/bin/gcc" $ export CXX="/usr/local/bin/ccache /usr/bin/g++" - $ export CCACHE_SLOPPINESS=time_macros + $ export CCACHE_SLOPPINESS=pch_defines,time_macros $ cmake .. Note that with ccache in order for precompiled headers to work properly, it is necessary to set -the environment variable `CCACHE_SLOPPINESS` to `time_macros`. Otherwise the build process may -abort with the following error message: +the environment variable `CCACHE_SLOPPINESS` to `pch_defines,time_macros`. Otherwise the build +process may abort with the following error message: fatal error: file 'example_CXX_prefix.hxx' has been modified since the precompiled header 'example_CXX_prefix.hxx.gch' was built @@ -613,6 +617,60 @@ Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build syst directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based variants of the *FSEditor* sample Qt application. +### installing files generated by unity targets + +Cotire cannot set up a `install_unity` target that mimics the `install` target automatically, +because CMake does not provide the necessary information about the existing install rules +programmatically. + +When using a Makefile generator, you can use the following workaround (thanks to peterhuene): + + $ make all_unity + $ make install/fast + +The `install/fast` does not trigger a build, but will use the binaries built by the `all_unity` +target. + +For other generators, set up an `install_unity` target manually. First set up install rules for +all unity targets, that mimic the install rules for the original targets: + + install(TARGETS example_unity RUNTIME DESTINATION "bin" OPTIONAL COMPONENT "unity") + +This installs the `example` executable built by the unity target to the `bin` folder. The install +rules for unity targets must use a custom install component. Then add a global `install_unity` +target that performs the installation of all unity targets: + + add_custom_target(install_unity + COMMAND ${CMAKE_COMMAND} -DCOMPONENT=unity -P cmake_install.cmake + COMMENT "Install the unity-built project..." + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_dependencies(unity_install example_unity) + +The global `install_unity` target must depend on all unity targets that should be installed. + +### customized inclusion of system headers + +If a system header ends up in a pre-compiled header, it is not possible to customize the inclusion +of that header in a source file through preprocessor defines. + +For example, under Windows one may want to include `Windows.h` with `NOMINMAX` defined to prevent +the definition of the `min` and `max` macros: + + #define NOMINMAX + #include + +The dependency of `Windows.h` on the preprocessor define `NOMINMAX` will not be picked up by cotire +automatically upon adding `Windows.h` to the prefix header. To work around the problem, make the +dependency explicit by using `add_definitions` in the corresponding `CMakeLists.txt`: + + if (WIN32) + # prevent definition of min and max macros through inclusion of Windows.h + add_definitions("-DNOMINMAX") + endif() + +That way, the preprocessor define `NOMINMAX` will be picked up by cotire and applied to the +pre-compilation of the prefix header. + cotire usage restrictions ------------------------- diff --git a/Patches/clang-3.5.src.patch b/Patches/clang-3.5.src.patch new file mode 100644 index 0000000..0d9c444 --- /dev/null +++ b/Patches/clang-3.5.src.patch @@ -0,0 +1,39 @@ +diff -rupN --exclude=.DS_Store cfe-3.5.0.src/CMakeLists.txt cfe-3.5.0.src.cotire/CMakeLists.txt +--- cfe-3.5.0.src/CMakeLists.txt 2014-07-16 18:48:33.000000000 +0200 ++++ cfe-3.5.0.src.cotire/CMakeLists.txt 2014-12-21 19:58:36.000000000 +0100 +@@ -94,6 +94,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + include(AddLLVM) + include(TableGen) + include(HandleLLVMOptions) ++ include(cotire) ++ set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + +@@ -343,6 +345,12 @@ macro(add_clang_library name) + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") ++ if (COMMAND cotire) ++ if (NOT "${name}" MATCHES "libclang") ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++ endif() ++ endif() + endmacro(add_clang_library) + + macro(add_clang_executable name) +diff -rupN --exclude=.DS_Store cfe-3.5.0.src/tools/libclang/CMakeLists.txt cfe-3.5.0.src.cotire/tools/libclang/CMakeLists.txt +--- cfe-3.5.0.src/tools/libclang/CMakeLists.txt 2014-07-15 00:17:16.000000000 +0200 ++++ cfe-3.5.0.src.cotire/tools/libclang/CMakeLists.txt 2014-12-21 19:58:36.000000000 +0100 +@@ -114,3 +114,10 @@ if(ENABLE_SHARED) + LINK_FLAGS ${LIBCLANG_LINK_FLAGS}) + endif() + endif() ++ ++if (COMMAND cotire) ++ cotire(libclang) ++ if (TARGET ${LIBCLANG_STATIC_TARGET_NAME}) ++ cotire(${LIBCLANG_STATIC_TARGET_NAME}) ++ endif() ++endif() diff --git a/Patches/llvm-3.5.src.patch b/Patches/llvm-3.5.src.patch new file mode 100644 index 0000000..fb39b62 --- /dev/null +++ b/Patches/llvm-3.5.src.patch @@ -0,0 +1,99 @@ +diff -rupN --exclude=.DS_Store --exclude='*.pyc' llvm-3.5.0.src/CMakeLists.txt llvm-3.5.0.src.cotire/CMakeLists.txt +--- llvm-3.5.0.src/CMakeLists.txt 2014-07-04 06:23:26.000000000 +0200 ++++ llvm-3.5.0.src.cotire/CMakeLists.txt 2014-12-14 12:19:41.000000000 +0100 +@@ -1,6 +1,6 @@ + # See docs/CMake.html for instructions about how to build LLVM with CMake. + +-cmake_minimum_required(VERSION 2.8.8) ++cmake_minimum_required(VERSION 2.8.12) + + # FIXME: It may be removed when we use 2.8.12. + if(CMAKE_VERSION VERSION_LESS 2.8.12) +@@ -41,6 +41,8 @@ if ( LLVM_USE_FOLDERS ) + endif() + + include(VersionFromVCS) ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + + option(LLVM_APPEND_VC_REV + "Append the version control system revision id to LLVM version" OFF) +diff -rupN --exclude=.DS_Store --exclude='*.pyc' llvm-3.5.0.src/cmake/modules/AddLLVM.cmake llvm-3.5.0.src.cotire/cmake/modules/AddLLVM.cmake +--- llvm-3.5.0.src/cmake/modules/AddLLVM.cmake 2014-07-23 17:19:01.000000000 +0200 ++++ llvm-3.5.0.src.cotire/cmake/modules/AddLLVM.cmake 2014-12-14 12:28:35.000000000 +0100 +@@ -106,6 +106,10 @@ function(add_llvm_symbol_exports target_ + set_property(TARGET ${target_name} APPEND_STRING PROPERTY + LINK_FLAGS " /DEF:${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}") + endif() ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endif() + + add_custom_target(${target_name}_exports DEPENDS ${native_export_file}) +@@ -394,6 +398,10 @@ macro(add_llvm_library name) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Libraries") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_library name) + + macro(add_llvm_loadable_module name) +@@ -422,6 +430,10 @@ macro(add_llvm_loadable_module name) + endif() + + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_loadable_module name) + + +@@ -471,6 +483,10 @@ macro(add_llvm_tool name) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Tools") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_tool name) + + +@@ -483,12 +499,20 @@ macro(add_llvm_example name) + install(TARGETS ${name} RUNTIME DESTINATION examples) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Examples") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_example name) + + + macro(add_llvm_utility name) + add_llvm_executable(${name} ${ARGN}) + set_target_properties(${name} PROPERTIES FOLDER "Utils") ++if (COMMAND cotire) ++ set_target_properties(${name} PROPERTIES COTIRE_UNITY_SOURCE_POST_UNDEFS "DEBUG_TYPE") ++ cotire(${name}) ++endif() + endmacro(add_llvm_utility name) + + +diff -rupN --exclude=.DS_Store --exclude='*.pyc' llvm-3.5.0.src/lib/Support/CMakeLists.txt llvm-3.5.0.src.cotire/lib/Support/CMakeLists.txt +--- llvm-3.5.0.src/lib/Support/CMakeLists.txt 2014-07-17 22:05:29.000000000 +0200 ++++ llvm-3.5.0.src.cotire/lib/Support/CMakeLists.txt 2014-12-14 12:17:10.000000000 +0100 +@@ -1,3 +1,7 @@ ++if (COMMAND cotire) ++ set_source_files_properties (IsInf.cpp IsNAN.cpp PROPERTIES COTIRE_EXCLUDED TRUE) ++endif() ++ + add_llvm_library(LLVMSupport + APFloat.cpp + APInt.cpp diff --git a/README.md b/README.md index 7b8dead..6a2bde7 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ requirements * [CMake 2.8.6][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. -* [GCC][gcc] under Linux or OS X. +* [GCC][gcc] or [Clang][clang] under Linux or OS X. * [Intel C++ compiler][intel] under Windows, Linux or OS X. -* [Xcode][xcdt] developer tools package under OS X. This includes [Clang][clang]. +* [Xcode][xcdt] application or Xcode Command Line Tools under OS X. installation ------------ From b4933c8863eb5c083752b1da1af15cdb1c4a4b21 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 28 Dec 2014 21:12:46 +0100 Subject: [PATCH 061/169] cotire 1.6.8 --- CMake/cotire.cmake | 3 ++- HISTORY.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index dd139e0..abfe245 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -52,7 +52,7 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.7") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.8") include(CMakeParseArguments) include(ProcessorCount) @@ -3105,6 +3105,7 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) + cotire_select_unity_source_files("${COTIRE_ARGV3}" _sourceLocations ${_sourceLocations}) cotire_generate_unity_source( "${COTIRE_ARGV3}" ${_sources} diff --git a/HISTORY.md b/HISTORY.md index cb8baf6..12e7a2f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.6.8 (2014-12-28) + +* fix bug with generation of unity source file segments for parallel builds. + ## 1.6.7 (2014-12-21) * fix CMake 3.1 compatibility issues. From 4c799a70f2079e43c4d4bc82617b416bd0b4ef31 Mon Sep 17 00:00:00 2001 From: ArnaudD-FR Date: Thu, 8 Jan 2015 10:20:16 +0100 Subject: [PATCH 062/169] Allow to organize by priority prefix header file --- CMake/cotire.cmake | 47 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index abfe245..0fbadc3 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1054,7 +1054,8 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE UNPARSED_LINES) - set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS, + INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_LANGUAGE) @@ -1104,6 +1105,21 @@ function (cotire_scan_includes _includesVar) "${_option_IGNORE_EXTENSIONS}" _includes _unparsedLines ${_sourceFiles}) + + if (_option_INCLUDE_PRIORITY_PATH) + set (_sortedIncludes "") + foreach (_priorityPath ${_option_INCLUDE_PRIORITY_PATH}) + foreach (_include ${_includes}) + string (FIND ${_include} ${_priorityPath} _position) + if (_position GREATER -1) + list (APPEND _sortedIncludes ${_include}) + endif() + endforeach() + endforeach() + list (INSERT _includes 0 "${_sortedIncludes}") + list (REMOVE_DUPLICATES _includes) + endif() + set (${_includesVar} ${_includes} PARENT_SCOPE) if (_option_UNPARSED_LINES) set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) @@ -1255,7 +1271,8 @@ function (cotire_generate_prefix_header _prefixFile) set(_options "") set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS - INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) + INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS + INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) @@ -1292,6 +1309,7 @@ function (cotire_generate_prefix_header _prefixFile) IGNORE_PATH ${_option_IGNORE_PATH} INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} + INCLUDE_PRIORITY_PATH ${_option_INCLUDE_PRIORITY_PATH} UNPARSED_LINES _unparsedLines) cotire_generate_unity_source("${_prefixFile}" PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) @@ -1951,6 +1969,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS) get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + get_target_property(COTIRE_TARGET_INCLUDE_PRIORITY_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" COTIRE_INCLUDE_SYSTEM_FLAG) @@ -2360,6 +2379,10 @@ function (cotire_init_cotire_target_properties _target) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "") endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "") + endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS "") @@ -3145,6 +3168,7 @@ if (CMAKE_SCRIPT_MODE_FILE) IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" + INCLUDE_PRIORITY_PATH "${COTIRE_TARGET_INCLUDE_PRIORITY_PATH}" INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} @@ -3382,6 +3406,13 @@ else() "See target property COTIRE_PREFIX_HEADER_INCLUDE_PATH." ) + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" + BRIEF_DOCS "Header path matching one of these directories is put at the top of prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH." + ) + define_property( DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each source file." @@ -3468,6 +3499,18 @@ else() "If not set, this property is initialized to the empty list." ) + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" + BRIEF_DOCS "Header path matching one of these directories is put at the top of prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "Headers files paths matching one of these directories will appear at the begin of generated prefix header." + "Order is kept from the property path order." + "If not set, this property is initialized to the empty list." + ) + + + define_property( TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file." From 9ab2aba91af8ba9481df74bae8f43d8151f1d955 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Jan 2015 19:56:45 +0100 Subject: [PATCH 063/169] cotire 1.6.9 --- CMake/cotire.cmake | 4 ++-- HISTORY.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index abfe245..0babbd5 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -52,7 +52,7 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.8") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.9") include(CMakeParseArguments) include(ProcessorCount) @@ -925,7 +925,7 @@ macro (cotire_parse_line _line _headerFileVar _headerDepthVar) # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : characters - if (_line MATCHES ":( +)([^:]+:[^:]+)$") + if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$") # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) diff --git a/HISTORY.md b/HISTORY.md index 12e7a2f..dd2e3f5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.6.9 (2015-01-18) + +* fix bug with parsing of localized MSVC `/showIncludes` output. + ## 1.6.8 (2014-12-28) * fix bug with generation of unity source file segments for parallel builds. From aaefd8f10db785ba43951cffefdeb0c14759729d Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Thu, 19 Feb 2015 13:02:24 -0800 Subject: [PATCH 064/169] Copy IMPORT_PREFIX and IMPORT_SUFFIX target properties for unity targets. For unity targets, the PREFIX and SUFFIX target properties were being copied so that library output file names would make the non-unity target. However, this wasn't the case for IMPORT_PREFIX and IMPORT_SUFFIX which control the import library file name on Windows. As a result, the unity target and the original target differed in the output file name for import libraries. This fix simply adds IMPORT_PREFIX and IMPORT_SUFFIX to the list of properties being copied from the original target. --- CMake/cotire.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 0babbd5..33703a5 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2757,7 +2757,8 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ OUTPUT_NAME OUTPUT_NAME_ RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_ - PREFIX _POSTFIX SUFFIX) + PREFIX _POSTFIX SUFFIX + IMPORT_PREFIX IMPORT_SUFFIX) # copy compile stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ From 7ff33be792f94c96fef709444f89039ae95ec25c Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Mon, 16 Mar 2015 15:23:38 +0100 Subject: [PATCH 065/169] Fix typo Incude -> Include --- CMake/cotire.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 33703a5..e07ffba 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -869,12 +869,12 @@ macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar) endforeach() endmacro() -macro (cotire_check_header_file_location _headerFile _insideIncudeDirs _outsideIncudeDirs _headerIsInside) +macro (cotire_check_header_file_location _headerFile _insideIncludeDirs _outsideIncludeDirs _headerIsInside) # check header path against ignored and honored include directories - cotire_find_closest_relative_path("${_headerFile}" "${_insideIncudeDirs}" _insideRelPath) + cotire_find_closest_relative_path("${_headerFile}" "${_insideIncludeDirs}" _insideRelPath) if (_insideRelPath) # header is inside, but could be become outside if there is a shorter outside match - cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncudeDirs}" _outsideRelPath) + cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncludeDirs}" _outsideRelPath) if (_outsideRelPath) string (LENGTH "${_insideRelPath}" _insideRelPathLen) string (LENGTH "${_outsideRelPath}" _outsideRelPathLen) @@ -949,7 +949,7 @@ macro (cotire_parse_line _line _headerFileVar _headerDepthVar) endif() endmacro() -function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honoredIncudeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar) +function (cotire_parse_includes _language _scanOutput _ignoredIncludeDirs _honoredIncludeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar) if (WIN32) # prevent CMake macro invocation errors due to backslash characters in Windows paths string (REPLACE "\\" "/" _scanOutput "${_scanOutput}") @@ -969,11 +969,11 @@ function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honore if (_ignoredExtensions) message (STATUS "Ignored extensions: ${_ignoredExtensions}") endif() - if (_ignoredIncudeDirs) - message (STATUS "Ignored paths: ${_ignoredIncudeDirs}") + if (_ignoredIncludeDirs) + message (STATUS "Ignored paths: ${_ignoredIncludeDirs}") endif() - if (_honoredIncudeDirs) - message (STATUS "Included paths: ${_honoredIncudeDirs}") + if (_honoredIncludeDirs) + message (STATUS "Included paths: ${_honoredIncludeDirs}") endif() endif() set (_sourceFiles ${ARGN}) @@ -985,7 +985,7 @@ function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honore if (_line) cotire_parse_line("${_line}" _headerFile _headerDepth) if (_headerFile) - cotire_check_header_file_location("${_headerFile}" "${_ignoredIncudeDirs}" "${_honoredIncudeDirs}" _headerIsInside) + cotire_check_header_file_location("${_headerFile}" "${_ignoredIncludeDirs}" "${_honoredIncludeDirs}" _headerIsInside) if (COTIRE_DEBUG) message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}") endif() From 3c21d60e8d9802209c38f1f9fb11e07039eff7f6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 29 Mar 2015 16:57:02 +0200 Subject: [PATCH 066/169] fix a few COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH issues --- CMake/cotire.cmake | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 6907d66..c502662 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1054,8 +1054,8 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE UNPARSED_LINES) - set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS, - INCLUDE_PRIORITY_PATH) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES + IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_LANGUAGE) @@ -1105,7 +1105,6 @@ function (cotire_scan_includes _includesVar) "${_option_IGNORE_EXTENSIONS}" _includes _unparsedLines ${_sourceFiles}) - if (_option_INCLUDE_PRIORITY_PATH) set (_sortedIncludes "") foreach (_priorityPath ${_option_INCLUDE_PRIORITY_PATH}) @@ -1116,10 +1115,11 @@ function (cotire_scan_includes _includesVar) endif() endforeach() endforeach() - list (INSERT _includes 0 "${_sortedIncludes}") - list (REMOVE_DUPLICATES _includes) + if (_sortedIncludes) + list (INSERT _includes 0 ${_sortedIncludes}) + list (REMOVE_DUPLICATES _includes) + endif() endif() - set (${_includesVar} ${_includes} PARENT_SCOPE) if (_option_UNPARSED_LINES) set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) @@ -1271,8 +1271,8 @@ function (cotire_generate_prefix_header _prefixFile) set(_options "") set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS - INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS - INCLUDE_PRIORITY_PATH) + INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH + IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) @@ -3169,7 +3169,7 @@ if (CMAKE_SCRIPT_MODE_FILE) IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" - INCLUDE_PRIORITY_PATH "${COTIRE_TARGET_INCLUDE_PRIORITY_PATH}" + INCLUDE_PRIORITY_PATH ${COTIRE_TARGET_INCLUDE_PRIORITY_PATH} INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} @@ -3409,7 +3409,7 @@ else() define_property( DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" - BRIEF_DOCS "Header path matching one of these directories is put at the top of prefix header." + BRIEF_DOCS "Header paths matching one of these directories are put at the top of the prefix header." FULL_DOCS "See target property COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH." ) @@ -3501,17 +3501,15 @@ else() ) define_property( - TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" - BRIEF_DOCS "Header path matching one of these directories is put at the top of prefix header." + TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" INHERITED + BRIEF_DOCS "Header paths matching one of these directories are put at the top of prefix header." FULL_DOCS "The property can be set to a list of directories." - "Headers files paths matching one of these directories will appear at the begin of generated prefix header." - "Order is kept from the property path order." + "Header file paths matching one of these directories will be inserted at the beginning of the generated prefix header." + "Header files are sorted according to the order of the directories in the property." "If not set, this property is initialized to the empty list." ) - - define_property( TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file." From 2dd30b59095a1b326a910c5e5fcba8468d8504c8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 29 Mar 2015 19:46:30 +0200 Subject: [PATCH 067/169] cotire 1.7.0 --- CMake/cotire.cmake | 233 ++++++++++++++++++++++++++------------------- CMakeLists.txt | 2 +- HISTORY.md | 13 +++ MANUAL.md | 69 +++++++++----- README.md | 24 ++--- license | 2 +- 6 files changed, 201 insertions(+), 142 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index c502662..e293ba1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2014 Sascha Kratky +# Copyright 2012-2015 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -37,22 +37,23 @@ set(__COTIRE_INCLUDED TRUE) if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(PUSH) endif() -# we need the CMake variables CMAKE_SCRIPT_MODE_FILE and CMAKE_ARGV available since 2.8.5 -# we need APPEND_STRING option for set_property available since 2.8.6 -cmake_minimum_required(VERSION 2.8.6) +cmake_minimum_required(VERSION 2.8.12) if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(POP) endif() -if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") +if (POLICY CMP0051) # include TARGET_OBJECTS expressions in a target's SOURCES property cmake_policy(SET CMP0051 NEW) +endif() + +if (POLICY CMP0054) # only interpret if() arguments as variables or keywords when unquoted cmake_policy(SET CMP0054 NEW) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.9") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.0") include(CMakeParseArguments) include(ProcessorCount) @@ -372,13 +373,8 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (_target) # add option from CMake target type variable get_target_property(_targetType ${_target} TYPE) - if (POLICY CMP0018) - # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on - cmake_policy(GET CMP0018 _PIC_Policy) - else() - # default to old behavior - set (_PIC_Policy "OLD") - endif() + # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on + cmake_policy(GET CMP0018 _PIC_Policy) if (COTIRE_DEBUG) message(STATUS "CMP0018=${_PIC_Policy}") endif() @@ -412,33 +408,39 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ endif() endif() if (_target) - # add target compile options + # add target compile flags get_target_property(_targetflags ${_target} COMPILE_FLAGS) if (_targetflags) set (_compileFlags "${_compileFlags} ${_targetflags}") endif() + endif() + if (UNIX) + separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") + elseif(WIN32) + separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}") + else() + separate_arguments(_compileFlags) + endif() + # target compile options + if (_target) get_target_property(_targetOptions ${_target} COMPILE_OPTIONS) if (_targetOptions) - set (_compileFlags "${_compileFlags} ${_targetOptions}") + list (APPEND _compileFlags ${_targetOptions}) endif() - # interface compile options from linked library targets + endif() + # interface compile options from linked library targets + if (_target) + set (_linkLibraries "") cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) - set (_compileFlags "${_compileFlags} ${_targetOptions}") + list (APPEND _compileFlags ${_targetOptions}) endif() endif() endforeach() endif() - if (UNIX) - separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") - elseif(WIN32) - separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}") - else() - separate_arguments(_compileFlags) - endif() # platform specific flags if (APPLE) get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) @@ -497,7 +499,10 @@ function (cotire_get_target_include_directories _config _language _targetSourceD if (_targetDirs) list (APPEND _systemIncludeDirs ${_targetDirs}) endif() - # interface include directories from linked library targets + endif() + # interface include directories from linked library targets + if (_target) + set (_linkLibraries "") cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) @@ -549,18 +554,6 @@ function (cotire_get_target_include_directories _config _language _targetSourceD set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE) endfunction() -macro (cotire_make_C_identifier _identifierVar _str) - if (CMAKE_VERSION VERSION_LESS "2.8.12") - # mimic CMake SystemTools::MakeCindentifier behavior - if ("${_str}" MATCHES "^[0-9].+$") - set (_str "_${str}") - endif() - string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") - else() - string (MAKE_C_IDENTIFIER "${_str}" "${_identifierVar}") - endif() -endmacro() - function (cotire_get_target_export_symbol _target _exportSymbolVar) set (_exportSymbol "") get_target_property(_targetType ${_target} TYPE) @@ -571,7 +564,7 @@ function (cotire_get_target_export_symbol _target _exportSymbolVar) if (NOT _exportSymbol) set (_exportSymbol "${_target}_EXPORTS") endif() - cotire_make_C_identifier(_exportSymbol "${_exportSymbol}") + string (MAKE_C_IDENTIFIER "${_exportSymbol}" _exportSymbol) endif() set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE) endfunction() @@ -607,6 +600,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta list (APPEND _configDefinitions ${_definitions}) endif() # interface compile definitions from linked library targets + set (_linkLibraries "") cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) @@ -1427,15 +1421,22 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # /TC treat all files named on the command line as C source files # /TP treat all files named on the command line as C++ source files # /Zs syntax check only + # /Zm precompiled header memory allocation scaling factor set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() else() # return as a flag string set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() endif() elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used @@ -1525,14 +1526,21 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # /Yu uses a precompiled header file during build # /Fp specifies precompiled header binary file name # /FI forces inclusion of file + # /Zm precompiled header memory allocation scaling factor if (_pchFile) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) if (_flags) # append to list list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() else() # return as a flag string set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() endif() else() # no precompiled header, force inclusion of prefix header @@ -1737,6 +1745,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta endfunction() macro (cotire_get_intermediate_dir _cotireDir) + # ${CMAKE_CFG_INTDIR} may reference a build-time variable when using a generator which supports configuration types get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) endmacro() @@ -1853,7 +1862,7 @@ function (cotire_make_prefix_file_path _language _target _prefixFileVar) if (NOT _language) set (_language "C") endif() - if (MSVC OR CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel") + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel|MSVC") cotire_get_intermediate_dir(_baseDir) set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE) endif() @@ -2010,15 +2019,9 @@ function (cotire_generate_target_script _language _configurations _targetSourceD cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) if (_contentsHasGeneratorExpressions) # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time - if (NOT CMAKE_VERSION VERSION_LESS "2.8.12") - # the file(GENERATE ...) command requires cmake 2.8.12 or later - set (_configNameOrNoneGeneratorExpression "$<$:None>$<$>:$>") - set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") - file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") - else() - message (WARNING "cotire: generator expression used in target ${_target}. This requires CMake 2.8.12 or later.") - set (_targetCotireConfigScript "${_targetCotireScript}") - endif() + set (_configNameOrNoneGeneratorExpression "$<$:None>$<$>:$>") + set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") + file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") else() set (_targetCotireConfigScript "${_targetCotireScript}") endif() @@ -2035,19 +2038,19 @@ function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) list (GET _sourceFiles 0 _hostFile) - set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + set (_flags "") cotire_add_pch_compilation_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") - # make first source file depend on prefix header + # make object file generated from first source file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") # mark first source file as cotired to prevent it from being used in another cotired target set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") endif() - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) @@ -2079,21 +2082,21 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") list (REMOVE_AT _sourceFiles 0) - set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + set (_flags "") cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") - # make source files depend on precompiled header + # make object files generated from source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if (NOT _wholeTarget) # for makefile based generator, we force the inclusion of the prefix header for a subset # of the source files, if this is a multi-language target or has excluded files - set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + set (_flags "") cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) @@ -2101,7 +2104,7 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") endif() - # make source files depend on precompiled header + # make object files generated from source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() endfunction() @@ -2109,15 +2112,15 @@ endfunction() function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) set (_sourceFiles ${ARGN}) # force the inclusion of the prefix header for the given source files - set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) + set (_flags "") cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") - # make source files depend on prefix header + # make object files generated from source files depend on prefix header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") endfunction() @@ -2212,7 +2215,7 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") - elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # for makefile based generator, we force inclusion of the prefix header for all target source files # if this is a single-language target without any excluded files if (_wholeTarget) @@ -2222,13 +2225,13 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) if (_prefixFile) - set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + set (_options COMPILE_OPTIONS) cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" - "${_prefixFile}" "${_pchFile}" _flags) - set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + "${_prefixFile}" "${_pchFile}" _options) + set_property(TARGET ${_target} APPEND PROPERTY ${_options}) endif() endif() endif() @@ -2334,6 +2337,7 @@ function (cotire_setup_prefix_generation_from_unity_command _language _target _t "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) endif() if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # set up generation of a prefix source file which includes the prefix header cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) @@ -2349,6 +2353,7 @@ function (cotire_setup_prefix_generation_from_provided_command _language _target endif() cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # set up generation of a prefix source file which includes the prefix header cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) @@ -2393,7 +2398,7 @@ function (cotire_init_cotire_target_properties _target) endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT SET) if (NOT _isSet) - set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "") + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET) if (NOT _isSet) @@ -2657,7 +2662,7 @@ function (cotire_setup_clean_target _target) endfunction() function (cotire_setup_pch_target _languages _configurations _target) - if ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") + if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # for makefile based generators, we add a custom target to trigger the generation of the cotire related files set (_dependsFiles "") foreach (_language ${_languages}) @@ -2732,6 +2737,14 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + get_target_property(_targetAutoMoc ${_target} AUTOMOC) + get_target_property(_targetAutoUic ${_target} AUTOUIC) + if (_targetAutoMoc OR _targetAutoUic) + # if the original target sources are subject to CMake's automatic Qt processing, + # also include implicitly generated _automoc.cpp file + list (APPEND _unityTargetSources "${_target}_automoc.cpp") + set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + endif() if (COTIRE_DEBUG) message (STATUS "add ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") endif() @@ -2741,11 +2754,11 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() + # copy output location properties set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_ RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_) - # copy output location properties if (COTIRE_UNITY_OUTPUT_DIRECTORY) set (_setDefaultOutputDir TRUE) if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") @@ -2772,7 +2785,8 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + ${_outputDirProperties}) endif() # copy output name cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} @@ -2791,12 +2805,19 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_ POSITION_INDEPENDENT_CODE C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) + # copy compile features + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED + CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED + COMPILE_FEATURES) # copy interface stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING - INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES + COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN + COMPATIBLE_INTERFACE_STRING + INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS + INTERFACE_INCLUDE_DIRECTORIES INTERFACE_SOURCES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES - INTERFACE_AUTOUIC_OPTIONS) + INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) # copy link stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH @@ -2809,22 +2830,34 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour NO_SONAME SOVERSION VERSION) # copy Qt stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - AUTOMOC AUTOMOC_MOC_OPTIONS AUTOUIC AUTOUIC_OPTIONS AUTORCC AUTORCC_OPTIONS - AUTOGEN_TARGET_DEPENDS) + AUTORCC AUTORCC_OPTIONS) + if (_targetAutoMoc OR _targetAutoUic) + # do not copy the original target's AUTOMOC and AUTOUIC related properties, + # but depend on the original target's implicity generated _automoc target + add_dependencies(${_unityTargetName} ${_target}_automoc) + set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) + endif() # copy cmake stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST - MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) + BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST + MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES + OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) # copy Windows platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS + COMPILE_PDB_NAME COMPILE_PDB_NAME_ + COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ - VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_KEYWORD - VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER - VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES WIN32_EXECUTABLE) + VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE + VS_KEYWORD VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER + VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES VS_WINRT_COMPONENT + VS_DOTNET_TARGET_FRAMEWORK_VERSION WIN32_EXECUTABLE) + # copy Android platform specific stuff + cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + ANDROID_API ANDROID_API_MIN ANDROID_GUI) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) @@ -2890,6 +2923,11 @@ function (cotire_target _target) return() endif() endif() + # when not using configuration types, immediately create cotire intermediate dir + if (NOT CMAKE_CONFIGURATION_TYPES) + cotire_get_intermediate_dir(_baseDir) + file (MAKE_DIRECTORY "${_baseDir}") + endif() # choose languages that apply to the target cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) if (NOT _targetLanguages) @@ -2945,25 +2983,21 @@ function (cotire_target_link_libraries _target) message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}") endif() if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") - if (CMAKE_VERSION VERSION_LESS "2.8.11") - message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") - else() - set (_unityLinkLibraries "") - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) - if (_linkLibraries) - list (APPEND _unityLinkLibraries ${_linkLibraries}) - endif() - get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) - if (_interfaceLinkLibraries) - list (APPEND _unityLinkLibraries ${_interfaceLinkLibraries}) - endif() - cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_unityLinkLibraries}) - if (COTIRE_DEBUG) - message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") - endif() - if (_unityLinkLibraries) - target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) - endif() + set (_unityLinkLibraries "") + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + if (_linkLibraries) + list (APPEND _unityLinkLibraries ${_linkLibraries}) + endif() + get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) + if (_interfaceLinkLibraries) + list (APPEND _unityLinkLibraries ${_interfaceLinkLibraries}) + endif() + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_unityLinkLibraries}) + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") + endif() + if (_unityLinkLibraries) + target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) endif() endif() endif() @@ -3302,6 +3336,13 @@ else() if (NOT COTIRE_PCH_TARGET_SUFFIX) set (COTIRE_PCH_TARGET_SUFFIX "_pch") endif() + if (MSVC) + # MSVC default PCH memory scaling factor of 100 percent (75 MB) is too small for template heavy C++ code + # use a bigger default factor of 140 percent (105 MB) + if (NOT DEFINED COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (COTIRE_PCH_MEMORY_SCALING_FACTOR "140") + endif() + endif() if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX) set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity") endif() @@ -3565,7 +3606,7 @@ else() TARGET PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" INHERITED BRIEF_DOCS "Define strategy for setting up unity target's link libraries." FULL_DOCS - "If this property is empty, the generated unity target's link libraries have to be set up manually." + "If this property is empty or set to NONE, the generated unity target's link libraries have to be set up manually." "If this property is set to COPY, the unity target's link libraries will be copied from this target." "If this property is set to COPY_UNITY, the unity target's link libraries will be copied from this target with considering existing unity targets." "Inherited from directory." diff --git a/CMakeLists.txt b/CMakeLists.txt index eeb1372..bfe830a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # cotire example project -cmake_minimum_required(VERSION 2.8.6) +cmake_minimum_required(VERSION 2.8.12) project (CotireExample) diff --git a/HISTORY.md b/HISTORY.md index dd2e3f5..6cff4b1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,16 @@ +## 1.7.0 (2015-03-29) + +* fix CMake 3.2 compatibility issues. +* cotire now requires CMake 2.8.12 or newer. +* copy `IMPORT_PREFIX` and `IMPORT_SUFFIX` target properties for unity targets (thanks peterhuene). +* new property `COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH` allows for organizing includes + added to the prefix header by priority (thanks ArnaudD-FR). +* for Visual Studio C++, increase static precompiled header memory allocation. +* the default strategy for setting up a unity target's linked libraries is now `COPY_UNITY`. +* for Qt projects, fix problem with handling of `AUTOMOC` in generated unity target. +* fix problem with generating the cotire intermediate directory. +* documentation updates. + ## 1.6.9 (2015-01-18) * fix bug with parsing of localized MSVC `/showIncludes` output. diff --git a/MANUAL.md b/MANUAL.md index 6f0341a..10aaa46 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -100,10 +100,7 @@ files generated by cotire. The `example_unity` target produces the same output pool targets for all cotired project targets. By default, the `example_unity` target inherits all build settings from the original target -`example` except for linked libraries and target dependencies. To get a linkable unity target, -the required libraries have to be added manually to the unity target with `target_link_libraries`. -When using CMake 2.8.11 or later, it is possible to have the unity target inherit linked libraries -as well (see the section on the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` below). +`example` including linked libraries and target dependencies. cotire generated files ---------------------- @@ -482,7 +479,7 @@ the file segments in parallel. To explicitly specify the number of cores, append the number after `-j`, e.g. `-j 4` or `-j4`. -For CMake generators that are multi-core aware by default (i.e., Visual Studio, JOM, Ninja) cotire +For CMake generators that are multi-core aware by default (i.e., Visual Studio, JOM, Ninja), cotire will automatically initialize the property to `-j`. For makefile based generators, this has to be done explicitly by setting the cache variable `COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES`, i.e.: @@ -582,40 +579,46 @@ be enabled for them for Xcode projects generated with CMake. Unity builds work a ### automatically setting up linked libraries in the unity target -CMake 2.8.11 introduced a new target property `LINK_LIBRARIES`, which specifies the list of -libraries or targets which will be used for linking. Cotire can be configured to make use of this -property to automatically set up the linked libraries in the generated unity target. +The setting of the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` controls the linking +strategy for the generated unit target. -To have cotire copy the the list of linked libraries and targets from the original target to the -unity target, set the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` to `COPY`. +If this property is empty or set to `NONE`, the generated unity target's link libraries have to be +set up manually with subsequent `target_link_libraries` calls: - cmake_minimum_required(VERSION 2.8.11) - ... - set_target_properties(example PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY") + set_target_properties(example PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "NONE") ... cotire(example) + target_link_libraries(MyExecutable_unity ${MyExecutableLibraries}) + +If this property is set to `COPY`, the unity target's link libraries will be copied from the +original target. -If the target property `COTIRE_UNITY_LINK_LIBRARIES_INIT` is set to `COPY_UNITY` instead, cotire -will copy all linked libraries and targets from the original target, but instead of copying a -target verbatim, it will prefer the target's corresponding unity target, provided one exists. +If this property is set to `COPY_UNITY`, the unity target's link libraries will be copied from the +original target but instead of copying a linked target verbatim, the target's corresponding unity +target will be preferred, provided one exists. -For reasons of backwards compatibility, the `COTIRE_UNITY_LINK_LIBRARIES_INIT` property is left -empty by default. The required libraries have to be added manually to the unity target with -subsequent `target_link_libraries` calls. +As of cotire 1.7.0, the default linking strategy for unit targets is `COPY_UNITY`. The property `COTIRE_UNITY_LINK_LIBRARIES_INIT` can also be set on directories. A target inherits the property value from its enclosing directory. To make all targets in the project use the -`COPY_UNITY` strategy, the directory property can be set in the outermost `CMakeList.txt` file: +`COPY` strategy, the directory property can be set in the outermost `CMakeList.txt` file: include(cotire) ... - set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY") ### using cotire with Qt -Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build system. The `Patches` -directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based variants of the -*FSEditor* sample Qt application. +Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build system. + +If a CMake target's `AUTOMOC` or `AUTOUIC` properties are set, the generated unity target will +automatically add a dependency to the implicitly generated `_automoc` target to ensure +that `moc` and `uic` are run on the individual source files. + +The unity target will also include the implicitly generated `_automoc.cpp` source file. + +The `Patches` directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based +variants of the *FSEditor* sample Qt application. ### installing files generated by unity targets @@ -671,6 +674,20 @@ dependency explicit by using `add_definitions` in the corresponding `CMakeLists. That way, the preprocessor define `NOMINMAX` will be picked up by cotire and applied to the pre-compilation of the prefix header. +### organize includes added to the prefix header + +Sometimes the order of the includes in the automatically generated prefix header may result in +compilation errors due to subtile header dependencies. + +To work around the problem, the target property `COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH` +can be set to a list of directories. Header files whose path matches one of these directories will +be inserted at the beginning of generated prefix header. Header files are sorted according to +the order of the directories in the property. Headers not matching one of these directories are +left untouched. + +The property `COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH` can also be set on directories. A target +inherits the property value from its enclosing directory. + cotire usage restrictions ------------------------- @@ -710,7 +727,7 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [1260]:http://www.cmake.org/Bug/view.php?id=1260 [ccch]:http://ccache.samba.org/ [ccch_pch]:http://ccache.samba.org/manual.html#_precompiled_headers -[clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders +[clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiled-headers [fsedit_qt4]:http://www.vikingsoft.eu/fseditor.html [fsedit_qt5]:https://github.com/joonhwan/fsedit-qt5 [gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html @@ -721,7 +738,7 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit -[objlib]:http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library +[objlib]:http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library [pfh]:http://en.wikipedia.org/wiki/Prefix_header [icc_linux]:http://software.intel.com/en-us/non-commercial-software-development [XGE]:http://www.incredibuild.com diff --git a/README.md b/README.md index 6a2bde7..52a6897 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ features requirements ------------ -* [CMake 2.8.6][cmk] or newer. The executable `cmake` should be on the system path. +* [CMake 2.8.12][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. * [GCC][gcc] or [Clang][clang] under Linux or OS X. * [Intel C++ compiler][intel] under Windows, Linux or OS X. @@ -75,19 +75,7 @@ set the `COTIRE_CXX_PREFIX_HEADER_INIT` property before invoking cotire: As a side effect, cotire generates a new target named `MyExecutable_unity`, which lets you perform a unity build for the original target. The unity target inherits all build settings from the -original target except for linked libraries and target dependencies. To get a workable unity -target, add another `target_link_libraries` call: - - cotire(MyExecutable) - target_link_libraries(MyExecutable_unity ${MyExecutableLibraries}) - -If CMake version 2.8.11 or later is used, it is possible to also inherit linked libraries from -the original target by setting the property `COTIRE_UNITY_LINK_LIBRARIES_INIT`: - - set_target_properties(MyExecutable PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY") - cotire(MyExecutable) - -See the [cotire manual][manual] for more information. +original target, including linked libraries and target dependencies. For Makefile based generators you can then invoke a unity build that produces the same output as the original target, but does so much faster by entering: @@ -131,19 +119,19 @@ known issues [ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling [cgwn]:http://www.cygwin.com/ [clang]:http://clang.llvm.org/ -[cmk]:http://www.cmake.org/cmake/resources/software.html +[cmk]:http://www.cmake.org/download/ [gcc]:http://gcc.gnu.org/ [manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md [mingw]:http://www.mingw.org/ -[ninja]:http://martine.github.com/ninja/ +[ninja]:http://martine.github.io/ninja/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [pfh]:http://en.wikipedia.org/wiki/Prefix_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit [vslstd]:http://msdn.microsoft.com/vstudio/ -[xcdt]:http://developer.apple.com/tools/xcode/ +[xcdt]:http://developer.apple.com/xcode/ [PCHH]:http://gcc.gnu.org/wiki/PCHHaters [EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ -[jom]:http://qt-project.org/wiki/jom +[jom]:http://wiki.qt.io/Jom [intel]:http://software.intel.com/en-us/c-compilers [XGE]:http://www.incredibuild.com [shrp]:http://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html diff --git a/license b/license index f199abe..acae20c 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012-2014 Sascha Kratky +Copyright (c) 2012-2015 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From c5d2d6928921dcc7a591e3bdc47a2bc28316fa3e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 6 Apr 2015 17:53:53 +0200 Subject: [PATCH 068/169] cotire 1.7.1 --- CMake/cotire.cmake | 350 +++++++++++++++++++++------------------------ HISTORY.md | 8 ++ MANUAL.md | 40 +++++- 3 files changed, 206 insertions(+), 192 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e293ba1..fd0ad87 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -42,57 +42,63 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(POP) endif() +# activate select policies +if (POLICY CMP0038) + # targets may not link directly to themselves + cmake_policy(SET CMP0038 NEW) +endif() + +if (POLICY CMP0039) + # utility targets may not have link dependencies + cmake_policy(SET CMP0039 NEW) +endif() + +if (POLICY CMP0040) + # target in the TARGET signature of add_custom_command() must exist + cmake_policy(SET CMP0040 NEW) +endif() + +if (POLICY CMP0045) + # error on non-existent target in get_target_property + cmake_policy(SET CMP0045 NEW) +endif() + +if (POLICY CMP0046) + # error on non-existent dependency in add_dependencies + cmake_policy(SET CMP0046 NEW) +endif() + +if (POLICY CMP0049) + # do not expand variables in target source entries + cmake_policy(SET CMP0049 NEW) +endif() + +if (POLICY CMP0050) + # disallow add_custom_command SOURCE signatures + cmake_policy(SET CMP0050 NEW) +endif() + if (POLICY CMP0051) # include TARGET_OBJECTS expressions in a target's SOURCES property cmake_policy(SET CMP0051 NEW) endif() +if (POLICY CMP0053) + # simplify variable reference and escape sequence evaluation + cmake_policy(SET CMP0053 NEW) +endif() + if (POLICY CMP0054) # only interpret if() arguments as variables or keywords when unquoted cmake_policy(SET CMP0054 NEW) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.1") include(CMakeParseArguments) include(ProcessorCount) -function (cotire_determine_compiler_version _language _versionPrefix) - if (NOT ${_versionPrefix}_VERSION) - # use CMake's predefined compiler version variable (available since CMake 2.8.8) - if (DEFINED CMAKE_${_language}_COMPILER_VERSION) - set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") - elseif (WIN32) - # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared - unset (ENV{VS_UNICODE_OUTPUT}) - string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process ( - COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} - ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) - string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" ${_versionPrefix}_VERSION "${_versionLine}") - else() - # assume GCC like command line interface - string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) - execute_process ( - COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" - OUTPUT_VARIABLE ${_versionPrefix}_VERSION - RESULT_VARIABLE _result - OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) - if (_result) - set (${_versionPrefix}_VERSION "") - endif() - endif() - if (${_versionPrefix}_VERSION) - set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" CACHE INTERNAL "${_language} compiler version") - endif() - set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" PARENT_SCOPE) - if (COTIRE_DEBUG) - message (STATUS "${CMAKE_${_language}_COMPILER} version ${${_versionPrefix}_VERSION}") - endif() - endif() -endfunction() - function (cotire_get_configuration_types _configsVar) set (_configs "") if (CMAKE_CONFIGURATION_TYPES) @@ -136,9 +142,6 @@ macro (cotire_check_is_path_relative_to _path _isRelativeVar) endmacro() function (cotire_filter_language_source_files _language _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) - set (_sourceFiles "") - set (_excludedSourceFiles "") - set (_cotiredSourceFiles "") if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}") else() @@ -154,9 +157,13 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude else() set (_excludeExtensions "") endif() - if (COTIRE_DEBUG) + if (COTIRE_DEBUG AND _languageExtensions) message (STATUS "${_language} source file extensions: ${_languageExtensions}") + endif() + if (COTIRE_DEBUG AND _ignoreExtensions) message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") + endif() + if (COTIRE_DEBUG AND _excludeExtensions) message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") endif() if (CMAKE_VERSION VERSION_LESS "3.1.0") @@ -167,12 +174,13 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude # through generator expressions at configure time, we filter them out string (GENEX_STRIP "${ARGN}" _allSourceFiles) endif() + set (_filteredSourceFiles "") + set (_excludedSourceFiles "") foreach (_sourceFile ${_allSourceFiles}) + get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) - get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) - set (_sourceIsFiltered FALSE) if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic) cotire_get_source_file_extension("${_sourceFile}" _sourceExt) if (_sourceExt) @@ -184,7 +192,8 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude else() list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) if (_sourceIndex GREATER -1) - set (_sourceIsFiltered TRUE) + # consider source file + list (APPEND _filteredSourceFiles "${_sourceFile}") elseif ("${_sourceLanguage}" STREQUAL "${_language}") # add to excluded sources, if file is not ignored and has correct language without having the correct extension list (APPEND _excludedSourceFiles "${_sourceFile}") @@ -193,30 +202,33 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude endif() endif() endif() - if (COTIRE_DEBUG) - message (STATUS "${_sourceFile} filtered=${_sourceIsFiltered} language=${_sourceLanguage} header=${_sourceIsHeaderOnly}") - endif() - if (_sourceIsFiltered) - get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) - get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) - get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) - if (COTIRE_DEBUG) - message (STATUS "${_sourceFile} excluded=${_sourceIsExcluded} cotired=${_sourceIsCotired} compileFlags=${_sourceCompileFlags}") - endif() - if (_sourceIsCotired) - list (APPEND _cotiredSourceFiles "${_sourceFile}") - elseif (_sourceIsExcluded OR _sourceCompileFlags) - list (APPEND _excludedSourceFiles "${_sourceFile}") - else() - list (APPEND _sourceFiles "${_sourceFile}") - endif() + endforeach() + set (_sourceFiles "") + set (_cotiredSourceFiles "") + foreach (_sourceFile ${_filteredSourceFiles}) + get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) + get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) + get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) + if (_sourceIsCotired) + list (APPEND _cotiredSourceFiles "${_sourceFile}") + elseif (_sourceIsExcluded OR _sourceCompileFlags) + # add to excluded sources, if file has custom compile flags + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") endif() endforeach() if (COTIRE_DEBUG) - message (STATUS "All: ${ARGN}") - message (STATUS "${_language}: ${_sourceFiles}") - message (STATUS "Excluded: ${_excludedSourceFiles}") - message (STATUS "Cotired: ${_cotiredSourceFiles}") + message (STATUS "All sources: ${ARGN}") + if (_sourceFiles) + message (STATUS "Filtered ${_language} sources: ${_sourceFiles}") + endif() + if (_excludedSourceFiles) + message (STATUS "Excluded ${_language} sources: ${_excludedSourceFiles}") + endif() + if (_cotiredSourceFiles) + message (STATUS "Cotired ${_language} sources: ${_cotiredSourceFiles}") + endif() endif() set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE) set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE) @@ -347,14 +359,11 @@ function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _ if (_optionFlag) list (APPEND _matchedOptions "${_optionFlag}") endif() - if (COTIRE_DEBUG) - message (STATUS "Filter ${_flagFilter}") - if (_matchedOptions) - message (STATUS "Matched ${_matchedOptions}") - endif() - if (_unmatchedOptions) - message (STATUS "Unmatched ${_unmatchedOptions}") - endif() + if (COTIRE_DEBUG AND _matchedOptions) + message (STATUS "Filter ${_flagFilter} matched: ${_matchedOptions}") + endif() + if (COTIRE_DEBUG AND _unmatchedOptions) + message (STATUS "Filter ${_flagFilter} unmatched: ${_unmatchedOptions}") endif() set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE) set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) @@ -371,32 +380,14 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}") endif() if (_target) - # add option from CMake target type variable - get_target_property(_targetType ${_target} TYPE) - # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on - cmake_policy(GET CMP0018 _PIC_Policy) - if (COTIRE_DEBUG) - message(STATUS "CMP0018=${_PIC_Policy}") - endif() - if (_PIC_Policy STREQUAL "NEW") - # NEW behavior: honor the POSITION_INDEPENDENT_CODE target property - get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) - if (_targetPIC) - if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") - elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") - endif() - endif() - else() - # OLD behavior or policy not set: use the value of CMAKE_SHARED_LIBRARY__FLAGS - if (_targetType STREQUAL "MODULE_LIBRARY") - # flags variable for module library uses different name SHARED_MODULE - # (e.g., CMAKE_SHARED_MODULE_C_FLAGS) - set (_targetType SHARED_MODULE) - endif() - if (CMAKE_${_targetType}_${_language}_FLAGS) - set (_compileFlags "${_compileFlags} ${CMAKE_${_targetType}_${_language}_FLAGS}") + # handle the POSITION_INDEPENDENT_CODE target property + get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) + if (_targetPIC) + get_target_property(_targetType ${_target} TYPE) + if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") + elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") endif() endif() endif() @@ -468,7 +459,7 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ endif() endif() if (COTIRE_DEBUG AND _compileFlags) - message (STATUS "Target ${_target} compile flags ${_compileFlags}") + message (STATUS "Target ${_target} compile flags: ${_compileFlags}") endif() set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() @@ -545,11 +536,11 @@ function (cotire_get_target_include_directories _config _language _targetSourceD list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() if (COTIRE_DEBUG AND _includeDirs) - message (STATUS "Target ${_target} include dirs ${_includeDirs}") + message (STATUS "Target ${_target} include dirs: ${_includeDirs}") endif() set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE) if (COTIRE_DEBUG AND _systemIncludeDirs) - message (STATUS "Target ${_target} system include dirs ${_systemIncludeDirs}") + message (STATUS "Target ${_target} system include dirs: ${_systemIncludeDirs}") endif() set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE) endfunction() @@ -620,7 +611,7 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta endif() list (REMOVE_DUPLICATES _configDefinitions) if (COTIRE_DEBUG AND _configDefinitions) - message (STATUS "Target ${_target} compile definitions ${_configDefinitions}") + message (STATUS "Target ${_target} compile definitions: ${_configDefinitions}") endif() set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) endfunction() @@ -632,7 +623,7 @@ function (cotire_get_target_compiler_flags _config _language _directory _target set (_compilerFlags "") cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compilerFlags) - message (STATUS "Target ${_target} compiler flags ${_compilerFlags}") + message (STATUS "Target ${_target} compiler flags: ${_compilerFlags}") endif() set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) endfunction() @@ -651,9 +642,6 @@ function (cotire_add_sys_root_paths _pathsVar) endif() endif() set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE) - if (COTIRE_DEBUG) - message (STATUS "${_pathsVar}=${${_pathsVar}}") - endif() endfunction() function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) @@ -696,7 +684,7 @@ function (cotire_get_source_compile_definitions _config _language _sourceFile _d list (APPEND _compileDefinitions ${_definitions}) endif() if (COTIRE_DEBUG AND _compileDefinitions) - message (STATUS "Source ${_sourceFile} compile definitions ${_compileDefinitions}") + message (STATUS "Source ${_sourceFile} compile definitions: ${_compileDefinitions}") endif() set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE) endfunction() @@ -725,7 +713,7 @@ function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar) list (APPEND _sourceUndefs ${_undefs}) endif() if (COTIRE_DEBUG AND _sourceUndefs) - message (STATUS "Source ${_sourceFile} ${_property} undefs ${_sourceUndefs}") + message (STATUS "Source ${_sourceFile} ${_property} undefs: ${_sourceUndefs}") endif() set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) endfunction() @@ -1081,9 +1069,6 @@ function (cotire_scan_includes _includesVar) message (STATUS "execute_process: ${_cmd}") endif() if (_option_COMPILER_ID MATCHES "MSVC") - if (COTIRE_DEBUG) - message (STATUS "clearing VS_UNICODE_OUTPUT") - endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -1359,12 +1344,13 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags # Clang options used # -H print the name of each header file used # -E invoke preprocessor + # -fno-color-diagnostics don't prints diagnostics in color if (_flags) # append to list - list (APPEND _flags -H -E) + list (APPEND _flags -H -E -fno-color-diagnostics) else() # return as a flag string - set (_flags "-H -E") + set (_flags "-H -E -fno-color-diagnostics") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1672,9 +1658,6 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) message (STATUS "execute_process: ${_cmd}") endif() if (_option_COMPILER_ID MATCHES "MSVC") - if (COTIRE_DEBUG) - message (STATUS "clearing VS_UNICODE_OUTPUT") - endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -1696,10 +1679,8 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") # GCC PCH support requires version >= 3.4 - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND - "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") - set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) + if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() @@ -1708,10 +1689,8 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel PCH support requires version >= 8.0.0 - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) - if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND - "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") - set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) + if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() @@ -1769,9 +1748,6 @@ function (cotire_make_single_unity_source_file_path _language _target _unityFile cotire_get_intermediate_dir(_baseDir) set (_unityFile "${_baseDir}/${_unityFileName}") set (${_unityFileVar} "${_unityFile}" PARENT_SCOPE) - if (COTIRE_DEBUG) - message(STATUS "${_unityFile}") - endif() endfunction() function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) @@ -1811,8 +1787,8 @@ function (cotire_make_unity_source_file_paths _language _target _maxIncludes _un list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") endif() set (${_unityFilesVar} ${_unityFiles} PARENT_SCOPE) - if (COTIRE_DEBUG) - message(STATUS "${_unityFiles}") + if (COTIRE_DEBUG AND _unityFiles) + message (STATUS "unity files: ${_unityFiles}") endif() endfunction() @@ -1923,7 +1899,8 @@ endfunction() function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar) set (_dependencySources "") # depend on target's generated source files - cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) if (_generatedSources) # but omit all generated source files that have the COTIRE_EXCLUDED property set to true cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources}) @@ -1940,25 +1917,26 @@ function (cotire_get_unity_source_dependencies _language _target _dependencySour endif() endif() if (COTIRE_DEBUG AND _dependencySources) - message (STATUS "${_language} ${_target} unity source depends on ${_dependencySources}") + message (STATUS "${_language} ${_target} unity source dependencies: ${_dependencySources}") endif() set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar) - # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") - cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) + # depend on target source files marked with custom COTIRE_DEPENDENCY property + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GCC and clang raise a fatal error if a file is not found during preprocessing # thus we depend on target's generated source files for prefix header generation - cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) if (_generatedSources) list (APPEND _dependencySources ${_generatedSources}) endif() endif() if (COTIRE_DEBUG AND _dependencySources) - message (STATUS "${_language} ${_target} prefix header DEPENDS ${_dependencySources}") + message (STATUS "${_language} ${_target} prefix header dependencies: ${_dependencySources}") endif() set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() @@ -1970,7 +1948,6 @@ function (cotire_generate_target_script _language _configurations _targetSourceD cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) # set up variables to be configured set (COTIRE_TARGET_LANGUAGE "${_language}") - cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) cotire_add_sys_root_paths(COTIRE_TARGET_IGNORE_PATH) get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) @@ -2002,7 +1979,8 @@ function (cotire_generate_target_script _language _configurations _targetSourceD set (_contentsHasGeneratorExpressions FALSE) foreach (_var IN LISTS _matchVars ITEMS XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES - CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 + CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION + CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") @@ -2038,10 +2016,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) list (GET _sourceFiles 0 _hostFile) - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) set (_flags "") cotire_add_pch_compilation_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") @@ -2082,10 +2059,9 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") list (REMOVE_AT _sourceFiles 0) - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) set (_flags "") cotire_add_prefix_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # make object files generated from source files depend on precompiled header @@ -2095,10 +2071,9 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix if (NOT _wholeTarget) # for makefile based generator, we force the inclusion of the prefix header for a subset # of the source files, if this is a multi-language target or has excluded files - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) set (_flags "") cotire_add_prefix_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target @@ -2112,10 +2087,9 @@ endfunction() function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) set (_sourceFiles ${ARGN}) # force the inclusion of the prefix header for the given source files - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) set (_flags "") cotire_add_prefix_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target @@ -2225,11 +2199,10 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) if (_prefixFile) - cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) set (_options COMPILE_OPTIONS) cotire_add_prefix_pch_inclusion_flags( - "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _options) set_property(TARGET ${_target} APPEND PROPERTY ${_options}) endif() @@ -2577,7 +2550,7 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (_maxIncludes 0) endif() if (COTIRE_DEBUG) - message (STATUS "${_target} unity source max includes = ${_maxIncludes}") + message (STATUS "${_target} unity source max includes: ${_maxIncludes}") endif() set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) endfunction() @@ -2688,22 +2661,7 @@ function (cotire_setup_pch_target _languages _configurations _target) endif() endfunction() -function (cotire_setup_unity_build_target _languages _configurations _targetSourceDir _target) - get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) - if (NOT _unityTargetName) - set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") - endif() - # determine unity target sub type - get_target_property(_targetType ${_target} TYPE) - if ("${_targetType}" STREQUAL "EXECUTABLE") - set (_unityTargetSubType "") - elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") - set (_unityTargetSubType "${CMAKE_MATCH_1}") - else() - message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.") - return() - endif() - # determine unity target sources +function (cotire_collect_unity_target_sources _target _languages _unityTargetSourcesVar) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_unityTargetSources ${_targetSourceFiles}) foreach (_language ${_languages}) @@ -2727,7 +2685,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour endif() endforeach() if (_nonExistingFiles) - if (COTIRE_VERBOSE) + if (COTIRE_DEBUG) message (STATUS "removing non-existing ${_nonExistingFiles} from ${_unityTargetName}") endif() list (REMOVE_ITEM _unityTargetSources ${_nonExistingFiles}) @@ -2737,16 +2695,43 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) +endfunction(cotire_collect_unity_target_sources) + +function (cotire_setup_unity_build_target _languages _configurations _targetSourceDir _target) + get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) + if (NOT _unityTargetName) + set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") + endif() + # determine unity target sub type + get_target_property(_targetType ${_target} TYPE) + if ("${_targetType}" STREQUAL "EXECUTABLE") + set (_unityTargetSubType "") + elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + set (_unityTargetSubType "${CMAKE_MATCH_1}") + else() + message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.") + return() + endif() + # determine unity target sources + set (_unityTargetSources "") + cotire_collect_unity_target_sources(${_target} "${_languages}" _unityTargetSources) + # handle automatic Qt processing get_target_property(_targetAutoMoc ${_target} AUTOMOC) get_target_property(_targetAutoUic ${_target} AUTOUIC) - if (_targetAutoMoc OR _targetAutoUic) + get_target_property(_targetAutoRcc ${_target} AUTORCC) + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) # if the original target sources are subject to CMake's automatic Qt processing, # also include implicitly generated _automoc.cpp file list (APPEND _unityTargetSources "${_target}_automoc.cpp") set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) endif() + # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created + set (CMAKE_AUTOMOC OFF) + set (CMAKE_AUTOUIC OFF) + set (CMAKE_AUTORCC OFF) if (COTIRE_DEBUG) - message (STATUS "add ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") + message (STATUS "add target ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") endif() # generate unity target if ("${_targetType}" STREQUAL "EXECUTABLE") @@ -2754,6 +2739,10 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + # depend on the original target's implicity generated _automoc target + add_dependencies(${_unityTargetName} ${_target}_automoc) + endif() # copy output location properties set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ @@ -2828,15 +2817,6 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ NO_SONAME SOVERSION VERSION) - # copy Qt stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - AUTORCC AUTORCC_OPTIONS) - if (_targetAutoMoc OR _targetAutoUic) - # do not copy the original target's AUTOMOC and AUTOUIC related properties, - # but depend on the original target's implicity generated _automoc target - add_dependencies(${_unityTargetName} ${_target}_automoc) - set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) - endif() # copy cmake stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) @@ -3020,7 +3000,7 @@ function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) endforeach() if (_filesToRemove) if (COTIRE_VERBOSE) - message (STATUS "removing ${_filesToRemove}") + message (STATUS "cleaning up ${_filesToRemove}") endif() file (REMOVE ${_filesToRemove}) endif() @@ -3030,6 +3010,7 @@ function (cotire_init_target _targetName) if (COTIRE_TARGETS_FOLDER) set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}") endif() + set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_ALL TRUE) if (MSVC_IDE) set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) endif() @@ -3117,14 +3098,6 @@ if (CMAKE_SCRIPT_MODE_FILE) message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") endif() - if (WIN32) - # for MSVC, compiler IDs may not always be set correctly - if (MSVC) - set (CMAKE_C_COMPILER_ID "MSVC") - set (CMAKE_CXX_COMPILER_ID "MSVC") - endif() - endif() - if (NOT COTIRE_BUILD_TYPE) set (COTIRE_BUILD_TYPE "None") endif() @@ -3198,7 +3171,7 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" - COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} @@ -3225,7 +3198,7 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" - COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} @@ -3266,9 +3239,6 @@ else() # cotire is being run in include mode # set up all variable and property definitions - unset (COTIRE_C_COMPILER_VERSION CACHE) - unset (COTIRE_CXX_COMPILER_VERSION CACHE) - if (NOT DEFINED COTIRE_DEBUG_INIT) if (DEFINED COTIRE_DEBUG) set (COTIRE_DEBUG_INIT ${COTIRE_DEBUG}) diff --git a/HISTORY.md b/HISTORY.md index 6cff4b1..6bed5a7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,11 @@ +## 1.7.1 (2015-04-06) + +* fix problem with CMake's automatic Qt processing for generated unity targets. +* added a section on common pitfalls when using cotire to the manual. +* remove obsolete code required for CMake versions older than 2.8.12. +* streamline debugging output. +# activate select CMake policies. + ## 1.7.0 (2015-03-29) * fix CMake 3.2 compatibility issues. diff --git a/MANUAL.md b/MANUAL.md index 10aaa46..8376ab8 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -688,8 +688,44 @@ left untouched. The property `COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH` can also be set on directories. A target inherits the property value from its enclosing directory. -cotire usage restrictions -------------------------- +common pitfalls +--------------- + +### always add the directory where `cotire.cmake` resides to the CMake module search + +If CMake issues the message `Unknown CMake command "cotire"`, double check that the cotire module +has been included correctly in your project. See the manual section "cotire basic usage". + +### do not modify a target's build related properties after applying cotire + +Cotire only considers build related settings of a target at the time of the `cotire` function call. +If target properties that control the build are changed after the call to the `cotire` function, +the build rules set up by cotire for the precompiled header and unity build may not work correctly. + +Don't do this: + + add_executable(example main.cpp example.cpp log.cpp log.h example.h) + cotire(example) + ... + set_target_properties(example PROPERTIES POSITION_INDEPENDENT_CODE ON) # affects build + + +### always apply cotire in the same source directory where a target has been added + +CMake targets are globally visible. Nevertheless, it is important that the `cotire` function is called +for a target in the exact same directory that creates the target with `add_library` or `add_executable`. + +Don't do this: + + add_subdirectory(src) + ... + cotire(mytarget) # mytarget added in src directory + +Cotire may fail to inspect the target's source files correctly, if the target has been added in a +different directory and you may get messages about missing source files. + +known issues +------------ ### using source files for multiple targets From e1d331d6e476f098b461977b9cf34954d8e6590d Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 6 Apr 2015 19:24:53 +0200 Subject: [PATCH 069/169] fix typo in history --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 6bed5a7..a0b597b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,7 +4,7 @@ * added a section on common pitfalls when using cotire to the manual. * remove obsolete code required for CMake versions older than 2.8.12. * streamline debugging output. -# activate select CMake policies. +* activate select CMake policies. ## 1.7.0 (2015-03-29) From d0eadcd2a230a8701d5310e34cc45ea9d6649df2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 22 Apr 2015 20:35:16 +0200 Subject: [PATCH 070/169] cotire 1.7.2 --- CMake/cotire.cmake | 490 +++++++++++++++++++++++---------------------- HISTORY.md | 7 + MANUAL.md | 4 +- 3 files changed, 262 insertions(+), 239 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index fd0ad87..0df9a4a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -94,7 +94,7 @@ if (POLICY CMP0054) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.1") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.2") include(CMakeParseArguments) include(ProcessorCount) @@ -141,7 +141,7 @@ macro (cotire_check_is_path_relative_to _path _isRelativeVar) endif() endmacro() -function (cotire_filter_language_source_files _language _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) +function (cotire_filter_language_source_files _language _target _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}") else() @@ -177,7 +177,6 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude set (_filteredSourceFiles "") set (_excludedSourceFiles "") foreach (_sourceFile ${_allSourceFiles}) - get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) @@ -192,42 +191,52 @@ function (cotire_filter_language_source_files _language _sourceFilesVar _exclude else() list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) if (_sourceIndex GREATER -1) - # consider source file - list (APPEND _filteredSourceFiles "${_sourceFile}") - elseif ("${_sourceLanguage}" STREQUAL "${_language}") - # add to excluded sources, if file is not ignored and has correct language without having the correct extension - list (APPEND _excludedSourceFiles "${_sourceFile}") + # consider source file unless it is excluded explicitly + get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) + if (_sourceIsExcluded) + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _filteredSourceFiles "${_sourceFile}") + endif() + else() + get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) + if ("${_sourceLanguage}" STREQUAL "${_language}") + # add to excluded sources, if file is not ignored and has correct language without having the correct extension + list (APPEND _excludedSourceFiles "${_sourceFile}") + endif() endif() endif() endif() endif() endif() endforeach() + # separate filtered source files from already cotired ones + # the COTIRE_TARGET property of a source file may be set while a target is being processed by cotire set (_sourceFiles "") set (_cotiredSourceFiles "") foreach (_sourceFile ${_filteredSourceFiles}) - get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) - get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) if (_sourceIsCotired) list (APPEND _cotiredSourceFiles "${_sourceFile}") - elseif (_sourceIsExcluded OR _sourceCompileFlags) - # add to excluded sources, if file has custom compile flags - list (APPEND _excludedSourceFiles "${_sourceFile}") else() - list (APPEND _sourceFiles "${_sourceFile}") + get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) + if (_sourceCompileFlags) + # add to excluded sources, if file has custom compile flags + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") + endif() endif() endforeach() if (COTIRE_DEBUG) - message (STATUS "All sources: ${ARGN}") if (_sourceFiles) - message (STATUS "Filtered ${_language} sources: ${_sourceFiles}") + message (STATUS "Filtered ${_target} ${_language} sources: ${_sourceFiles}") endif() if (_excludedSourceFiles) - message (STATUS "Excluded ${_language} sources: ${_excludedSourceFiles}") + message (STATUS "Excluded ${_target} ${_language} sources: ${_excludedSourceFiles}") endif() if (_cotiredSourceFiles) - message (STATUS "Cotired ${_language} sources: ${_cotiredSourceFiles}") + message (STATUS "Cotired ${_target} ${_language} sources: ${_cotiredSourceFiles}") endif() endif() set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE) @@ -301,26 +310,27 @@ function (cotire_copy_set_properites _configurations _type _source _target) endforeach() endfunction() -function (cotire_get_target_link_libraries_for_usage_requirements _target _targetLinkLibrariesVar) - set (_targetLinkLibraries "") +function (cotire_get_target_usage_requirements _target _targetRequirementsVar) + set (_targetRequirements "") get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) while (_librariesToProcess) # remove from head list (GET _librariesToProcess 0 _library) list (REMOVE_AT _librariesToProcess 0) - list (FIND _targetLinkLibraries ${_library} _index) - if (_index LESS 0) - list (APPEND _targetLinkLibraries ${_library}) - # process transitive libraries - if (TARGET ${_library}) + if (TARGET ${_library}) + list (FIND _targetRequirements ${_library} _index) + if (_index LESS 0) + list (APPEND _targetRequirements ${_library}) + # process transitive libraries get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) if (_libraries) list (APPEND _librariesToProcess ${_libraries}) + list (REMOVE_DUPLICATES _librariesToProcess) endif() endif() endif() endwhile() - set (${_targetLinkLibrariesVar} ${_targetLinkLibraries} PARENT_SCOPE) + set (${_targetRequirementsVar} ${_targetRequirements} PARENT_SCOPE) endfunction() function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar) @@ -369,7 +379,7 @@ function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _ set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) endfunction() -function (cotire_get_target_compile_flags _config _language _directory _target _flagsVar) +function (cotire_get_target_compile_flags _config _language _target _flagsVar) string (TOUPPER "${_config}" _upperConfig) # collect options from CMake language variables set (_compileFlags "") @@ -379,25 +389,6 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ if (CMAKE_${_language}_FLAGS_${_upperConfig}) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}") endif() - if (_target) - # handle the POSITION_INDEPENDENT_CODE target property - get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) - if (_targetPIC) - get_target_property(_targetType ${_target} TYPE) - if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") - elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) - set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") - endif() - endif() - endif() - if (_directory) - # add_definitions may have been used to add flags to the compiler command - get_directory_property(_dirDefinitions DIRECTORY "${_directory}" DEFINITIONS) - if (_dirDefinitions) - set (_compileFlags "${_compileFlags} ${_dirDefinitions}") - endif() - endif() if (_target) # add target compile flags get_target_property(_targetflags ${_target} COMPILE_FLAGS) @@ -421,17 +412,27 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ endif() # interface compile options from linked library targets if (_target) - set (_linkLibraries "") - cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) - foreach (_library ${_linkLibraries}) - if (TARGET ${_library}) - get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) - if (_targetOptions) - list (APPEND _compileFlags ${_targetOptions}) - endif() + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS) + if (_targetOptions) + list (APPEND _compileFlags ${_targetOptions}) endif() endforeach() endif() + # handle the POSITION_INDEPENDENT_CODE target property + if (_target) + get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) + if (_targetPIC) + get_target_property(_targetType ${_target} TYPE) + if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") + elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") + endif() + endif() + endif() # platform specific flags if (APPLE) get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) @@ -464,23 +465,23 @@ function (cotire_get_target_compile_flags _config _language _directory _target _ set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() -function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar _systemIncludeDirsVar) +function (cotire_get_target_include_directories _config _language _target _includeDirsVar _systemIncludeDirsVar) set (_includeDirs "") set (_systemIncludeDirs "") # default include dirs if (CMAKE_INCLUDE_CURRENT_DIR) - list (APPEND _includeDirs "${_targetBinaryDir}") - list (APPEND _includeDirs "${_targetSourceDir}") + list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}") + list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}") endif() # parse additional include directories from target compile flags set (_targetFlags "") - cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "I" _dirs _ignore ${_targetFlags}) if (_dirs) list (APPEND _includeDirs ${_dirs}) endif() # target include directories - get_directory_property(_dirs DIRECTORY "${_targetSourceDir}" INCLUDE_DIRECTORIES) + get_directory_property(_dirs DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES) if (_target) get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) if (_targetDirs) @@ -493,18 +494,16 @@ function (cotire_get_target_include_directories _config _language _targetSourceD endif() # interface include directories from linked library targets if (_target) - set (_linkLibraries "") - cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) - foreach (_library ${_linkLibraries}) - if (TARGET ${_library}) - get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) - if (_targetDirs) - list (APPEND _dirs ${_targetDirs}) - endif() - get_target_property(_targetDirs ${_library} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) - if (_targetDirs) - list (APPEND _systemIncludeDirs ${_targetDirs}) - endif() + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_targetDirs ${_linkedTarget} INTERFACE_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_linkedTarget} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) endif() endforeach() endif() @@ -560,7 +559,7 @@ function (cotire_get_target_export_symbol _target _exportSymbolVar) set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE) endfunction() -function (cotire_get_target_compile_definitions _config _language _directory _target _definitionsVar) +function (cotire_get_target_compile_definitions _config _language _target _definitionsVar) string (TOUPPER "${_config}" _upperConfig) set (_configDefinitions "") # CMAKE_INTDIR for multi-configuration build systems @@ -573,11 +572,11 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta list (APPEND _configDefinitions "${_defineSymbol}") endif() # directory compile definitions - get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS) + get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() - get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS_${_upperConfig}) + get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() @@ -591,20 +590,18 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta list (APPEND _configDefinitions ${_definitions}) endif() # interface compile definitions from linked library targets - set (_linkLibraries "") - cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) - foreach (_library ${_linkLibraries}) - if (TARGET ${_library}) - get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) - if (_definitions) - list (APPEND _configDefinitions ${_definitions}) - endif() + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) endif() endforeach() # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled set (_targetFlags "") - cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) @@ -616,10 +613,10 @@ function (cotire_get_target_compile_definitions _config _language _directory _ta set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) endfunction() -function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) +function (cotire_get_target_compiler_flags _config _language _target _compilerFlagsVar) # parse target compile flags omitting compile definitions and include directives set (_targetFlags "") - cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) set (_compilerFlags "") cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compilerFlags) @@ -804,30 +801,38 @@ macro (cotire_add_compile_flags_to_cmd _cmdVar) endmacro() function (cotire_check_file_up_to_date _fileIsUpToDateVar _file) - set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) - set (_triggerFile "") - foreach (_dependencyFile ${ARGN}) - if (EXISTS "${_dependencyFile}" AND "${_dependencyFile}" IS_NEWER_THAN "${_file}") - set (_triggerFile "${_dependencyFile}") - break() - endif() - endforeach() - get_filename_component(_fileName "${_file}" NAME) if (EXISTS "${_file}") + set (_triggerFile "") + foreach (_dependencyFile ${ARGN}) + if (EXISTS "${_dependencyFile}") + # IS_NEWER_THAN returns TRUE if both files have the same timestamp + # thus we do the comparison in both directions to exclude ties + if ("${_dependencyFile}" IS_NEWER_THAN "${_file}" AND + NOT "${_file}" IS_NEWER_THAN "${_dependencyFile}") + set (_triggerFile "${_dependencyFile}") + break() + endif() + endif() + endforeach() if (_triggerFile) if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) message (STATUS "${_fileName} update triggered by ${_triggerFile} change.") endif() + set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) else() if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) message (STATUS "${_fileName} is up-to-date.") endif() set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE) endif() else() if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) message (STATUS "${_fileName} does not exist yet.") endif() + set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) endif() endfunction() @@ -1046,6 +1051,9 @@ function (cotire_scan_includes _includesVar) if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() set (_cmd "${_option_COMPILER_EXECUTABLE}" ${_option_COMPILER_ARG1}) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) @@ -1073,8 +1081,11 @@ function (cotire_scan_includes _includesVar) unset (ENV{VS_UNICODE_OUTPUT}) endif() execute_process( - COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE _result OUTPUT_QUIET ERROR_VARIABLE _output) + COMMAND ${_cmd} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE _result + OUTPUT_QUIET + ERROR_VARIABLE _output) if (_result) message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.") endif() @@ -1149,7 +1160,7 @@ function (cotire_generate_unity_source _unityFile) set(_options "") set(_oneValueArgs LANGUAGE) set(_multiValueArgs - DEPENDS SOURCE_LOCATIONS SOURCES_COMPILE_DEFINITIONS + DEPENDS SOURCES_COMPILE_DEFINITIONS PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) @@ -1183,7 +1194,6 @@ function (cotire_generate_unity_source _unityFile) endif() endif() set (_compileUndefinitions "") - set (_index 0) foreach (_sourceFile ${_sourceFiles}) cotire_get_source_compile_definitions( "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions @@ -1215,18 +1225,12 @@ function (cotire_generate_unity_source _unityFile) list (INSERT _compileUndefinitions 0 "${_definition}") endif() endforeach() - if (_option_SOURCE_LOCATIONS) - # use explicitly provided source file location - list (GET _option_SOURCE_LOCATIONS ${_index} _sourceFileLocation) - else() - # use absolute path as source file location - get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE) - endif() + # use absolute path as source file location + get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE) if (WIN32) file (TO_NATIVE_PATH "${_sourceFileLocation}" _sourceFileLocation) endif() list (APPEND _contents "#include \"${_sourceFileLocation}\"") - math (EXPR _index "${_index} + 1") endforeach() if (_compileUndefinitions) cotire_append_undefs(_contents ${_compileUndefinitions}) @@ -1253,9 +1257,16 @@ function (cotire_generate_prefix_header _prefixFile) INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) if (_prefixFileIsUpToDate) + # create empty log file set (_unparsedLinesFile "${_prefixFile}.log") file (WRITE "${_unparsedLinesFile}" "") return() @@ -1296,8 +1307,7 @@ function (cotire_generate_prefix_header _prefixFile) if (_unparsedLines) if (COTIRE_VERBOSE OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) - file (RELATIVE_PATH _unparsedLinesFileRelPath "${CMAKE_BINARY_DIR}" "${_unparsedLinesFile}") - message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFileRelPath}") + message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() @@ -1646,6 +1656,9 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) @@ -1670,7 +1683,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) endif() endfunction() -function (cotire_check_precompiled_header_support _language _targetSourceDir _target _msgVar) +function (cotire_check_precompiled_header_support _language _target _msgVar) set (_unsupportedCompiler "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") @@ -1709,7 +1722,7 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta cotire_get_configuration_types(_configs) foreach (_config ${_configs}) set (_targetFlags "") - cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) if (_numberOfArchitectures GREATER 1) @@ -1845,11 +1858,11 @@ function (cotire_make_prefix_file_path _language _target _prefixFileVar) endif() endfunction() -function (cotire_make_pch_file_path _language _targetSourceDir _target _pchFileVar) +function (cotire_make_pch_file_path _language _target _pchFileVar) cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) set (${_pchFileVar} "" PARENT_SCOPE) if (_prefixFileBaseName AND _prefixFileName) - cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _msg) + cotire_check_precompiled_header_support("${_language}" "${_target}" _msg) if (NOT _msg) if (XCODE) # For Xcode, we completely hand off the compilation of the prefix header to the IDE @@ -1941,11 +1954,10 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() -function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar _targetConfigScriptVar) - set (COTIRE_TARGET_SOURCES ${ARGN}) - cotire_get_source_file_property_values(COTIRE_TARGET_SOURCE_LOCATIONS LOCATION ${COTIRE_TARGET_SOURCES}) - cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) - cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) +function (cotire_generate_target_script _language _configurations _target _targetScriptVar _targetConfigScriptVar) + set (_targetSources ${ARGN}) + cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${_targetSources}) + cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${_targetSources}) # set up variables to be configured set (COTIRE_TARGET_LANGUAGE "${_language}") get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) @@ -1956,21 +1968,34 @@ function (cotire_generate_target_script _language _configurations _targetSourceD get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) get_target_property(COTIRE_TARGET_INCLUDE_PRIORITY_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH) - cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) - cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${_targetSources}) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${_targetSources}) string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" COTIRE_INCLUDE_SYSTEM_FLAG) set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) cotire_get_target_include_directories( - "${_config}" "${_language}" "${_targetSourceDir}" "${_targetBinaryDir}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}) + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}) cotire_get_target_compile_definitions( - "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) cotire_get_target_compiler_flags( - "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) cotire_get_source_files_compile_definitions( - "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${COTIRE_TARGET_SOURCES}) + "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${_targetSources}) endforeach() + # set up COTIRE_TARGET_SOURCES + set (COTIRE_TARGET_SOURCES "") + foreach (_sourceFile ${_targetSources}) + get_source_file_property(_generated "${_sourceFile}" GENERATED) + if (_generated) + # use absolute paths for generated files only, retrieving the LOCATION property is an expensive operation + get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION) + list (APPEND COTIRE_TARGET_SOURCES "${_sourceLocation}") + else() + list (APPEND COTIRE_TARGET_SOURCES "${_sourceFile}") + endif() + endforeach() + # copy variable definitions to cotire target script get_cmake_property(_vars VARIABLES) string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") # remove COTIRE_VERBOSE which is passed as a CMake define on command line @@ -1992,6 +2017,7 @@ function (cotire_generate_target_script _language _configurations _targetSourceD endif() endif() endforeach() + # generate target script file get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) @@ -2007,31 +2033,27 @@ function (cotire_generate_target_script _language _configurations _targetSourceD set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) endfunction() -function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _targetScript _prefixFile _pchFile) +function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we attach the precompiled header compilation to the first source file + # for Visual Studio and Intel, we attach the precompiled header compilation to the host file # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) - file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) - file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) - list (GET _sourceFiles 0 _hostFile) set (_flags "") cotire_add_pch_compilation_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") - # make object file generated from first source file depend on prefix header + # make object file generated from host file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") - # mark first source file as cotired to prevent it from being used in another cotired target + # mark host file as cotired to prevent it from being used in another cotired target set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") endif() elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) - list (GET _sourceFiles 0 _hostFile) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") if (COTIRE_DEBUG) @@ -2043,22 +2065,22 @@ function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _ COMMAND ${_cmds} DEPENDS "${_prefixFile}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" - WORKING_DIRECTORY "${_targetSourceDir}" - COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" + VERBATIM) endif() endif() endfunction() -function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) - set (_sourceFiles ${ARGN}) +function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile _hostFile) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we include the precompiled header in all but the first source file - # the first source file does the precompiled header compilation, see cotire_setup_pch_file_compilation + # for Visual Studio and Intel, we include the precompiled header in all but the host file + # the host file does the precompiled header compilation, see cotire_setup_pch_file_compilation + set (_sourceFiles ${ARGN}) list (LENGTH _sourceFiles _numberOfSourceFiles) - if (_numberOfSourceFiles GREATER 1) + if (_numberOfSourceFiles GREATER 0) # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") - list (REMOVE_AT _sourceFiles 0) set (_flags "") cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" @@ -2068,6 +2090,7 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + set (_sourceFiles ${_hostFile} ${ARGN}) if (NOT _wholeTarget) # for makefile based generator, we force the inclusion of the prefix header for a subset # of the source files, if this is a multi-language target or has excluded files @@ -2088,9 +2111,10 @@ function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) set (_sourceFiles ${ARGN}) # force the inclusion of the prefix header for the given source files set (_flags "") + set (_pchFile "") cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" - "${_prefixFile}" "" _flags) + "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") @@ -2110,21 +2134,12 @@ function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (${_propertyValueVar} "" PARENT_SCOPE) endfunction() -function (cotire_setup_combine_command _language _sourceDir _targetScript _joinedFile _cmdsVar) +function (cotire_setup_combine_command _language _targetScript _joinedFile _cmdsVar) set (_files ${ARGN}) set (_filesPaths "") foreach (_file ${_files}) - if (IS_ABSOLUTE "${_file}") - set (_filePath "${_file}") - else() - get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) - endif() - file (RELATIVE_PATH _fileRelPath "${_sourceDir}" "${_filePath}") - if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") - list (APPEND _filesPaths "${_fileRelPath}") - else() - list (APPEND _filesPaths "${_filePath}") - endif() + get_filename_component(_filePath "${_file}" ABSOLUTE) + list (APPEND _filesPaths "${_filePath}") endforeach() cotire_set_cmd_to_prologue(_prefixCmd) list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") @@ -2155,15 +2170,15 @@ function (cotire_setup_combine_command _language _sourceDir _targetScript _joine COMMAND ${_prefixCmd} DEPENDS ${_files} COMMENT "${_comment}" - WORKING_DIRECTORY "${_sourceDir}" VERBATIM) + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _wholeTarget) +function (cotire_setup_target_pch_usage _languages _target _wholeTarget) if (XCODE) # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers - # if necessary, we also generate a single prefix header which includes all language specific prefix headers set (_prefixFiles "") foreach (_language ${_languages}) get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) @@ -2174,18 +2189,25 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who set (_cmds ${ARGN}) list (LENGTH _prefixFiles _numberOfPrefixFiles) if (_numberOfPrefixFiles GREATER 1) - cotire_make_prefix_file_path("" ${_target} _prefixHeader) - cotire_setup_combine_command("" "${_targetSourceDir}" "" "${_prefixHeader}" _cmds ${_prefixFiles}) + # we also generate a generic, single prefix header which includes all language specific prefix headers + set (_language "") + set (_targetScript "") + cotire_make_prefix_file_path("${_language}" ${_target} _prefixHeader) + cotire_setup_combine_command("${_language}" "${_targetScript}" "${_prefixHeader}" _cmds ${_prefixFiles}) else() set (_prefixHeader "${_prefixFiles}") endif() if (COTIRE_DEBUG) message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}") endif() - add_custom_command(TARGET "${_target}" + # because CMake PRE_BUILD command does not support dependencies, + # we check dependencies explicity in cotire script mode when the pre-build action is run + add_custom_command( + TARGET "${_target}" PRE_BUILD ${_cmds} - WORKING_DIRECTORY "${_targetSourceDir}" - COMMENT "Updating target ${_target} prefix headers" VERBATIM) + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Updating target ${_target} prefix headers" + VERBATIM) # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") @@ -2211,11 +2233,10 @@ function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _who endif() endfunction() -function (cotire_setup_unity_generation_commands _language _targetSourceDir _target _targetScript _targetConfigScript _unityFiles _cmdsVar) +function (cotire_setup_unity_generation_commands _language _target _targetScript _targetConfigScript _unityFiles _cmdsVar) set (_dependencySources "") cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) foreach (_unityFile ${_unityFiles}) - file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) # set up compiled unity source dependencies via OBJECT_DEPENDS # this ensures that missing source files are generated before the unity file is compiled @@ -2243,6 +2264,7 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar # CMake 3.1.0 supports generator expressions in arguments to DEPENDS set (_unityCmdDepends "${_targetConfigScript}") endif() + file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}") endif() @@ -2251,19 +2273,20 @@ function (cotire_setup_unity_generation_commands _language _targetSourceDir _tar COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends} COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" - WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) endforeach() list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetConfigScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) + cotire_setup_combine_command(${_language} "${_targetConfigScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFile _cmdsVar) +function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFile _cmdsVar) set (_sourceFiles ${ARGN}) set (_dependencySources "") cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) @@ -2285,12 +2308,13 @@ function (cotire_setup_prefix_generation_command _language _target _targetSource COMMAND ${_prefixCmd} DEPENDS "${_unityFile}" ${_dependencySources} COMMENT "${_comment}" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_prefix_generation_from_unity_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) +function (cotire_setup_prefix_generation_from_unity_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma @@ -2302,21 +2326,21 @@ function (cotire_setup_prefix_generation_from_unity_command _language _target _t if (_numberOfUnityFiles GREATER 1) cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) cotire_setup_prefix_generation_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" + ${_language} ${_target} "${_targetScript}" "${_prefixSourceFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) else() cotire_setup_prefix_generation_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" + ${_language} ${_target} "${_targetScript}" "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) endif() if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # set up generation of a prefix source file which includes the prefix header - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixSourceFile}) + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_prefix_generation_from_provided_command _language _target _targetSourceDir _targetScript _prefixFile _cmdsVar) +function (cotire_setup_prefix_generation_from_provided_command _language _target _targetScript _prefixFile _cmdsVar) set (_prefixHeaderFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma @@ -2324,10 +2348,10 @@ function (cotire_setup_prefix_generation_from_provided_command _language _target else() set (_prefixSourceFile "${_prefixFile}") endif() - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # set up generation of a prefix source file which includes the prefix header - cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() @@ -2431,7 +2455,7 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) endfunction() -function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar _wholeTargetVar) +function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTargetVar) set (_languages ${ARGN}) set (_allSourceFiles "") set (_allExcludedSourceFiles "") @@ -2452,7 +2476,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag return() endif() if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$") - cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _disableMsg) + cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) if (_disableMsg) set (_targetUsePCH FALSE) endif() @@ -2460,7 +2484,7 @@ function (cotire_choose_target_languages _targetSourceDir _target _targetLanguag set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") - cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (_sourceFiles OR _excludedSources OR _cotiredSources) list (APPEND _targetLanguages ${_language}) endif() @@ -2555,13 +2579,13 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) endfunction() -function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTarget _cmdsVar) +function (cotire_process_target_language _language _configurations _target _wholeTarget _cmdsVar) set (${_cmdsVar} "" PARENT_SCOPE) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") - cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (NOT _sourceFiles AND NOT _cotiredSources) return() endif() @@ -2572,24 +2596,24 @@ function (cotire_process_target_language _language _configurations _targetSource set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources}) endif() cotire_generate_target_script( - ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) + ${_language} "${_configurations}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() endif() cotire_setup_unity_generation_commands( - ${_language} "${_targetSourceDir}" ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) if (_prefixFile) # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) cotire_setup_prefix_generation_from_provided_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_prefix_generation_from_unity_command( - ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() # check if selected language has enough sources at all list (LENGTH _sourceFiles _numberOfSources) @@ -2599,10 +2623,11 @@ function (cotire_process_target_language _language _configurations _targetSource get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) endif() if (_targetUsePCH) - cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) + cotire_make_pch_file_path(${_language} ${_target} _pchFile) if (_pchFile) + # first file in _sourceFiles is passed as the host file cotire_setup_pch_file_compilation( - ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) cotire_setup_pch_file_inclusion( ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) endif() @@ -2628,8 +2653,11 @@ function (cotire_setup_clean_target _target) cotire_set_cmd_to_prologue(_cmds) get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" ABSOLUTE) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${_outputDir}" "${COTIRE_INTDIR}" "${_target}") - add_custom_target(${_cleanTargetName} COMMAND ${_cmds} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Cleaning up target ${_target} cotire generated files" VERBATIM) + add_custom_target(${_cleanTargetName} + COMMAND ${_cmds} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Cleaning up target ${_target} cotire generated files" + VERBATIM) cotire_init_target("${_cleanTargetName}") endif() endfunction() @@ -2671,34 +2699,18 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") - cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (_sourceFiles OR _cotiredSources) list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources}) endif() - # if cotire is applied to a target which has not been added in the current source dir, - # non-existing files cannot be referenced from the unity build target (this is a CMake restriction) - if (NOT "${_targetSourceDir}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - set (_nonExistingFiles "") - foreach (_file ${_unityTargetSources}) - if (NOT EXISTS "${_file}") - list (APPEND _nonExistingFiles "${_file}") - endif() - endforeach() - if (_nonExistingFiles) - if (COTIRE_DEBUG) - message (STATUS "removing non-existing ${_nonExistingFiles} from ${_unityTargetName}") - endif() - list (REMOVE_ITEM _unityTargetSources ${_nonExistingFiles}) - endif() - endif() # add unity source files instead list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) -endfunction(cotire_collect_unity_target_sources) +endfunction() -function (cotire_setup_unity_build_target _languages _configurations _targetSourceDir _target) +function (cotire_setup_unity_build_target _languages _configurations _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (NOT _unityTargetName) set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") @@ -2753,6 +2765,7 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() + # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) cotire_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) @@ -2858,15 +2871,9 @@ endfunction(cotire_setup_unity_build_target) function (cotire_target _target) set(_options "") - set(_oneValueArgs SOURCE_DIR BINARY_DIR) + set(_oneValueArgs "") set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) - if (NOT _option_SOURCE_DIR) - set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - endif() - if (NOT _option_BINARY_DIR) - set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") - endif() if (NOT _option_LANGUAGES) get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) endif() @@ -2909,25 +2916,24 @@ function (cotire_target _target) file (MAKE_DIRECTORY "${_baseDir}") endif() # choose languages that apply to the target - cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) + cotire_choose_target_languages("${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) if (NOT _targetLanguages) return() endif() set (_cmds "") foreach (_language ${_targetLanguages}) - cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" - "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} ${_wholeTarget} _cmd) + cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" ${_target} ${_wholeTarget} _cmd) if (_cmd) list (APPEND _cmds ${_cmd}) endif() endforeach() get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) if (_targetAddSCU) - cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" "${_option_SOURCE_DIR}" ${_target}) + cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) - cotire_setup_target_pch_usage("${_targetLanguages}" "${_option_SOURCE_DIR}" ${_target} ${_wholeTarget} ${_cmds}) + cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds}) cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) endif() get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) @@ -3019,7 +3025,9 @@ endfunction() function (cotire_add_to_pch_all_target _pchTargetName) set (_targetName "${COTIRE_PCH_ALL_TARGET_NAME}") if (NOT TARGET "${_targetName}") - add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + add_custom_target("${_targetName}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) cotire_init_target("${_targetName}") endif() cotire_setup_clean_all_target() @@ -3029,7 +3037,9 @@ endfunction() function (cotire_add_to_unity_all_target _unityTargetName) set (_targetName "${COTIRE_UNITY_BUILD_ALL_TARGET_NAME}") if (NOT TARGET "${_targetName}") - add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) + add_custom_target("${_targetName}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) cotire_init_target("${_targetName}") endif() cotire_setup_clean_all_target() @@ -3041,28 +3051,24 @@ function (cotire_setup_clean_all_target) if (NOT TARGET "${_targetName}") cotire_set_cmd_to_prologue(_cmds) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${CMAKE_BINARY_DIR}" "${COTIRE_INTDIR}") - add_custom_target(${_targetName} COMMAND ${_cmds} - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Cleaning up all cotire generated files" VERBATIM) + add_custom_target(${_targetName} + COMMAND ${_cmds} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Cleaning up all cotire generated files" + VERBATIM) cotire_init_target("${_targetName}") endif() endfunction() function (cotire) set(_options "") - set(_oneValueArgs SOURCE_DIR BINARY_DIR) + set(_oneValueArgs "") set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_targets ${_option_UNPARSED_ARGUMENTS}) - if (NOT _option_SOURCE_DIR) - set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - endif() - if (NOT _option_BINARY_DIR) - set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") - endif() foreach (_target ${_targets}) if (TARGET ${_target}) - cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS} - SOURCE_DIR "${_option_SOURCE_DIR}" BINARY_DIR "${_option_BINARY_DIR}") + cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS}) else() message (WARNING "cotire: ${_target} is not a target.") endif() @@ -3110,7 +3116,6 @@ if (CMAKE_SCRIPT_MODE_FILE) list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) if (_index GREATER -1) set (_sources ${COTIRE_TARGET_SOURCES}) - set (_sourceLocations ${COTIRE_TARGET_SOURCE_LOCATIONS}) set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) else() if (COTIRE_DEBUG) @@ -3136,12 +3141,10 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) - cotire_select_unity_source_files("${COTIRE_ARGV3}" _sourceLocations ${_sourceLocations}) cotire_generate_unity_source( "${COTIRE_ARGV3}" ${_sources} LANGUAGE "${COTIRE_TARGET_LANGUAGE}" - SOURCE_LOCATIONS ${_sourceLocations} SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} PRE_UNDEFS ${_targetPreUndefs} POST_UNDEFS ${_targetPostUndefs} @@ -3209,9 +3212,11 @@ if (CMAKE_SCRIPT_MODE_FILE) elseif ("${COTIRE_ARGV1}" STREQUAL "combine") if (COTIRE_TARGET_LANGUAGE) - set (_startIndex 3) + set (_combinedFile "${COTIRE_ARGV3}") + set (_startIndex 4) else() - set (_startIndex 2) + set (_combinedFile "${COTIRE_ARGV2}") + set (_startIndex 3) endif() set (_files "") foreach (_index RANGE ${_startIndex} ${COTIRE_ARGC}) @@ -3220,10 +3225,21 @@ if (CMAKE_SCRIPT_MODE_FILE) endif() endforeach() + if (XCODE) + # executing pre-build action under Xcode, check dependency on files to be combined + set (_dependsOption DEPENDS ${_files}) + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + if (COTIRE_TARGET_LANGUAGE) - cotire_generate_unity_source(${_files} LANGUAGE "${COTIRE_TARGET_LANGUAGE}") + cotire_generate_unity_source( + "${_combinedFile}" ${_files} + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + ${_dependsOption}) else() - cotire_generate_unity_source(${_files}) + cotire_generate_unity_source("${_combinedFile}" ${_files} ${_dependsOption}) endif() elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup") diff --git a/HISTORY.md b/HISTORY.md index a0b597b..83d839d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.7.2 (2015-04-22) + +* reduce configure time overhead. +* fix bug with dependency checking when using Xcode. +* remove obsolete code required for CMake versions older than 2.8.12. +* streamline debugging output. + ## 1.7.1 (2015-04-06) * fix problem with CMake's automatic Qt processing for generated unity targets. diff --git a/MANUAL.md b/MANUAL.md index 8376ab8..5e11adf 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -691,7 +691,7 @@ inherits the property value from its enclosing directory. common pitfalls --------------- -### always add the directory where `cotire.cmake` resides to the CMake module search +### include the `cotire.cmake` module correclty If CMake issues the message `Unknown CMake command "cotire"`, double check that the cotire module has been included correctly in your project. See the manual section "cotire basic usage". @@ -722,7 +722,7 @@ Don't do this: cotire(mytarget) # mytarget added in src directory Cotire may fail to inspect the target's source files correctly, if the target has been added in a -different directory and you may get messages about missing source files. +different directory and you may get odd messages about missing source files. known issues ------------ From bed5526c42815fbfc59e7949fd6a683b28fb1b9b Mon Sep 17 00:00:00 2001 From: Pierre-Luc Date: Tue, 26 May 2015 19:37:48 +0200 Subject: [PATCH 071/169] Fix typo in MANUAL.md Correct 'make us' to 'make use'. --- MANUAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANUAL.md b/MANUAL.md index 5e11adf..e72ee5d 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -298,7 +298,7 @@ ensure that the project builds properly without cotire. ### disabling precompiled headers and unity builds -If the target's build process should not be modified to make us of the generated precompiled +If the target's build process should not be modified to make use of the generated precompiled header, the target property `COTIRE_ENABLE_PRECOMPILED_HEADER` can be set to `FALSE`: set_target_properties(example PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) From d99d509b01f9e07d3f3c1c048215027d93b40bfb Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 10:57:32 +0200 Subject: [PATCH 072/169] ignore .idea dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7f6efa0..ae81b2e 100755 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build*/ .DS_Store .project +.idea From 39744c50bc606e27624949bd115c26786d91defa Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 10:57:59 +0200 Subject: [PATCH 073/169] start 1.7.3 --- CMake/cotire.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 0df9a4a..1c824a0 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -95,6 +95,7 @@ endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") set (COTIRE_CMAKE_MODULE_VERSION "1.7.2") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.3") include(CMakeParseArguments) include(ProcessorCount) From 6121cb6b4849689b237429ce3ffd184df68b4c81 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 10:59:24 +0200 Subject: [PATCH 074/169] handle language standard target properties --- CMake/cotire.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 1c824a0..4f86b2c 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -422,6 +422,27 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) endif() endforeach() endif() + # handle language standard properties + if (_target) + get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) + get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) + get_target_property(_targetLanguageStandardRequired ${_target} ${_language}_STANDARD_REQUIRED) + if (_targetLanguageExtensions) + if (CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION}") + endif() + elseif (_targetLanguageStandard) + if (_targetLanguageStandardRequired) + if (CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION}") + endif() + else() + if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") + endif() + endif() + endif() + endif() # handle the POSITION_INDEPENDENT_CODE target property if (_target) get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) From b7e36448fb92c7610f57b2a336e6f8c1635af850 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 11:00:08 +0200 Subject: [PATCH 075/169] remove 1.7.2 --- CMake/cotire.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 4f86b2c..6c99228 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -94,7 +94,6 @@ if (POLICY CMP0054) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.2") set (COTIRE_CMAKE_MODULE_VERSION "1.7.3") include(CMakeParseArguments) From 65c7e85f186d41991d10f072eaebb3cb3b235bec Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 11:33:27 +0200 Subject: [PATCH 076/169] apply user provided prefix header to unity build target --- CMake/cotire.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 6c99228..22e29f9 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2731,6 +2731,20 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) endfunction() +function (cotire_setup_unity_target_pch_usage _languages _target) + foreach (_language ${_languages}) + get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) + if (_unityFiles) + get_property(_userPrefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + if (_userPrefixFile AND _prefixFile) + # user provided prefix header must be included unconditionally by unity sources + cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_unityFiles}) + endif() + endif() + endforeach() +endfunction() + function (cotire_setup_unity_build_target _languages _configurations _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (NOT _unityTargetName) @@ -2956,6 +2970,9 @@ function (cotire_target _target) if (_targetUsePCH) cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds}) cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + if (_targetAddSCU) + cotire_setup_unity_target_pch_usage("${_targetLanguages}" ${_target}) + endif() endif() get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) if (_targetAddCleanTarget) From dcf05bb6a87583d3691603e6c18e942ef0f3f383 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 11:45:38 +0200 Subject: [PATCH 077/169] remove effect of COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES on unity targets --- CMake/cotire.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 22e29f9..69e9a67 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2587,10 +2587,6 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) endif() list (LENGTH _sourceFiles _numberOfSources) math (EXPR _maxIncludes "(${_numberOfSources} + ${_numberOfThreads} - 1) / ${_numberOfThreads}") - # a unity source segment must not contain less than COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES files - if (_maxIncludes LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) - set (_maxIncludes ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) - endif() elseif (NOT _maxIncludes MATCHES "[0-9]+") set (_maxIncludes 0) endif() From d1b6fc0f68fa99e428172ad19359b2d50e9d7ae9 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 5 Jul 2015 11:50:48 +0200 Subject: [PATCH 078/169] add COTIRE_UNITY_TARGET_NAME example to manual --- MANUAL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MANUAL.md b/MANUAL.md index e72ee5d..5952fae 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -258,6 +258,7 @@ generated files (`` can be set to `CXX` or `C`). The target property get_target_property(_unitySource example COTIRE_CXX_UNITY_SOURCE) get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) get_target_property(_precompiledHeader example COTIRE_CXX_PRECOMPILED_HEADER) + get_target_property(_unityTargetName example COTIRE_UNITY_TARGET_NAME) If a source file's `COMPILE_FLAGS` are modified by cotire, it sets the source file property `COTIRE_TARGET` to the name of the target, that the source file's build command has been From 17725e64ccd9ce3324b3ac932abd83cfecb2727e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 25 Jul 2015 19:26:13 +0200 Subject: [PATCH 079/169] update history --- HISTORY.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 83d839d..426c075 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.7.3 (2015-07-25) + +* handle language standard target properties (e.g., `CXX_STANDARD`). +* apply user provided prefix header to unity build target. +* remove effect of `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` on generated unity target. +* manual updates. + ## 1.7.2 (2015-04-22) * reduce configure time overhead. From c299bfe3261be770426ce1a781402bb7626c4a91 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 12 Sep 2015 20:19:51 +0200 Subject: [PATCH 080/169] start 1.7.4 --- CMake/cotire.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 69e9a67..93097a0 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -42,6 +42,9 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(POP) endif() +set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.4") + # activate select policies if (POLICY CMP0038) # targets may not link directly to themselves @@ -93,9 +96,6 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() -set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.3") - include(CMakeParseArguments) include(ProcessorCount) From 69496eb5dbae123dcfeee0f01eb27dcb2e27920f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 12 Sep 2015 20:21:37 +0200 Subject: [PATCH 081/169] use DIRECTORY instead of PATH with get_filename_component --- CMake/cotire.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 93097a0..9a161a1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -802,7 +802,7 @@ macro (cotire_add_frameworks_to_cmd _cmdVar _language) set (_frameWorkDirs "") foreach (_include ${ARGN}) if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") - get_filename_component(_frameWorkDir "${_include}" PATH) + get_filename_component(_frameWorkDir "${_include}" DIRECTORY) list (APPEND _frameWorkDirs "${_frameWorkDir}") endif() endforeach() @@ -1508,7 +1508,7 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio # -Kc++ process all source or unrecognized file types as C++ source files # -fsyntax-only check only for correct syntax # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) - get_filename_component(_pchDir "${_pchFile}" PATH) + get_filename_component(_pchDir "${_pchFile}" DIRECTORY) get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") @@ -1634,7 +1634,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # -include process include file as the first line of the primary source file # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) if (_pchFile) - get_filename_component(_pchDir "${_pchFile}" PATH) + get_filename_component(_pchDir "${_pchFile}" DIRECTORY) get_filename_component(_pchName "${_pchFile}" NAME) if (_flags) # append to list @@ -3032,7 +3032,7 @@ function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) # filter files in intermediate directory set (_filesToRemove "") foreach (_file ${_cotireFiles}) - get_filename_component(_dir "${_file}" PATH) + get_filename_component(_dir "${_file}" DIRECTORY) get_filename_component(_dirName "${_dir}" NAME) if ("${_dirName}" STREQUAL "${_cotireIntermediateDirName}") list (APPEND _filesToRemove "${_file}") From 8338e4259c6168b5e053c948b06a065ad6f58c7c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 12 Sep 2015 20:23:25 +0200 Subject: [PATCH 082/169] increase MSVC default PCH memory to 128M --- CMake/cotire.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 9a161a1..e47f4f1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3358,9 +3358,9 @@ else() endif() if (MSVC) # MSVC default PCH memory scaling factor of 100 percent (75 MB) is too small for template heavy C++ code - # use a bigger default factor of 140 percent (105 MB) + # use a bigger default factor of 170 percent (128 MB) if (NOT DEFINED COTIRE_PCH_MEMORY_SCALING_FACTOR) - set (COTIRE_PCH_MEMORY_SCALING_FACTOR "140") + set (COTIRE_PCH_MEMORY_SCALING_FACTOR "170") endif() endif() if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX) From e18049baecc0f67cba2bc04ce4102fe29334ea05 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 26 Sep 2015 20:11:37 +0200 Subject: [PATCH 083/169] remove obsolete variable --- CMake/cotire.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e47f4f1..062e478 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3156,7 +3156,6 @@ if (CMAKE_SCRIPT_MODE_FILE) message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") endif() set (_sources "") - set (_sourceLocations "") set (_sourcesDefinitions "") endif() set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) From 9f34ff37c95ef88cd12e4d4fe462136782191d3d Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 10 Oct 2015 13:21:03 +0200 Subject: [PATCH 084/169] omit COTIRE_*_INIT variables from generated target script --- CMake/cotire.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 062e478..c76494f 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2019,7 +2019,12 @@ function (cotire_generate_target_script _language _configurations _target _targe # copy variable definitions to cotire target script get_cmake_property(_vars VARIABLES) string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") - # remove COTIRE_VERBOSE which is passed as a CMake define on command line + # omit COTIRE_*_INIT variables + string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+_INIT" _initVars "${_matchVars}") + if (_initVars) + list (REMOVE_ITEM _matchVars ${_initVars}) + endif() + # omit COTIRE_VERBOSE which is passed as a CMake define on command line list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) set (_contents "") set (_contentsHasGeneratorExpressions FALSE) From 504b2f4b6fc3505c394512ebc59405d0328b69b5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 10 Oct 2015 13:27:36 +0200 Subject: [PATCH 085/169] set up single unity file for prefix header generation --- CMake/cotire.cmake | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index c76494f..698636d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2303,21 +2303,15 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) endforeach() - list (LENGTH _unityFiles _numberOfUnityFiles) - if (_numberOfUnityFiles GREATER 1) - # create a joint unity file from all unity file segments - cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_combine_command(${_language} "${_targetConfigScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) - endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() -function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFile _cmdsVar) +function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) set (_sourceFiles ${ARGN}) set (_dependencySources "") cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) cotire_set_cmd_to_prologue(_prefixCmd) - list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" "${_unityFile}") + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" ${_unityFiles}) set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") @@ -2332,7 +2326,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} - DEPENDS "${_unityFile}" ${_dependencySources} + DEPENDS ${_unityFiles} ${_dependencySources} COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) @@ -2348,17 +2342,9 @@ function (cotire_setup_prefix_generation_from_unity_command _language _target _t else() set (_prefixSourceFile "${_prefixFile}") endif() - list (LENGTH _unityFiles _numberOfUnityFiles) - if (_numberOfUnityFiles GREATER 1) - cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) - cotire_setup_prefix_generation_command( - ${_language} ${_target} "${_targetScript}" - "${_prefixSourceFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) - else() - cotire_setup_prefix_generation_command( - ${_language} ${_target} "${_targetScript}" - "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) - endif() + cotire_setup_prefix_generation_command( + ${_language} ${_target} "${_targetScript}" + "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # set up generation of a prefix source file which includes the prefix header cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) @@ -2619,14 +2605,22 @@ function (cotire_process_target_language _language _configurations _target _whol endif() cotire_generate_target_script( ${_language} "${_configurations}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) + # set up unity files for parallel compilation cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) - if (NOT _unityFiles) + list (LENGTH _unityFiles _numberOfUnityFiles) + if (_numberOfUnityFiles EQUAL 0) return() + elseif (_numberOfUnityFiles GREATER 1) + cotire_setup_unity_generation_commands( + ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() + # set up single unity file for prefix header generation + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) cotire_setup_unity_generation_commands( - ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFile}" _cmds ${_unitySourceFiles}) cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) + # set up prefix header if (_prefixFile) # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) @@ -2635,7 +2629,7 @@ function (cotire_process_target_language _language _configurations _target _whol ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_prefix_generation_from_unity_command( - ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_unityFile}" _cmds ${_unitySourceFiles}) endif() # check if selected language has enough sources at all list (LENGTH _sourceFiles _numberOfSources) From feb6bdd38f08ea6d614d4c4c839d4db7173762ce Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 10 Oct 2015 18:48:34 +0200 Subject: [PATCH 086/169] typo fix --- MANUAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANUAL.md b/MANUAL.md index 5952fae..fde6b5b 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -692,7 +692,7 @@ inherits the property value from its enclosing directory. common pitfalls --------------- -### include the `cotire.cmake` module correclty +### include the `cotire.cmake` module correctly If CMake issues the message `Unknown CMake command "cotire"`, double check that the cotire module has been included correctly in your project. See the manual section "cotire basic usage". From 7803fd36db7b7889daf77da99279987cc95b5052 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 10 Oct 2015 18:49:24 +0200 Subject: [PATCH 087/169] update history --- HISTORY.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 426c075..805edc5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.7.4 (2015-10-10) + +* set up single unity source file for prefix header generation. +* increase MSVC default PCH memory to 128M. +* remove obsolete code. + ## 1.7.3 (2015-07-25) * handle language standard target properties (e.g., `CXX_STANDARD`). From c82f2e5d845a63e566bebd547a27bf209e9ac1a2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 22 Oct 2015 20:40:06 +0200 Subject: [PATCH 088/169] start 1.7.5 --- CMake/cotire.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 698636d..bb11c4a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -44,6 +44,7 @@ endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") set (COTIRE_CMAKE_MODULE_VERSION "1.7.4") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.5") # activate select policies if (POLICY CMP0038) From bfc32c57ef0da4970751070ae30cdc85b0ef9781 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 22 Oct 2015 20:42:00 +0200 Subject: [PATCH 089/169] activate policies --- CMake/cotire.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index bb11c4a..8dcb482 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -47,6 +47,16 @@ set (COTIRE_CMAKE_MODULE_VERSION "1.7.4") set (COTIRE_CMAKE_MODULE_VERSION "1.7.5") # activate select policies +if (POLICY CMP0025) + # Compiler id for Apple Clang is now AppleClang + cmake_policy(SET CMP0025 NEW) +endif() + +if (POLICY CMP0026) + # disallow use of the LOCATION target property + cmake_policy(SET CMP0026 NEW) +endif() + if (POLICY CMP0038) # targets may not link directly to themselves cmake_policy(SET CMP0038 NEW) From 6ea9ef6f118aef666e94d8bd966b75821593af27 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 22 Oct 2015 20:42:31 +0200 Subject: [PATCH 090/169] remove 1.7.4 --- CMake/cotire.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 8dcb482..18d0526 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,6 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.4") set (COTIRE_CMAKE_MODULE_VERSION "1.7.5") # activate select policies From 35193044c297e5c042ef4637126ac5ed4283706a Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 22 Oct 2015 20:42:53 +0200 Subject: [PATCH 091/169] handle visibility target properties --- CMake/cotire.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 18d0526..0fe44ac 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -464,6 +464,17 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) endif() endif() endif() + # handle visibility target properties + if (_target) + get_target_property(_targetVisibility ${_target} ${_language}_VISIBILITY_PRESET) + if (_targetVisibility AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY}${_targetVisibility}") + endif() + get_target_property(_targetVisibilityInlines ${_target} VISIBILITY_INLINES_HIDDEN) + if (_targetVisibilityInlines AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}") + endif() + endif() # platform specific flags if (APPLE) get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) From 6aa5b5daf70e9663e318b4b612b8ea30c750c32e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 22 Oct 2015 20:44:21 +0200 Subject: [PATCH 092/169] refactor handing of system include directories --- CMake/cotire.cmake | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 0fe44ac..952fae0 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -802,17 +802,17 @@ macro (cotire_add_definitions_to_cmd _cmdVar _language) endforeach() endmacro() -macro (cotire_add_includes_to_cmd _cmdVar _language _includeSystemFlag _includesVar _systemIncludesVar) +macro (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar) foreach (_include ${${_includesVar}}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) - list (APPEND ${_cmdVar} "/I${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") else() - list (FIND ${_systemIncludesVar} ${_include} _index) - if(_index GREATER -1 AND NOT "${_includeSystemFlag}" STREQUAL "") - list (APPEND ${_cmdVar} "${_includeSystemFlag}${_include}") + list (FIND ${_systemIncludesVar} "${_include}" _index) + if (_index GREATER -1 AND CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") else() - list (APPEND ${_cmdVar} "-I${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") endif() endif() endforeach() @@ -830,7 +830,7 @@ macro (cotire_add_frameworks_to_cmd _cmdVar _language) if (_frameWorkDirs) list (REMOVE_DUPLICATES _frameWorkDirs) foreach (_frameWorkDir ${_frameWorkDirs}) - list (APPEND ${_cmdVar} "-F${_frameWorkDir}") + list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameWorkDir}") endforeach() endif() endif() @@ -1082,7 +1082,7 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") - set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE UNPARSED_LINES) + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION LANGUAGE UNPARSED_LINES) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) @@ -1100,7 +1100,7 @@ function (cotire_scan_includes _includesVar) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning @@ -1294,7 +1294,7 @@ endfunction() function (cotire_generate_prefix_header _prefixFile) set(_options "") - set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG) + set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) @@ -1336,7 +1336,6 @@ function (cotire_generate_prefix_header _prefixFile) COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} COMPILE_FLAGS ${_option_COMPILE_FLAGS} INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES} - INCLUDE_SYSTEM_FLAG ${_option_INCLUDE_SYSTEM_FLAG} SYSTEM_INCLUDE_DIRECTORIES ${_option_SYSTEM_INCLUDE_DIRECTORIES} IGNORE_PATH ${_option_IGNORE_PATH} INCLUDE_PATH ${_option_INCLUDE_PATH} @@ -1689,7 +1688,7 @@ endfunction() function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) set(_options "") - set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE) + set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION LANGUAGE) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_LANGUAGE) @@ -1704,7 +1703,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) - cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" @@ -2012,7 +2011,6 @@ function (cotire_generate_target_script _language _configurations _target _targe get_target_property(COTIRE_TARGET_INCLUDE_PRIORITY_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${_targetSources}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${_targetSources}) - string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" COTIRE_INCLUDE_SYSTEM_FLAG) set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) @@ -2053,6 +2051,8 @@ function (cotire_generate_target_script _language _configurations _target _targe XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_SYSTEM_FLAG_${_language} + CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG CMAKE_INCLUDE_FLAG_${_language}_SEP CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") @@ -3233,7 +3233,6 @@ if (CMAKE_SCRIPT_MODE_FILE) INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" INCLUDE_PRIORITY_PATH ${COTIRE_TARGET_INCLUDE_PRIORITY_PATH} - INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} @@ -3256,7 +3255,6 @@ if (CMAKE_SCRIPT_MODE_FILE) COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" - INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} From ac016a18055f82d6fbe4ebd074bfbbc7bb3ce8a5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 25 Oct 2015 21:14:01 +0100 Subject: [PATCH 093/169] parse additional system include directories from target compile flags --- CMake/cotire.cmake | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 952fae0..892d027 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -515,12 +515,31 @@ function (cotire_get_target_include_directories _config _language _target _inclu list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}") list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}") endif() - # parse additional include directories from target compile flags set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) - cotire_filter_compile_flags("${_language}" "I" _dirs _ignore ${_targetFlags}) - if (_dirs) - list (APPEND _includeDirs ${_dirs}) + # parse additional include directories from target compile flags + if (CMAKE_INCLUDE_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_dirs "") + cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags}) + if (_dirs) + list (APPEND _includeDirs ${_dirs}) + endif() + endif() + endif() + # parse additional system include directories from target compile flags + if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_dirs "") + cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags}) + if (_dirs) + list (APPEND _systemIncludeDirs ${_dirs}) + endif() + endif() endif() # target include directories get_directory_property(_dirs DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES) From 5a5e8525b552d521187feb85cdaaf544a6db0bea Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 25 Oct 2015 21:15:31 +0100 Subject: [PATCH 094/169] use CMAKE_INCLUDE_FLAG_C and CMAKE_INCLUDE_FLAG_CXX --- CMake/cotire.cmake | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 892d027..ef69d0c 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -678,8 +678,23 @@ function (cotire_get_target_compiler_flags _config _language _target _compilerFl # parse target compile flags omitting compile definitions and include directives set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) + set (_flagFilter "D") + if (CMAKE_INCLUDE_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_flagFilter "${_flagFilter}|${_includeFlag}") + endif() + endif() + if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_flagFilter "${_flagFilter}|${_includeFlag}") + endif() + endif() set (_compilerFlags "") - cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) + cotire_filter_compile_flags("${_language}" "${_flagFilter}" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compilerFlags) message (STATUS "Target ${_target} compiler flags: ${_compilerFlags}") endif() From 884e8fd2cc76b81b8ee8bb456ae511e2c7d7d6a2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 25 Oct 2015 21:17:37 +0100 Subject: [PATCH 095/169] better handling of includes and system include directories --- CMake/cotire.cmake | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ef69d0c..73ed7fc 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -836,21 +836,29 @@ macro (cotire_add_definitions_to_cmd _cmdVar _language) endforeach() endmacro() -macro (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar) - foreach (_include ${${_includesVar}}) - if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - file (TO_NATIVE_PATH "${_include}" _include) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") - else() - list (FIND ${_systemIncludesVar} "${_include}" _index) - if (_index GREATER -1 AND CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") - else() +function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar) + set (_includeDirs ${${_includesVar}} ${${_systemIncludesVar}}) + if (_includeDirs) + list (REMOVE_DUPLICATES _includeDirs) + foreach (_include ${_includeDirs}) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + file (TO_NATIVE_PATH "${_include}" _include) list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + else() + set (_index -1) + if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+") + list (FIND ${_systemIncludesVar} "${_include}" _index) + endif() + if (_index GREATER -1) + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") + else() + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + endif() endif() - endif() - endforeach() -endmacro() + endforeach() + endif() + set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE) +endfunction() macro (cotire_add_frameworks_to_cmd _cmdVar _language) if (APPLE) From 47964fc7bdb0fcabdd3c7be52ed95e9ced257d98 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 25 Oct 2015 21:19:11 +0100 Subject: [PATCH 096/169] better handling of framework and system framework include directories --- CMake/cotire.cmake | 49 +++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 73ed7fc..3236fa1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -860,23 +860,42 @@ function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemInclu set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE) endfunction() -macro (cotire_add_frameworks_to_cmd _cmdVar _language) +function (cotire_add_frameworks_to_cmd _cmdVar _language _includesVar _systemIncludesVar) if (APPLE) - set (_frameWorkDirs "") - foreach (_include ${ARGN}) + set (_frameworkDirs "") + foreach (_include ${${_includesVar}}) if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") - get_filename_component(_frameWorkDir "${_include}" DIRECTORY) - list (APPEND _frameWorkDirs "${_frameWorkDir}") + get_filename_component(_frameworkDir "${_include}" DIRECTORY) + list (APPEND _frameworkDirs "${_frameworkDir}") endif() endforeach() - if (_frameWorkDirs) - list (REMOVE_DUPLICATES _frameWorkDirs) - foreach (_frameWorkDir ${_frameWorkDirs}) - list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameWorkDir}") + set (_systemFrameworkDirs "") + foreach (_include ${${_systemIncludesVar}}) + if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") + get_filename_component(_frameworkDir "${_include}" DIRECTORY) + list (APPEND _systemFrameworkDirs "${_frameworkDir}") + endif() + endforeach() + if (_systemFrameworkDirs) + list (APPEND _frameworkDirs ${_systemFrameworkDirs}) + endif() + if (_frameworkDirs) + list (REMOVE_DUPLICATES _frameworkDirs) + foreach (_frameworkDir ${_frameworkDirs}) + set (_index -1) + if ("${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}" MATCHES ".+") + list (FIND _systemFrameworkDirs "${_frameworkDir}" _index) + endif() + if (_index GREATER -1) + list (APPEND ${_cmdVar} "${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}") + else() + list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}") + endif() endforeach() endif() endif() -endmacro() + set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE) +endfunction() macro (cotire_add_compile_flags_to_cmd _cmdVar) foreach (_flag ${ARGN}) @@ -1143,7 +1162,7 @@ function (cotire_scan_includes _includesVar) cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) - cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning set (_existingSourceFiles "") @@ -1746,7 +1765,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) - cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) @@ -2093,8 +2112,10 @@ function (cotire_generate_target_script _language _configurations _target _targe XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 - CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_SYSTEM_FLAG_${_language} - CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG CMAKE_INCLUDE_FLAG_${_language}_SEP + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_${_language}_SEP + CMAKE_INCLUDE_SYSTEM_FLAG_${_language} + CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG + CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") From d06a5110fe7f944579fd6a37e365d05ea2648337 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 27 Oct 2015 20:08:46 +0100 Subject: [PATCH 097/169] doc updates --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52a6897..0833345 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ set the `COTIRE_CXX_PREFIX_HEADER_INIT` property before invoking cotire: As a side effect, cotire generates a new target named `MyExecutable_unity`, which lets you perform a unity build for the original target. The unity target inherits all build settings from the -original target, including linked libraries and target dependencies. +original target, including linked library dependencies. For Makefile based generators you can then invoke a unity build that produces the same output as the original target, but does so much faster by entering: From 9730d1ddaf4ec9e608c5d5534470b2cf60568dc3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 27 Oct 2015 20:22:01 +0100 Subject: [PATCH 098/169] update history --- HISTORY.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 805edc5..a930ad4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## 1.7.5 (2015-10-27) + +* handle visibility target properties (`CXX_VISIBILITY_PRESET` and `VISIBILITY_INLINES_HIDDEN`). +* better handling of include directories and system include directories. +* parse additional system include directories from target compile flags. +* activate select CMake policies. + ## 1.7.4 (2015-10-10) * set up single unity source file for prefix header generation. From 48ab9a72c195952c301308a500b223ab03b524b6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 Dec 2015 13:19:56 +0100 Subject: [PATCH 099/169] start 1.7.6 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3236fa1..f1ba885 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.6") # activate select policies if (POLICY CMP0025) From cda1975e88fce9d522d63479c8d2be734e06e6db Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 Dec 2015 13:20:40 +0100 Subject: [PATCH 100/169] remove redundant initialization --- CMake/cotire.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index f1ba885..3c3a3dd 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1157,7 +1157,6 @@ function (cotire_scan_includes _includesVar) if (NOT _option_COMPILER_VERSION) set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") endif() - set (_cmd "${_option_COMPILER_EXECUTABLE}" ${_option_COMPILER_ARG1}) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) From 9d22e96b5cde83579bc3adab802bc67a923998a0 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 Dec 2015 13:23:22 +0100 Subject: [PATCH 101/169] honor CMake 3.4 target properties --- CMake/cotire.cmake | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3c3a3dd..5830a5e 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2919,6 +2919,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_ POSITION_INDEPENDENT_CODE + C_COMPILER_LAUNCHER CXX_COMPILER_LAUNCHER + C_INCLUDE_WHAT_YOU_USE CXX_INCLUDE_WHAT_YOU_USE C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) # copy compile features cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} @@ -2948,22 +2950,31 @@ function (cotire_setup_unity_build_target _languages _configurations _target) IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST - MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES - OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE) + BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR + MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH + OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST) # copy Windows platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS COMPILE_PDB_NAME COMPILE_PDB_NAME_ COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ - VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE - VS_KEYWORD VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER - VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES VS_WINRT_COMPONENT - VS_DOTNET_TARGET_FRAMEWORK_VERSION WIN32_EXECUTABLE) + VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_TARGET_FRAMEWORK_VERSION + VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE + VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK + VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION + VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER + VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION + VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES + WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS) # copy Android platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - ANDROID_API ANDROID_API_MIN ANDROID_GUI) + ANDROID_API ANDROID_API_MIN ANDROID_GUI + ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES + ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR + ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES + ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH + ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) From c55aeec38077a1ce099faa3628b5fab785ba5fb4 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 Dec 2015 14:53:54 +0100 Subject: [PATCH 102/169] do not add file-dependency on target's generated files --- CMake/cotire.cmake | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 5830a5e..a4fb533 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2041,14 +2041,6 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou # depend on target source files marked with custom COTIRE_DEPENDENCY property get_target_property(_targetSourceFiles ${_target} SOURCES) cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles}) - if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") - # GCC and clang raise a fatal error if a file is not found during preprocessing - # thus we depend on target's generated source files for prefix header generation - cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) - if (_generatedSources) - list (APPEND _dependencySources ${_generatedSources}) - endif() - endif() if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_language} ${_target} prefix header dependencies: ${_dependencySources}") endif() @@ -2406,6 +2398,22 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript else() set (_comment "Generating ${_language} prefix header ${_prefixFileRelPath}") endif() + # prevent pre-processing errors upon generating the prefix header when a target's generated include file does not yet exist + # we do not add a file-level dependency for the target's generated files though, because we only want to depend on their existence + # thus we make the prefix header generation depend on a custom helper target which triggers the generation of the files + set (_preTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}_pre") + if (TARGET ${_preTargetName}) + # custom helper target has already been generated while processing a different language + list (APPEND _dependencySources ${_preTargetName}) + else() + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) + if (_generatedSources) + add_custom_target("${_preTargetName}" DEPENDS ${_generatedSources}) + cotire_init_target("${_preTargetName}") + list (APPEND _dependencySources ${_preTargetName}) + endif() + endif() add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} From 5767073df687addc3e30f8a266e58158f5648f91 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 6 Dec 2015 15:48:13 +0100 Subject: [PATCH 103/169] doc updates --- HISTORY.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index a930ad4..4545a80 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.7.6 (2015-12-06) + +* fix CMake 3.4 compatibility issues. +* prevent redundant re-generation of prefix header when a target has generated source files. + ## 1.7.5 (2015-10-27) * handle visibility target properties (`CXX_VISIBILITY_PRESET` and `VISIBILITY_INLINES_HIDDEN`). From 9b59ef0590f8975d258b482b8b1ce40643093f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Wed, 13 Jan 2016 18:14:20 +0100 Subject: [PATCH 104/169] Don't disable PCH if CMAKE_xx_COMPILER_ID is not set Should fix #82 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a4fb533..d103357 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2578,7 +2578,7 @@ function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTarge set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() - if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$") + if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND NOT "${CMAKE_${_language}_COMPILER_ID}" STREQUAL "") cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) if (_disableMsg) set (_targetUsePCH FALSE) From 1bb64f774fc0c9595f60e44d9a5f9cda9eda8cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Fri, 22 Jan 2016 07:43:00 +0100 Subject: [PATCH 105/169] Add detection of defined _COMPILER_LAUNCHER vars Since CMake 3.3 it is possible to use _COMPILER_LAUNCHER target property to define ccache. So we need to check those setting, too. --- CMake/cotire.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index d103357..74c008d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1811,7 +1811,8 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() - if (CMAKE_${_language}_COMPILER MATCHES "ccache") + get_target_property(launcher ${_target} ${_language}_COMPILER_LAUNCHER) + if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR launcher MATCHES "ccache") if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") set (${_msgVar} "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." From c999d641a7674e417b20db2518145bcc77c3211b Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 19 Mar 2016 12:27:48 +0100 Subject: [PATCH 106/169] start 1.7.7 --- CMake/cotire.cmake | 6 +++--- license | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index d103357..91effdc 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2015 Sascha Kratky +# Copyright 2012-2016 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.6") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.7") # activate select policies if (POLICY CMP0025) @@ -331,7 +331,7 @@ function (cotire_get_target_usage_requirements _target _targetRequirementsVar) list (FIND _targetRequirements ${_library} _index) if (_index LESS 0) list (APPEND _targetRequirements ${_library}) - # process transitive libraries + # BFS traversal of transitive libraries get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) if (_libraries) list (APPEND _librariesToProcess ${_libraries}) diff --git a/license b/license index acae20c..13bda98 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012-2015 Sascha Kratky +Copyright (c) 2012-2016 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From dc1bc8ff178348f5fba3af58c50b03ad75039eab Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 19 Mar 2016 12:28:30 +0100 Subject: [PATCH 107/169] suppress pointless warning for Ninja --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe830a..77d01d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8.12) +if (POLICY CMP0058) + # Ninja requires custom command byproducts to be explicit + cmake_policy(SET CMP0058 NEW) +endif() + project (CotireExample) set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") From 7c22a36899d5c15b958700c2fda27039060a20b5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 19 Mar 2016 12:29:52 +0100 Subject: [PATCH 108/169] output terser log messages when using Visual Studio IDE --- CMake/cotire.cmake | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 91effdc..643303f 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2156,7 +2156,11 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre if (_targetScript) cotire_set_cmd_to_prologue(_cmds) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") - file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileLogPath) + else() + file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}") + endif() if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") endif() @@ -2167,7 +2171,7 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre DEPENDS "${_prefixFile}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" + COMMENT "Building ${_language} precompiled header ${_pchFileLogPath}" VERBATIM) endif() endif() @@ -2252,19 +2256,23 @@ function (cotire_setup_combine_command _language _targetScript _joinedFile _cmds message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) - file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_joinedFile}" _joinedFileLogPath) + else() + file (RELATIVE_PATH _joinedFileLogPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + endif() get_filename_component(_joinedFileBaseName "${_joinedFile}" NAME_WE) get_filename_component(_joinedFileExt "${_joinedFile}" EXT) if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") - set (_comment "Generating ${_language} unity source ${_joinedFileRelPath}") + set (_comment "Generating ${_language} unity source ${_joinedFileLogPath}") elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$") if (_joinedFileExt MATCHES "^\\.c") - set (_comment "Generating ${_language} prefix source ${_joinedFileRelPath}") + set (_comment "Generating ${_language} prefix source ${_joinedFileLogPath}") else() - set (_comment "Generating ${_language} prefix header ${_joinedFileRelPath}") + set (_comment "Generating ${_language} prefix header ${_joinedFileLogPath}") endif() else() - set (_comment "Generating ${_joinedFileRelPath}") + set (_comment "Generating ${_joinedFileLogPath}") endif() add_custom_command( OUTPUT "${_joinedFile}" @@ -2365,7 +2373,11 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript # CMake 3.1.0 supports generator expressions in arguments to DEPENDS set (_unityCmdDepends "${_targetConfigScript}") endif() - file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_unityFile}" _unityFileLogPath) + else() + file (RELATIVE_PATH _unityFileLogPath "${CMAKE_BINARY_DIR}" "${_unityFile}") + endif() if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}") endif() @@ -2373,7 +2385,7 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript OUTPUT "${_unityFile}" COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends} - COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" + COMMENT "Generating ${_language} unity source ${_unityFileLogPath}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) @@ -2391,12 +2403,16 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") endif() - file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileLogPath) + else() + file (RELATIVE_PATH _prefixFileLogPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + endif() get_filename_component(_prefixFileExt "${_prefixFile}" EXT) if (_prefixFileExt MATCHES "^\\.c") - set (_comment "Generating ${_language} prefix source ${_prefixFileRelPath}") + set (_comment "Generating ${_language} prefix source ${_prefixFileLogPath}") else() - set (_comment "Generating ${_language} prefix header ${_prefixFileRelPath}") + set (_comment "Generating ${_language} prefix header ${_prefixFileLogPath}") endif() # prevent pre-processing errors upon generating the prefix header when a target's generated include file does not yet exist # we do not add a file-level dependency for the target's generated files though, because we only want to depend on their existence From 9a9e39a22f9528adcf422f036ef9aba77d7819dd Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 19 Mar 2016 12:30:48 +0100 Subject: [PATCH 109/169] honor CMake 3.5 target property IOS_INSTALL_COMBINED --- CMake/cotire.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 643303f..a269ca7 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2976,7 +2976,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH - OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST) + OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST + IOS_INSTALL_COMBINED) # copy Windows platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS From 6b1f2c888dbf4907331fc91930d7ed5fba85644f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 19 Mar 2016 20:36:29 +0100 Subject: [PATCH 110/169] fix bugs related to handling of interface libraries --- CMake/cotire.cmake | 51 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a269ca7..34248a3 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -389,6 +389,24 @@ function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _ set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) endfunction() +function (cotire_is_target_supported _target _isSupportedVar) + if (NOT TARGET "${_target}") + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + get_target_property(_imported ${_target} IMPORTED) + if (_imported) + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + get_target_property(_targetType ${_target} TYPE) + if (NOT _targetType MATCHES "EXECUTABLE|(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + set (${_isSupportedVar} TRUE PARENT_SCOPE) +endfunction() + function (cotire_get_target_compile_flags _config _language _target _flagsVar) string (TOUPPER "${_config}" _upperConfig) # collect options from CMake language variables @@ -3029,10 +3047,16 @@ function (cotire_target _target) if (NOT _option_CONFIGURATIONS) cotire_get_configuration_types(_option_CONFIGURATIONS) endif() - # trivial checks - get_target_property(_imported ${_target} IMPORTED) - if (_imported) - message (WARNING "cotire: imported target ${_target} cannot be cotired.") + # check if cotire can be applied to target at all + cotire_is_target_supported(${_target} _isSupported) + if (NOT _isSupported) + get_target_property(_imported ${_target} IMPORTED) + get_target_property(_targetType ${_target} TYPE) + if (_imported) + message (WARNING "cotire: imported ${_targetType} target ${_target} cannot be cotired.") + else() + message (STATUS "cotire: ${_targetType} target ${_target} cannot be cotired.") + endif() return() endif() # resolve alias @@ -3097,11 +3121,16 @@ endfunction(cotire_target) function (cotire_map_libraries _strategy _mappedLibrariesVar) set (_mappedLibraries "") foreach (_library ${ARGN}) - if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") - # use target's corresponding unity target, if available - get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) - if (TARGET "${_libraryUnityTargetName}") - list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + if ("${_strategy}" MATCHES "COPY_UNITY") + cotire_is_target_supported(${_library} _isSupported) + if (_isSupported) + # use target's corresponding unity target, if available + get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_libraryUnityTargetName}") + list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + else() + list (APPEND _mappedLibraries "${_library}") + endif() else() list (APPEND _mappedLibraries "${_library}") endif() @@ -3114,6 +3143,10 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) endfunction() function (cotire_target_link_libraries _target) + cotire_is_target_supported(${_target} _isSupported) + if (NOT _isSupported) + return() + endif() get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_unityTargetName}") get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) From ed521832d28b829227ebaa0005739433a1c5e94f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 20 Mar 2016 10:17:45 +0100 Subject: [PATCH 111/169] add support for compiler launchers --- CMake/cotire.cmake | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index dbb09d0..df8d37f 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -833,7 +833,10 @@ macro (cotire_set_cmd_to_prologue _cmdVar) endif() endmacro() -function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) +function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerExe _compilerArg1) + if (NOT _compilerLauncher) + set (_compilerLauncher ${CMAKE_${_language}_COMPILER_LAUNCHER}) + endif() if (NOT _compilerExe) set (_compilerExe "${CMAKE_${_language}_COMPILER}") endif() @@ -841,7 +844,7 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() string (STRIP "${_compilerArg1}" _compilerArg1) - set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) endfunction() macro (cotire_add_definitions_to_cmd _cmdVar _language) @@ -1161,9 +1164,9 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") - set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION LANGUAGE UNPARSED_LINES) + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES - IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) + IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_LANGUAGE) @@ -1175,7 +1178,7 @@ function (cotire_scan_includes _includesVar) if (NOT _option_COMPILER_VERSION) set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") endif() - cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) @@ -1372,10 +1375,10 @@ endfunction() function (cotire_generate_prefix_header _prefixFile) set(_options "") - set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION) + set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH - IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH) + IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") @@ -1408,7 +1411,9 @@ function (cotire_generate_prefix_header _prefixFile) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) cotire_scan_includes(_selectedHeaders ${_sourceFiles} LANGUAGE "${_option_LANGUAGE}" + COMPILER_LAUNCHER "${_option_COMPILER_LAUNCHER}" COMPILER_EXECUTABLE "${_option_COMPILER_EXECUTABLE}" + COMPILER_ARG1 "${_option_COMPILER_ARG1}" COMPILER_ID "${_option_COMPILER_ID}" COMPILER_VERSION "${_option_COMPILER_VERSION}" COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} @@ -1766,8 +1771,8 @@ endfunction() function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) set(_options "") - set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION LANGUAGE) - set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS) + set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION LANGUAGE) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS COMPILER_LAUNCHER) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") @@ -1778,7 +1783,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (NOT _option_COMPILER_VERSION) set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") endif() - cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) @@ -1829,8 +1834,8 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() - get_target_property(launcher ${_target} ${_language}_COMPILER_LAUNCHER) - if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR launcher MATCHES "ccache") + get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) + if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") set (${_msgVar} "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." @@ -2094,6 +2099,7 @@ function (cotire_generate_target_script _language _configurations _target _targe cotire_get_source_files_compile_definitions( "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${_targetSources}) endforeach() + get_target_property(COTIRE_TARGET_${_language}_COMPILER_LAUNCHER ${_target} ${_language}_COMPILER_LAUNCHER) # set up COTIRE_TARGET_SOURCES set (COTIRE_TARGET_SOURCES "") foreach (_sourceFile ${_targetSources}) @@ -2121,7 +2127,7 @@ function (cotire_generate_target_script _language _configurations _target _targe foreach (_var IN LISTS _matchVars ITEMS XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION - CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 + CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_${_language}_SEP CMAKE_INCLUDE_SYSTEM_FLAG_${_language} CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG @@ -3356,6 +3362,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_generate_prefix_header( "${COTIRE_ARGV3}" ${_files} + COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}" COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" @@ -3382,6 +3389,7 @@ if (CMAKE_SCRIPT_MODE_FILE) cotire_precompile_prefix_header( "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}" + COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}" COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" From 275b5ddcdcd377ce1b42e3a07eb0d1c2c60983a1 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 20 Mar 2016 10:29:27 +0100 Subject: [PATCH 112/169] only use compiler launchers for Makefile and Ninja --- CMake/cotire.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index df8d37f..419fe86 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -844,7 +844,12 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerE set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() string (STRIP "${_compilerArg1}" _compilerArg1) - set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + # compiler launcher is only supported for Makefile and Ninja + set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + else() + set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + endif() endfunction() macro (cotire_add_definitions_to_cmd _cmdVar _language) From 75ff9dd2b22854af9ca04610a1b0f4be40eee292 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 20 Mar 2016 10:43:48 +0100 Subject: [PATCH 113/169] docu updates --- HISTORY.md | 8 ++++++++ MANUAL.md | 26 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 4545a80..c0e0b88 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,11 @@ +## 1.7.7 (2016-03-20) + +* CMake 3.5 compatibility. +* fix bugs related to handling of interface libraries. +* output shorter log messages when using Visual Studio IDE. +* don't disable PCH if CMAKE__COMPILER_ID is not set (thanks jcelerier). +* add support for compiler launchers introduced in CMake 3.4 (thanks misery). + ## 1.7.6 (2015-12-06) * fix CMake 3.4 compatibility issues. diff --git a/MANUAL.md b/MANUAL.md index fde6b5b..0db916e 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -340,7 +340,7 @@ file. The path is interpreted relative to the target source directory: cotire(example) If the prefix header `stdafx.h` needs an accompanying source file (e.g., `stdafx.cpp`) in order -to be pre-compiled properly, that source file needs to be the first one on the list of source +to be precompiled properly, that source file needs to be the first one on the list of source files in the target's `add_executable` or `add_library` call. The property `COTIRE_CXX_PREFIX_HEADER_INIT` can also be set to a list of header files which will @@ -548,6 +548,11 @@ enabled in the following way upon configuring the project: $ export CCACHE_SLOPPINESS=pch_defines,time_macros $ cmake .. +Alternatively, for CMake 3.4 or later compiler wrappers can be enabled by pointing the CMake +variable `CMAKE_CXX_COMPILER_LAUNCHER` to the compiler wrapper executable upon configuring: + + $ cmake -D CMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache + Note that with ccache in order for precompiled headers to work properly, it is necessary to set the environment variable `CCACHE_SLOPPINESS` to `pch_defines,time_macros`. Otherwise the build process may abort with the following error message: @@ -654,7 +659,7 @@ The global `install_unity` target must depend on all unity targets that should b ### customized inclusion of system headers -If a system header ends up in a pre-compiled header, it is not possible to customize the inclusion +If a system header ends up in a precompiled header, it is not possible to customize the inclusion of that header in a source file through preprocessor defines. For example, under Windows one may want to include `Windows.h` with `NOMINMAX` defined to prevent @@ -713,8 +718,9 @@ Don't do this: ### always apply cotire in the same source directory where a target has been added -CMake targets are globally visible. Nevertheless, it is important that the `cotire` function is called -for a target in the exact same directory that creates the target with `add_library` or `add_executable`. +CMake targets are globally visible. Nevertheless, it is important that the `cotire` function is +called for a target in the exact same directory that creates the target with `add_library` or +`add_executable`. Don't do this: @@ -728,14 +734,21 @@ different directory and you may get odd messages about missing source files. known issues ------------ +### Ninja compatibility + +Under Ninja indirect prefix header dependencies are ignored by the generated build system. Cotire +uses the `IMPLICIT_DEPENDS` option of `add_custom_command` to make the precompiled header depend +on header files indirectly included by the prefix header. The `IMPLICIT_DEPENDS` option is not +supported by CMake's Ninja generator. See [CMake issue][ninja_issue]. + ### using source files for multiple targets When the same set of source files is used for different targets (e.g., for producing a static and a shared library variant from the same sources), using a precompiled header may not work. Under certain circumstances, cotire cannot enable the precompiled header usage by changing the `COMPILE_FLAGS` property of the whole target, but must set the `COMPILE_FLAGS` properties of -individual target source files instead. This will break the usage of the source file for -multiple targets. +individual target source files instead. This will break the usage of the source file for multiple +targets. ### multi-architecture builds under Mac OS X @@ -772,6 +785,7 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx [msvc_pch_create]:http://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx [msvc_pch_use]:http://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx +[ninja_issue]:https://cmake.org/Bug/view.php?id=13234 [EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [pch]:http://en.wikipedia.org/wiki/Precompiled_header [scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit From 38ed31341eae29bec144c54f9a2a86cec572ac3d Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 25 Mar 2016 19:23:49 +0100 Subject: [PATCH 114/169] start 1.7.8 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 419fe86..8885e48 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.7") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.8") # activate select policies if (POLICY CMP0025) From 46d04a4e3ca483773bccdbba04b74c88933c56d2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 25 Mar 2016 19:25:51 +0100 Subject: [PATCH 115/169] fix COPY_UNITY for LINK_ONLY libraries --- CMake/cotire.cmake | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 8885e48..b6d7f5d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3133,13 +3133,24 @@ endfunction(cotire_target) function (cotire_map_libraries _strategy _mappedLibrariesVar) set (_mappedLibraries "") foreach (_library ${ARGN}) + if (_library MATCHES "^\\$$") + set (_libraryName "${CMAKE_MATCH_1}") + set (_linkOnly TRUE) + else() + set (_libraryName "${_library}") + set (_linkOnly FALSE) + endif() if ("${_strategy}" MATCHES "COPY_UNITY") - cotire_is_target_supported(${_library} _isSupported) + cotire_is_target_supported(${_libraryName} _isSupported) if (_isSupported) # use target's corresponding unity target, if available - get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) + get_target_property(_libraryUnityTargetName ${_libraryName} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_libraryUnityTargetName}") - list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + if (_linkOnly) + list (APPEND _mappedLibraries "$") + else() + list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + endif() else() list (APPEND _mappedLibraries "${_library}") endif() From 48a1ca25918444de1896a6765cadb91953bf019b Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 25 Mar 2016 19:27:05 +0100 Subject: [PATCH 116/169] handle CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE --- CMake/cotire.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index b6d7f5d..0630451 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -576,6 +576,21 @@ function (cotire_get_target_include_directories _config _language _target _inclu set (_linkedTargets "") cotire_get_target_usage_requirements(${_target} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_linkedTargetType ${_linkedTarget} TYPE) + if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND + _linkedTargetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + # CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE refers to CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR + # at the time, when the target was created. These correspond to the target properties BINARY_DIR and SOURCE_DIR + # which are only available with CMake 3.4 or later. + get_target_property(_targetDirs ${_linkedTarget} BINARY_DIR) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_linkedTarget} SOURCE_DIR) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + endif() get_target_property(_targetDirs ${_linkedTarget} INTERFACE_INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _dirs ${_targetDirs}) From ca8b620ff69fa03c6e5de6bfcfef9e02d2fbf299 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 25 Mar 2016 19:30:40 +0100 Subject: [PATCH 117/169] set up LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES correctly for unity target --- CMake/cotire.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 0630451..741d690 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3192,21 +3192,21 @@ function (cotire_target_link_libraries _target) message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}") endif() if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") - set (_unityLinkLibraries "") get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) if (_linkLibraries) - list (APPEND _unityLinkLibraries ${_linkLibraries}) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries}) + set_target_properties(${_unityTargetName} PROPERTIES LINK_LIBRARIES "${_unityLinkLibraries}") + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} link libraries: ${_unityLinkLibraries}") + endif() endif() get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) if (_interfaceLinkLibraries) - list (APPEND _unityLinkLibraries ${_interfaceLinkLibraries}) - endif() - cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_unityLinkLibraries}) - if (COTIRE_DEBUG) - message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") - endif() - if (_unityLinkLibraries) - target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkInterfaceLibraries ${_interfaceLinkLibraries}) + set_target_properties(${_unityTargetName} PROPERTIES INTERFACE_LINK_LIBRARIES "${_unityLinkInterfaceLibraries}") + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} interface link libraries: ${_unityLinkInterfaceLibraries}") + endif() endif() endif() endif() From 40a46bf2fbea18bef0306ce8aba3c3fd8ff7afb8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 27 Mar 2016 18:27:17 +0200 Subject: [PATCH 118/169] update history --- HISTORY.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index c0e0b88..7fe23a0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 1.7.8 (2016-03-27) + +* fix `COPY_UNITY` linking strategy for private link dependencies. +* honor `CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE` upon handling of target usage requirements. +* reworked setting up of `LINK_LIBRARIES` and `INTERFACE_LINK_LIBRARIES` properties for unity targets. + ## 1.7.7 (2016-03-20) * CMake 3.5 compatibility. From ef64a48f19b4b97cee34a61f217d1bbc197f263e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 1 Jun 2016 22:28:38 +0200 Subject: [PATCH 119/169] start 1.7.9 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 741d690..2c15eea 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.8") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.9") # activate select policies if (POLICY CMP0025) From 66c5491538a9733b347b94b621f9998b0095fda3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 1 Jun 2016 22:29:29 +0200 Subject: [PATCH 120/169] make precompiled header compilation depend on the actual compiler executable --- CMake/cotire.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 2c15eea..c27d52a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2206,14 +2206,18 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre else() file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}") endif() + # make precompiled header compilation depend on the actual compiler executable to force + # re-compilation when the compiler executable is updated. This prevents "created by a different GCC executable" + # warnings when the precompiled header is included. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} ${_realCompilerExe} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") endif() set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) add_custom_command( OUTPUT "${_pchFile}" COMMAND ${_cmds} - DEPENDS "${_prefixFile}" + DEPENDS "${_prefixFile}" "${_realCompilerExe}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Building ${_language} precompiled header ${_pchFileLogPath}" From 8325b52a0b9be5ab315acf3ff5e5378574b52b18 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 19 Sep 2016 21:08:55 +0200 Subject: [PATCH 121/169] fix bug with handling CXX_STANDARD_REQUIRED --- CMake/cotire.cmake | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index c27d52a..b0061d5 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -450,20 +450,16 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) endforeach() endif() # handle language standard properties - if (_target) - get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) - get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) - get_target_property(_targetLanguageStandardRequired ${_target} ${_language}_STANDARD_REQUIRED) - if (_targetLanguageExtensions) - if (CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION}") - endif() - elseif (_targetLanguageStandard) - if (_targetLanguageStandardRequired) - if (CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION}") + if (CMAKE_${_language}_STANDARD_DEFAULT) + # used compiler supports language standard levels + if (_target) + get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) + get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) + if (_targetLanguageExtensions) + if (CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION}") endif() - else() + elseif (_targetLanguageStandard) if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") endif() From fc3125949dac43c7476027fe1c55a20740dbce6c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 19 Sep 2016 21:10:31 +0200 Subject: [PATCH 122/169] return result from scanning include files --- CMake/cotire.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index b0061d5..1f9b374 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1180,7 +1180,7 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") - set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES) + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES SCAN_RESULT) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) @@ -1253,6 +1253,9 @@ function (cotire_scan_includes _includesVar) if (_option_UNPARSED_LINES) set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) endif() + if (_option_SCAN_RESULT) + set (${_option_SCAN_RESULT} ${_result} PARENT_SCOPE) + endif() endfunction() macro (cotire_append_undefs _contentsVar) @@ -1440,12 +1443,13 @@ function (cotire_generate_prefix_header _prefixFile) INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} INCLUDE_PRIORITY_PATH ${_option_INCLUDE_PRIORITY_PATH} - UNPARSED_LINES _unparsedLines) + UNPARSED_LINES _unparsedLines + SCAN_RESULT _scanResult) cotire_generate_unity_source("${_prefixFile}" PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) set (_unparsedLinesFile "${_prefixFile}.log") if (_unparsedLines) - if (COTIRE_VERBOSE OR NOT _selectedHeaders) + if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") endif() From edafabedd771430e5ccd9854a352eed64322b15c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 19 Sep 2016 21:11:35 +0200 Subject: [PATCH 123/169] more defensive check for COMPILER_ID variable --- CMake/cotire.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 1f9b374..5cbcbaf 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2643,10 +2643,12 @@ function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTarge set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() - if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND NOT "${CMAKE_${_language}_COMPILER_ID}" STREQUAL "") - cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) - if (_disableMsg) - set (_targetUsePCH FALSE) + if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND DEFINED CMAKE_${_language}_COMPILER_ID) + if (CMAKE_${_language}_COMPILER_ID) + cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) + if (_disableMsg) + set (_targetUsePCH FALSE) + endif() endif() endif() set (_sourceFiles "") From 21146d0420d1e8692ff8fbc94c46496978a40f64 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 19 Sep 2016 21:12:40 +0200 Subject: [PATCH 124/169] ccache: more robust check if config sloppiness is set to "pch_defines,time_macros" --- CMake/cotire.cmake | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 5cbcbaf..a37ba22 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1856,10 +1856,31 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) endif() get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") - set (${_msgVar} - "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." - PARENT_SCOPE) + if (DEFINED ENV{CCACHE_SLOPPINESS}) + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() + else() + if (_launcher MATCHES "ccache") + get_filename_component(_ccacheExe "${_launcher}" REALPATH) + else() + get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + endif() + execute_process( + COMMAND "${_ccacheExe}" "--print-config" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if (_result OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + set (${_msgVar} + "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() endif() endif() if (APPLE) From da4aaf5f545af433834ede721ad50adbe679f95e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 7 Dec 2016 19:29:15 +0100 Subject: [PATCH 125/169] add *build* to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ae81b2e..d124354 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # ignore CMake build directories -build*/ +*build*/ .DS_Store .project .idea From 5ac72e7ef0aa97cdf33447c2afbf5dfce4ee8ce6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 7 Dec 2016 22:03:15 +0100 Subject: [PATCH 126/169] replace object libraries with unity object libraries --- CMake/cotire.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a37ba22..2745fdb 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2884,6 +2884,16 @@ function (cotire_setup_pch_target _languages _configurations _target) endif() endfunction() +function (cotire_filter_object_libraries _target _objectLibrariesVar) + set (_objectLibraries "") + foreach (_source ${ARGN}) + if (_source MATCHES "^\\$$") + list (APPEND _objectLibraries "${_source}") + endif() + endforeach() + set (${_objectLibrariesVar} ${_objectLibraries} PARENT_SCOPE) +endfunction() + function (cotire_collect_unity_target_sources _target _languages _unityTargetSourcesVar) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_unityTargetSources ${_targetSourceFiles}) @@ -2902,6 +2912,15 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) + if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$") + cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles}) + if (_objectLibraries) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityObjectLibraries ${_objectLibraries}) + list (REMOVE_ITEM _unityTargetSources ${_objectLibraries}) + list (APPEND _unityTargetSources ${_unityObjectLibraries}) + endif() + endif() set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) endfunction() @@ -3178,9 +3197,15 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) if (_library MATCHES "^\\$$") set (_libraryName "${CMAKE_MATCH_1}") set (_linkOnly TRUE) + set (_objectLibrary FALSE) + elseif (_library MATCHES "^\\$$") + set (_libraryName "${CMAKE_MATCH_1}") + set (_linkOnly FALSE) + set (_objectLibrary TRUE) else() set (_libraryName "${_library}") set (_linkOnly FALSE) + set (_objectLibrary FALSE) endif() if ("${_strategy}" MATCHES "COPY_UNITY") cotire_is_target_supported(${_libraryName} _isSupported) @@ -3190,6 +3215,8 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) if (TARGET "${_libraryUnityTargetName}") if (_linkOnly) list (APPEND _mappedLibraries "$") + elseif (_objectLibrary) + list (APPEND _mappedLibraries "$") else() list (APPEND _mappedLibraries "${_libraryUnityTargetName}") endif() From fc0fb5488e294e7f59dcf1e73964c2f7e728b7f5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 11:14:48 +0100 Subject: [PATCH 127/169] =?UTF-8?q?fix=20bug=20with=20handling=20target?= =?UTF-8?q?=E2=80=99s=20language=20standard=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMake/cotire.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 2745fdb..b428235 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -454,14 +454,16 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) # used compiler supports language standard levels if (_target) get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) - get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) - if (_targetLanguageExtensions) - if (CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION}") - endif() - elseif (_targetLanguageStandard) - if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") + if (_targetLanguageStandard) + get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) + if (_targetLanguageExtensions) + if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") + endif() + else() + if (CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION}") + endif() endif() endif() endif() From e6b65b0da762772e61ba0d31c0c76e0e929e29c4 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 12:14:23 +0100 Subject: [PATCH 128/169] convert Windows paths in include directories to CMake paths --- CMake/cotire.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index b428235..7c1c8c1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -626,6 +626,25 @@ function (cotire_get_target_include_directories _config _language _target _inclu if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() + if (WIN32) + # convert Windows paths in include directories to CMake paths + if (_includeDirs) + set (_paths "") + foreach (_dir ${_includeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_includeDirs ${_paths}) + endif() + if (_systemIncludeDirs) + set (_paths "") + foreach (_dir ${_systemIncludeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_systemIncludeDirs ${_paths}) + endif() + endif() if (COTIRE_DEBUG AND _includeDirs) message (STATUS "Target ${_target} include dirs: ${_includeDirs}") endif() From de10fe34ab59b76951ad4faa463eedd9467e5bcb Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 12:17:26 +0100 Subject: [PATCH 129/169] fix automoc target dependency for Visual Studio generators --- CMake/cotire.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 7c1c8c1..9ac8cee 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3000,9 +3000,16 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # depend on the original target's implicity generated _automoc target - add_dependencies(${_unityTargetName} ${_target}_automoc) + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # depend on original target's automoc target, if it exists + if (TARGET ${_target}_automoc) + add_dependencies(${_unityTargetName} ${_target}_automoc) + endif() + else() + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + # depend on the original target's implicity generated _automoc target + add_dependencies(${_unityTargetName} ${_target}_automoc) + endif() endif() # copy output location properties set (_outputDirProperties From 854a3647993ee04f8b3c9d11e03cea2f34a2361c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 13:33:01 +0100 Subject: [PATCH 130/169] don't set warning level for MSVC --- src/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index deb2b79..92df233 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,7 @@ add_executable(example main.cpp example.cpp log.cpp log.h example.h) # enable warnings -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set_target_properties(example PROPERTIES COMPILE_FLAGS "/Wall") -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set_target_properties(example PROPERTIES COMPILE_FLAGS "-Weverything") elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -Wextra") From b78ec9ebb36699cd472d52ac2bbe217945e7ac21 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 13:46:26 +0100 Subject: [PATCH 131/169] make prefix header generation depend on the actual compiler executable --- CMake/cotire.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 9ac8cee..d64ea16 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2248,7 +2248,7 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre else() file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}") endif() - # make precompiled header compilation depend on the actual compiler executable to force + # make precompiled header compilation depend on the actual compiler executable used to force # re-compilation when the compiler executable is updated. This prevents "created by a different GCC executable" # warnings when the precompiled header is included. get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) @@ -2491,8 +2491,12 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript cotire_set_cmd_to_prologue(_prefixCmd) list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" ${_unityFiles}) set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) + # make prefix header generation depend on the actual compiler executable used to force + # re-generation when the compiler executable is updated. This prevents "file not found" + # errors for compiler version specific system header files. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") + message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources} ${_realCompilerExe}") endif() if (MSVC_IDE) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileLogPath) @@ -2524,7 +2528,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} - DEPENDS ${_unityFiles} ${_dependencySources} + DEPENDS ${_unityFiles} ${_dependencySources} "${_realCompilerExe}" COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) From 3e613baeb3e58d91dafee9cc0c07e91d725c3483 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 14:27:18 +0100 Subject: [PATCH 132/169] =?UTF-8?q?simplify=20handling=20target=E2=80=99s?= =?UTF-8?q?=20language=20standard=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMake/cotire.cmake | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index d64ea16..5de7d74 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -455,16 +455,17 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) if (_target) get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) if (_targetLanguageStandard) - get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) - if (_targetLanguageExtensions) - if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") - endif() - else() - if (CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION}") + set (_type "EXTENSION") + get_property(_isSet TARGET ${_target} PROPERTY ${_language}_EXTENSIONS SET) + if (_isSet) + get_target_property(_targetUseLanguageExtensions ${_target} ${_language}_EXTENSIONS) + if (NOT _targetUseLanguageExtensions) + set (_type "STANDARD") endif() endif() + if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}") + endif() endif() endif() endif() From 5e61a443832f88290431185f262a46a1a841d953 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 14:39:57 +0100 Subject: [PATCH 133/169] set language standard variables in example project --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77d01d7..ca5270d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,11 @@ project (CotireExample) set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") +if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") + set (CMAKE_CXX_STANDARD "98") + set (CMAKE_CXX_EXTENSIONS OFF) +endif() + include(cotire) add_subdirectory(src) From e644a547af5dcf498e452da29376f9be6a218dc5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 15:40:38 +0100 Subject: [PATCH 134/169] honor 3.6 and 3.7 target properties upon generating unity target --- CMake/cotire.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 5de7d74..ab61100 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3069,7 +3069,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) POSITION_INDEPENDENT_CODE C_COMPILER_LAUNCHER CXX_COMPILER_LAUNCHER C_INCLUDE_WHAT_YOU_USE CXX_INCLUDE_WHAT_YOU_USE - C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) + C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN + C_CLANG_TIDY CXX_CLANG_TIDY) # copy compile features cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED @@ -3092,7 +3093,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ - NO_SONAME SOVERSION VERSION) + NO_SONAME SOVERSION VERSION + LINK_WHAT_YOU_USE) # copy cmake stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) @@ -3115,7 +3117,9 @@ function (cotire_setup_unity_build_target _languages _configurations _target) VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES - WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS) + WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS + DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE + VS_SDK_REFERENCES) # copy Android platform specific stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ANDROID_API ANDROID_API_MIN ANDROID_GUI From 2bb9cb6e8317ec42a7efbd0067eca9cbf728e03a Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 8 Dec 2016 16:11:55 +0100 Subject: [PATCH 135/169] docu updates --- HISTORY.md | 11 +++++++++++ MANUAL.md | 34 +++++++++++++++++----------------- README.md | 28 ++++++++++++++-------------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 7fe23a0..acb0865 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,14 @@ +## 1.7.9 (2016-12-08) + +* CMake 3.6 and 3.7 compatibility. +* fix ccache 3.2 compatibility issues. +* fix bugs with handling language standard related properties (e.g., `CXX_STANDARD`, `CXX_EXTENSIONS`). +* make prefix header generation and precompiled header compilation depend on the compiler executable. +* fix Qt automoc handling for Windows (thanks jcelerier). +* convert Windows paths in include directories to CMake paths (thanks wdx04). +* replace object library with corresponding unity object library when using `COPY_UNITY` linking strategy. +* better error reporting from prefix header generation. + ## 1.7.8 (2016-03-27) * fix `COPY_UNITY` linking strategy for private link dependencies. diff --git a/MANUAL.md b/MANUAL.md index 0db916e..af1f1fe 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -9,8 +9,8 @@ motivation ---------- Cotire was born out of a dissatisfaction with the existing CMake solutions for adding -[precompiled header][1260] support and [unity build][kde4macros] support to CMake based build -systems. The design of cotire tries to adhere to the following principles: +[precompiled header][1260] support and unity build support to CMake based build systems. +The design of cotire tries to adhere to the following principles: #### as automatic as possible @@ -601,7 +601,8 @@ original target. If this property is set to `COPY_UNITY`, the unity target's link libraries will be copied from the original target but instead of copying a linked target verbatim, the target's corresponding unity -target will be preferred, provided one exists. +target will be preferred, provided one exists. This also applies to object libraries, which have +been added to the original target with a `TARGET_OBJECTS` generator expression. As of cotire 1.7.0, the default linking strategy for unit targets is `COPY_UNITY`. @@ -775,21 +776,20 @@ is not compatible with those of precompiled header file) upon compilation of cot Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [1260]:http://www.cmake.org/Bug/view.php?id=1260 -[ccch]:http://ccache.samba.org/ -[ccch_pch]:http://ccache.samba.org/manual.html#_precompiled_headers +[ccch]:https://ccache.samba.org/ +[ccch_pch]:https://ccache.samba.org/manual.html#_precompiled_headers [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiled-headers [fsedit_qt4]:http://www.vikingsoft.eu/fseditor.html [fsedit_qt5]:https://github.com/joonhwan/fsedit-qt5 -[gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html -[kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake -[msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx -[msvc_pch_create]:http://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx -[msvc_pch_use]:http://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx +[gcc_pch]:https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html +[msvc_pch]:https://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx +[msvc_pch_create]:https://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx +[msvc_pch_use]:https://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx [ninja_issue]:https://cmake.org/Bug/view.php?id=13234 -[EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ -[pch]:http://en.wikipedia.org/wiki/Precompiled_header -[scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit -[objlib]:http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library -[pfh]:http://en.wikipedia.org/wiki/Prefix_header -[icc_linux]:http://software.intel.com/en-us/non-commercial-software-development -[XGE]:http://www.incredibuild.com +[EoUB]:https://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ +[pch]:https://en.wikipedia.org/wiki/Precompiled_header +[scu]:https://en.wikipedia.org/wiki/Single_Compilation_Unit +[objlib]:https://cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library +[pfh]:https://en.wikipedia.org/wiki/Prefix_header +[icc_linux]:https://software.intel.com/en-us/c-compilers/ipsxe-support +[XGE]:https://www.incredibuild.com/ diff --git a/README.md b/README.md index 0833345..0a048b2 100644 --- a/README.md +++ b/README.md @@ -115,23 +115,23 @@ known issues Multiple targets can share a generated prefix header, though (see the [cotire manual][manual]). * Cotire is not compatible with [Xoreax IncrediBuild][XGE]. -[ccch]:http://ccache.samba.org/ -[ccrc]:http://www.cmake.org/Wiki/CMake_Cross_Compiling +[ccch]:https://ccache.samba.org/ +[ccrc]:https://cmake.org/Wiki/CMake_Cross_Compiling [cgwn]:http://www.cygwin.com/ [clang]:http://clang.llvm.org/ -[cmk]:http://www.cmake.org/download/ -[gcc]:http://gcc.gnu.org/ +[cmk]:https://cmake.org/download/ +[gcc]:https://gcc.gnu.org/ [manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md [mingw]:http://www.mingw.org/ -[ninja]:http://martine.github.io/ninja/ -[pch]:http://en.wikipedia.org/wiki/Precompiled_header -[pfh]:http://en.wikipedia.org/wiki/Prefix_header -[scu]:http://en.wikipedia.org/wiki/Single_Compilation_Unit -[vslstd]:http://msdn.microsoft.com/vstudio/ -[xcdt]:http://developer.apple.com/xcode/ -[PCHH]:http://gcc.gnu.org/wiki/PCHHaters -[EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ +[ninja]:https://ninja-build.org/ +[pch]:https://en.wikipedia.org/wiki/Precompiled_header +[pfh]:https://en.wikipedia.org/wiki/Prefix_header +[scu]:https://en.wikipedia.org/wiki/Single_Compilation_Unit +[vslstd]:https://www.visualstudio.com/ +[xcdt]:https://developer.apple.com/xcode/ +[PCHH]:https://gcc.gnu.org/wiki/PCHHaters +[EoUB]:https://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [jom]:http://wiki.qt.io/Jom -[intel]:http://software.intel.com/en-us/c-compilers -[XGE]:http://www.incredibuild.com +[intel]:https://software.intel.com/en-us/c-compilers +[XGE]:https://www.incredibuild.com/ [shrp]:http://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html From 1c0ad8cc477f222330f055c0eea10ccf3773153f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 20 Dec 2016 20:01:52 +0100 Subject: [PATCH 136/169] start 1.7.10 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ab61100..09f41bb 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.9") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.10") # activate select policies if (POLICY CMP0025) From 7cb00727bf079a9af07d14a514792ba34677599c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 20 Dec 2016 20:02:43 +0100 Subject: [PATCH 137/169] fix typo in function name --- CMake/cotire.cmake | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 09f41bb..be7de65 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -293,7 +293,7 @@ function (cotire_get_source_file_property_values _valuesVar _property) set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() -function (cotire_resolve_config_properites _configurations _propertiesVar) +function (cotire_resolve_config_properties _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "") @@ -309,8 +309,8 @@ function (cotire_resolve_config_properites _configurations _propertiesVar) set (${_propertiesVar} ${_properties} PARENT_SCOPE) endfunction() -function (cotire_copy_set_properites _configurations _type _source _target) - cotire_resolve_config_properites("${_configurations}" _properties ${ARGN}) +function (cotire_copy_set_properties _configurations _type _source _target) + cotire_resolve_config_properties("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) @@ -3027,8 +3027,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) - cotire_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) @@ -3048,11 +3048,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) endif() # copy output name - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ OUTPUT_NAME OUTPUT_NAME_ @@ -3060,7 +3060,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) PREFIX _POSTFIX SUFFIX IMPORT_PREFIX IMPORT_SUFFIX) # copy compile stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ COMPILE_FLAGS COMPILE_OPTIONS Fortran_FORMAT Fortran_MODULE_DIRECTORY @@ -3072,12 +3072,12 @@ function (cotire_setup_unity_build_target _languages _configurations _target) C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN C_CLANG_TIDY CXX_CLANG_TIDY) # copy compile features - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED COMPILE_FEATURES) # copy interface stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS @@ -3085,7 +3085,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) # copy link stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ @@ -3096,16 +3096,16 @@ function (cotire_setup_unity_build_target _languages _configurations _target) NO_SONAME SOVERSION VERSION LINK_WHAT_YOU_USE) # copy cmake stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST IOS_INSTALL_COMBINED) # copy Windows platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS COMPILE_PDB_NAME COMPILE_PDB_NAME_ COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ @@ -3121,7 +3121,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE VS_SDK_REFERENCES) # copy Android platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ANDROID_API ANDROID_API_MIN ANDROID_GUI ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR From 580eb18cca17f1f7bdaa845acf7374bb654a42bc Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 20 Dec 2016 20:05:02 +0100 Subject: [PATCH 138/169] fix MinGW incompatibility with BUILD_INTERFACE generator expression --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index be7de65..e74c966 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -627,7 +627,7 @@ function (cotire_get_target_include_directories _config _language _target _inclu if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() - if (WIN32) + if (WIN32 AND NOT MINGW) # convert Windows paths in include directories to CMake paths if (_includeDirs) set (_paths "") From e392f4f4260c7c154810289ec05e8937b6b0351e Mon Sep 17 00:00:00 2001 From: kbinani Date: Tue, 7 Feb 2017 11:59:16 +0900 Subject: [PATCH 139/169] disable pch messages when Wno-pch-messages flag exists --- CMake/cotire.cmake | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ab61100..b968b44 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1657,6 +1657,10 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list if ("${_language}" STREQUAL "CXX") @@ -1664,13 +1668,17 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio endif() list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() endif() @@ -1781,17 +1789,25 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV if (_pchFile) get_filename_component(_pchDir "${_pchFile}" DIRECTORY) get_filename_component(_pchName "${_pchFile}" NAME) + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() else() From f1b2ccfb4eb5caf4d7533c578a28af780fa55e0f Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 20 Mar 2017 22:52:44 +0100 Subject: [PATCH 140/169] fix handling of CMAKE_INCLUDE_FLAG_SEP_* variables --- CMake/cotire.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e74c966..cbbdcfb 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -902,16 +902,16 @@ function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemInclu foreach (_include ${_includeDirs}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() set (_index -1) if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+") list (FIND ${_systemIncludesVar} "${_include}" _index) endif() if (_index GREATER -1) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") endif() endif() endforeach() @@ -2191,7 +2191,7 @@ function (cotire_generate_target_script _language _configurations _target _targe XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 - CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_${_language}_SEP + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_SEP_${_language} CMAKE_INCLUDE_SYSTEM_FLAG_${_language} CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG From 96ce7e9f0eef5d6130870f5476f2843aa7c76136 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Wed, 19 Apr 2017 12:50:09 +0200 Subject: [PATCH 141/169] CMake 3.8.0 Qt automoc support Fixes #112, #114. --- CMake/cotire.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index ab61100..6cf0cb6 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2989,8 +2989,13 @@ function (cotire_setup_unity_build_target _languages _configurations _target) if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) # if the original target sources are subject to CMake's automatic Qt processing, # also include implicitly generated _automoc.cpp file - list (APPEND _unityTargetSources "${_target}_automoc.cpp") - set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + if (CMAKE_VERSION VERSION_LESS "3.8.0") + list (APPEND _unityTargetSources "${_target}_automoc.cpp") + set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + else() + list (APPEND _unityTargetSources "${_target}_autogen/moc_compilation.cpp") + set_property (SOURCE "${_target}_autogen/moc_compilation.cpp" PROPERTY GENERATED TRUE) + endif() endif() # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created set (CMAKE_AUTOMOC OFF) @@ -3013,7 +3018,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) # depend on the original target's implicity generated _automoc target - add_dependencies(${_unityTargetName} ${_target}_automoc) + if (CMAKE_VERSION VERSION_LESS "3.8.0") + add_dependencies(${_unityTargetName} ${_target}_automoc) + else() + add_dependencies(${_unityTargetName} ${_target}_autogen) + endif() endif() endif() # copy output location properties From bde8d0cf7040b6fe239d0df14abe75779553d139 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 28 Apr 2017 21:11:35 +0200 Subject: [PATCH 142/169] work around ccache clang problem --- CMake/cotire.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index cbbdcfb..fc1baf8 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1839,6 +1839,15 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (_option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) + elseif (_option_COMPILER_ID MATCHES "Clang") + if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR + _option_COMPILER_EXECUTABLE MATCHES "ccache") + # Clang seems to embed a compilation timestamp into the precompiled header binary, + # which results in "file has been modified since the precompiled header was built" + # errors if ccache is used. We work around the problem by disabling ccache upon + # pre-compiling the prefix header. + set (ENV{CCACHE_DISABLE} "true") + endif() endif() execute_process( COMMAND ${_cmd} From e7505fc62a5d25bd11ac73ce891c06d2b6e10eef Mon Sep 17 00:00:00 2001 From: Guillaume Campagna Date: Mon, 8 May 2017 17:49:50 -0400 Subject: [PATCH 143/169] Fix Xcode recompiling every time builds happen if a target mixes multiple languages --- CMake/cotire.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 6cf0cb6..a7257f6 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -859,6 +859,9 @@ macro (cotire_set_cmd_to_prologue _cmdVar) list (APPEND ${_cmdVar} "--warn-uninitialized") endif() list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") + if (XCODE) + list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE") + endif() if (COTIRE_VERBOSE) list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") From 1cc391fbbd89d84fbd2585434a3e0b784631c1d8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 09:53:31 +0200 Subject: [PATCH 144/169] handle simple generator expression in target usage requirements --- CMake/cotire.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index fc1baf8..ef29085 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -320,13 +320,18 @@ function (cotire_copy_set_properties _configurations _type _source _target) endforeach() endfunction() -function (cotire_get_target_usage_requirements _target _targetRequirementsVar) +function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar) set (_targetRequirements "") get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) while (_librariesToProcess) # remove from head list (GET _librariesToProcess 0 _library) list (REMOVE_AT _librariesToProcess 0) + if (_library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + endif() if (TARGET ${_library}) list (FIND _targetRequirements ${_library} _index) if (_index LESS 0) @@ -441,7 +446,7 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) # interface compile options from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) @@ -573,7 +578,7 @@ function (cotire_get_target_include_directories _config _language _target _inclu # interface include directories from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_linkedTargetType ${_linkedTarget} TYPE) if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND @@ -703,7 +708,7 @@ function (cotire_get_target_compile_definitions _config _language _target _defin endif() # interface compile definitions from linked library targets set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS) if (_definitions) From cc83f49854cd9ce2986aeeca3f844f8392ce8bbe Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 12:02:22 +0200 Subject: [PATCH 145/169] ccache gcc work-around --- CMake/cotire.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 66f82b9..5080e06 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1863,13 +1863,12 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (_option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) - elseif (_option_COMPILER_ID MATCHES "Clang") + elseif (_option_COMPILER_ID MATCHES "GNU|Clang") if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR _option_COMPILER_EXECUTABLE MATCHES "ccache") - # Clang seems to embed a compilation timestamp into the precompiled header binary, - # which results in "file has been modified since the precompiled header was built" - # errors if ccache is used. We work around the problem by disabling ccache upon - # pre-compiling the prefix header. + # Newer versions of Clang and GCC seem to embed a compilation timestamp into the precompiled header binary, + # which results in "file has been modified since the precompiled header was built" errors if ccache is used. + # We work around the problem by disabling ccache upon pre-compiling the prefix header. set (ENV{CCACHE_DISABLE} "true") endif() endif() From 438747bd3daed38cdaf20861d0c921c6ec024991 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 12:03:23 +0200 Subject: [PATCH 146/169] honor new CMake 3.8 target properties --- CMake/cotire.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 5080e06..7a163eb 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3135,7 +3135,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ NO_SONAME SOVERSION VERSION - LINK_WHAT_YOU_USE) + LINK_WHAT_YOU_USE BUILD_RPATH) # copy cmake stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) @@ -3144,7 +3144,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST - IOS_INSTALL_COMBINED) + IOS_INSTALL_COMBINED XCODE_EXPLICIT_FILE_TYPE XCODE_PRODUCT_TYPE) # copy Windows platform specific stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS @@ -3160,7 +3160,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE - VS_SDK_REFERENCES) + VS_SDK_REFERENCES VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY) # copy Android platform specific stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ANDROID_API ANDROID_API_MIN ANDROID_GUI From 6c4cb3a8bc218f2659c758b2849ac695cd1c9f59 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 12:03:57 +0200 Subject: [PATCH 147/169] 2016 -> 2017 --- CMake/cotire.cmake | 2 +- license | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 7a163eb..a7273c4 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2016 Sascha Kratky +# Copyright 2012-2017 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation diff --git a/license b/license index 13bda98..33a6ea7 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012-2016 Sascha Kratky +Copyright (c) 2012-2017 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 351cbb77d712f32d275a1906c7b83bd577af2db0 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 15:26:58 +0200 Subject: [PATCH 148/169] enable policy CMP0055 --- CMake/cotire.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index a7273c4..62cd23d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -106,6 +106,11 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() +if (POLICY CMP0055) + # strict checking for break() command + cmake_policy(SET CMP0055 NEW) +endif() + include(CMakeParseArguments) include(ProcessorCount) From 516d78476f6dda336181fc5514f72774e1e0a8e2 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Fri, 16 Jun 2017 15:33:07 +0200 Subject: [PATCH 149/169] update history --- HISTORY.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index acb0865..c92e0b1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,13 @@ +## 1.7.10 (2017-06-16) + +* CMake 3.8 compatibility. +* CMake 3.8.0 Qt automoc support (thanks bilke). +* fix Xcode recompiling every time builds happen (thanks gcamp). +* disable PCH messages when `-Wno-pch-messages` flag exists (thanks kbinani). +* work around ccache incompatibility with newer versions of GCC and Clang. +* fix MinGW incompatibility with `BUILD_INTERFACE` generator expression. +* fix handling of `CMAKE_INCLUDE_FLAG_SEP_` variables. + ## 1.7.9 (2016-12-08) * CMake 3.6 and 3.7 compatibility. From 33ad5a164d5dea192240234cbbc8533be29988ba Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 15 Aug 2017 15:36:26 +0200 Subject: [PATCH 150/169] start 1.7.11 --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 62cd23d..00f1af5 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.10") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.11") # activate select policies if (POLICY CMP0025) From 04779d45807c53650ed478e01a3a4bdb58594b37 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Tue, 15 Aug 2017 15:37:48 +0200 Subject: [PATCH 151/169] convert paths to native paths under Windows --- CMake/cotire.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 00f1af5..12e508c 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -889,6 +889,9 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerE if (NOT _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe) + endif() string (STRIP "${_compilerArg1}" _compilerArg1) if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # compiler launcher is only supported for Makefile and Ninja @@ -1246,7 +1249,15 @@ function (cotire_scan_includes _includesVar) set (${_includesVar} "" PARENT_SCOPE) return() endif() - list (APPEND _cmd ${_existingSourceFiles}) + # add source files to be scanned + if (WIN32 AND "${_option_COMPILER_ID}" MATCHES "MSVC|Intel") + foreach (_sourceFile ${_existingSourceFiles}) + file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative) + list (APPEND _cmd "${_sourceFileNative}") + endforeach() + else() + list (APPEND _cmd ${_existingSourceFiles}) + endif() if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() From 7cf9c15e97cf4609a23b7d17506171b8bc9ed729 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 13:43:57 +0100 Subject: [PATCH 152/169] correct outdated comments --- CMake/cotire.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 12e508c..d0947f2 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2017 Sascha Kratky +# Copyright 2012-2018 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -721,7 +721,7 @@ function (cotire_get_target_compile_definitions _config _language _target _defin endif() endforeach() # parse additional compile definitions from target compile flags - # and don't look at directory compile definitions, which we already handled + # and do not look at directory compile definitions, which we already handled set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) @@ -1086,12 +1086,11 @@ endmacro() macro (cotire_parse_line _line _headerFileVar _headerDepthVar) if (MSVC) - # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: + # cl.exe /showIncludes produces different output, depending on the language pack used, e.g.: # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : characters if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$") - # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) else() @@ -1882,7 +1881,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) elseif (_option_COMPILER_ID MATCHES "GNU|Clang") if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR _option_COMPILER_EXECUTABLE MATCHES "ccache") - # Newer versions of Clang and GCC seem to embed a compilation timestamp into the precompiled header binary, + # Newer versions of Clang embed a compilation timestamp into the precompiled header binary, # which results in "file has been modified since the precompiled header was built" errors if ccache is used. # We work around the problem by disabling ccache upon pre-compiling the prefix header. set (ENV{CCACHE_DISABLE} "true") @@ -1901,7 +1900,7 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (_unsupportedCompiler "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") - # supported since Visual Studio C++ 6.0 + # PCH supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") @@ -2502,7 +2501,8 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths}) endif() if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel + # unity file compilation results in potentially huge object file, + # thus use /bigobj by default unter cl.exe and Windows Intel set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) From a5118909ad4bc0e5fe63e86ed02a4fb08abb5ec6 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 13:46:53 +0100 Subject: [PATCH 153/169] use native paths for output under Windows --- CMake/cotire.cmake | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index d0947f2..569af42 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -889,7 +889,7 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerE if (NOT _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() - if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + if (WIN32) file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe) endif() string (STRIP "${_compilerArg1}" _compilerArg1) @@ -1249,7 +1249,7 @@ function (cotire_scan_includes _includesVar) return() endif() # add source files to be scanned - if (WIN32 AND "${_option_COMPILER_ID}" MATCHES "MSVC|Intel") + if (WIN32) foreach (_sourceFile ${_existingSourceFiles}) file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative) list (APPEND _cmd "${_sourceFileNative}") @@ -1260,7 +1260,7 @@ function (cotire_scan_includes _includesVar) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (_option_COMPILER_ID MATCHES "MSVC") + if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -1496,7 +1496,12 @@ function (cotire_generate_prefix_header _prefixFile) if (_unparsedLines) if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) - message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") + if (WIN32) + file (TO_NATIVE_PATH "${_unparsedLinesFile}" _unparsedLinesLogPath) + else() + file (RELATIVE_PATH _unparsedLinesLogPath "${CMAKE_BINARY_DIR}" "${_unparsedLinesFile}") + endif() + message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesLogPath}") endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() @@ -1875,7 +1880,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (_option_COMPILER_ID MATCHES "MSVC") + if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) elseif (_option_COMPILER_ID MATCHES "GNU|Clang") From 1daa9d03f14e4dd873ba64c10bd89b4cb5204d8c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 13:52:25 +0100 Subject: [PATCH 154/169] ccache configuration check hardening --- CMake/cotire.cmake | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 569af42..2e3c76e 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1928,19 +1928,25 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() + # check if ccache is used as a compiler launcher get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) - if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" REALPATH) + if (_realCompilerExe MATCHES "ccache" OR _launcher MATCHES "ccache") + # verify that ccache configuration is compatible with precompiled headers + # always check environment variable CCACHE_SLOPPINESS, because earlier versions of ccache + # do not report the "sloppiness" setting correctly upon printing ccache configuration if (DEFINED ENV{CCACHE_SLOPPINESS}) - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR + NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") set (${_msgVar} "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." PARENT_SCOPE) endif() else() - if (_launcher MATCHES "ccache") - get_filename_component(_ccacheExe "${_launcher}" REALPATH) + if (_realCompilerExe MATCHES "ccache") + set (_ccacheExe "${_realCompilerExe}") else() - get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + set (_ccacheExe "${_launcher}") endif() execute_process( COMMAND "${_ccacheExe}" "--print-config" @@ -1948,9 +1954,10 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) RESULT_VARIABLE _result OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - if (_result OR NOT - _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT - _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + if (_result) + set (${_msgVar} "ccache configuration cannot be determined." PARENT_SCOPE) + elseif (NOT _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR + NOT _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") set (${_msgVar} "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." PARENT_SCOPE) From 12f74823ed0b6d66d6fdf38bf6fea71e8ac538a4 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 14:18:22 +0100 Subject: [PATCH 155/169] clang-cl.exe support --- CMake/cotire.cmake | 168 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 132 insertions(+), 36 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 2e3c76e..90c59f1 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.11") +set (COTIRE_CMAKE_MODULE_VERSION "1.8.0") # activate select policies if (POLICY CMP0025) @@ -1545,16 +1545,36 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags endif() endif() elseif (_compilerID MATCHES "Clang") - # Clang options used - # -H print the name of each header file used - # -E invoke preprocessor - # -fno-color-diagnostics don't prints diagnostics in color - if (_flags) - # append to list - list (APPEND _flags -H -E -fno-color-diagnostics) - else() - # return as a flag string - set (_flags "-H -E -fno-color-diagnostics") + if (UNIX) + # Clang options used + # -H print the name of each header file used + # -E invoke preprocessor + # -fno-color-diagnostics do not print diagnostics in color + # -Eonly just run preprocessor, no output + if (_flags) + # append to list + list (APPEND _flags -H -E -fno-color-diagnostics -Xclang -Eonly) + else() + # return as a flag string + set (_flags "-H -E -fno-color-diagnostics -Xclang -Eonly") + endif() + elseif (WIN32) + # Clang-cl.exe options used + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /EP preprocess to stdout without #line directives + # -H print the name of each header file used + # -fno-color-diagnostics do not print diagnostics in color + # -Eonly just run preprocessor, no output + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags "${_sourceFileType${_language}}" /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly") + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1628,8 +1648,8 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") endif() endif() - elseif (_compilerID MATCHES "GNU|Clang") - # GCC / Clang options used + elseif (_compilerID MATCHES "GNU") + # GCC options used # -x specify the source language # -c compile but do not link # -o place output in file @@ -1639,11 +1659,52 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (_xLanguage_CXX "c++-header") if (_flags) # append to list - list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() + elseif (_compilerID MATCHES "Clang") + if (UNIX) + # Clang options used + # -x specify the source language + # -c compile but do not link + # -o place output in file + # -fno-pch-timestamp disable inclusion of timestamp in precompiled headers (clang 4.0.0+) + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + if (_flags) + # append to list + list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}") + if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") + list (APPEND _flags -Xclang -fno-pch-timestamp) + endif() + else() + # return as a flag string + set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") + set (_flags "${_flags} -Xclang -fno-pch-timestamp") + endif() + endif() + elseif (WIN32) + # Clang-cl.exe options used + # /Yc creates a precompiled header file + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + # /Zs syntax check only + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags "${_sourceFileType${_language}}" + "/Yc${_prefixFile}" "/Fp${_pchFile}" "/FI${_prefixFile}" /Zs "${_hostFile}") + else() + # return as a flag string + set (_flags "/Yc\"${_prefixFile}\" /Fp\"${_pchFile}\" /FI\"${_prefixFile}\"") + endif() + endif() elseif (_compilerID MATCHES "Intel") if (WIN32) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) @@ -1763,17 +1824,40 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Clang") - # Clang options used - # -include process include file as the first line of the primary source file - # -include-pch include precompiled header file - # -Qunused-arguments don't emit warning for unused driver arguments - # note: ccache requires the -include flag to be used in order to process precompiled header correctly - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") - else() - # return as a flag string - set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + if (UNIX) + # Clang options used + # -include process include file as the first line of the primary source file + # note: ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND -include "${_prefixFile}") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\"") + endif() + elseif (WIN32) + # Clang-cl.exe options used + # /Yu uses a precompiled header file during build + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + if (_pchFile) + if (_flags) + # append to list + list (APPEND _flags "/Yu${_prefixFile}" "/Fp${_pchFile}" "/FI${_prefixFile}") + else() + # return as a flag string + set (_flags "/Yu\"${_prefixFile}\" /Fp\"${_pchFile}\" /FI\"${_prefixFile}\"") + endif() + else() + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFile}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFile}\"") + endif() + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1883,7 +1967,7 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) - elseif (_option_COMPILER_ID MATCHES "GNU|Clang") + elseif (_option_COMPILER_ID MATCHES "Clang" AND _option_COMPILER_VERSION VERSION_LESS "4.0.0") if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR _option_COMPILER_EXECUTABLE MATCHES "ccache") # Newer versions of Clang embed a compilation timestamp into the precompiled header binary, @@ -1916,8 +2000,16 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (${_msgVar} "" PARENT_SCOPE) endif() elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") - # all Clang versions have PCH support - set (${_msgVar} "" PARENT_SCOPE) + if (UNIX) + # all Unix Clang versions have PCH support + set (${_msgVar} "" PARENT_SCOPE) + elseif (WIN32) + # only clang-cl is supported under Windows + get_filename_component(_compilerName "${CMAKE_${_language}_COMPILER}" NAME_WE) + if (NOT _compilerName MATCHES "cl$") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}. Use clang-cl instead." PARENT_SCOPE) + endif() + endif() elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel PCH support requires version >= 8.0.0 if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") @@ -2283,8 +2375,9 @@ endfunction() function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) set (_sourceFiles ${ARGN}) - if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we attach the precompiled header compilation to the host file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # for MSVC, Intel and Clang-cl, we attach the precompiled header compilation to the host file # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) set (_flags "") @@ -2329,8 +2422,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre endfunction() function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile _hostFile) - if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we include the precompiled header in all but the host file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # for MSVC, Intel and clang-cl, we include the precompiled header in all but the host file # the host file does the precompiled header compilation, see cotire_setup_pch_file_compilation set (_sourceFiles ${ARGN}) list (LENGTH _sourceFiles _numberOfSourceFiles) @@ -2476,9 +2570,10 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) # if this is a single-language target without any excluded files if (_wholeTarget) set (_language "${_languages}") - # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level + # for MSVC, Intel and clang-cl, precompiled header inclusion is always done on the source file level # see cotire_setup_pch_file_inclusion - if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) if (_prefixFile) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) @@ -2949,8 +3044,9 @@ function (cotire_setup_pch_target _languages _configurations _target) set (_dependsFiles "") foreach (_language ${_languages}) set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) - if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # Visual Studio and Intel only create precompiled header as a side effect + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # MSVC, Intel and clang-cl only create precompiled header as a side effect list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) endif() cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) From bbe7af60f2264cba3ed09691b4b7119f144c30e7 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 15:28:50 +0100 Subject: [PATCH 156/169] honor new target properties --- CMake/cotire.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 90c59f1..e787a64 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3251,7 +3251,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) # copy link stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} - BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH + BUILD_WITH_INSTALL_RPATH BUILD_WITH_INSTALL_NAME_DIR + INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_ @@ -3293,6 +3294,10 @@ function (cotire_setup_unity_build_target _languages _configurations _target) ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE) + # copy CUDA platform specific stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + CUDA_PTX_COMPILATION CUDA_SEPARABLE_COMPILATION CUDA_RESOLVE_DEVICE_SYMBOLS + CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) From cec55d8c785fe9ece6eae30c4f4071f4318804bf Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 16:25:54 +0100 Subject: [PATCH 157/169] disable unity builds if automatic Qt processing is used --- CMake/cotire.cmake | 47 +++++++++--------------- MANUAL.md | 14 ++------ Patches/fsedit-qt5.patch | 74 -------------------------------------- Patches/fseditor-1.0.patch | 68 ----------------------------------- README.md | 9 +++-- 5 files changed, 23 insertions(+), 189 deletions(-) delete mode 100644 Patches/fsedit-qt5.patch delete mode 100644 Patches/fseditor-1.0.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index e787a64..edc948f 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -2815,6 +2815,9 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa else() set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") endif() + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() else() if (_excludedStr) set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.") @@ -2904,6 +2907,20 @@ function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTarge set (_targetUsePCH FALSE) endif() endif() + if (_targetAddSCU) + # disable unity builds if automatic Qt processing is used + get_target_property(_targetAutoMoc ${_target} AUTOMOC) + get_target_property(_targetAutoUic ${_target} AUTOUIC) + get_target_property(_targetAutoRcc ${_target} AUTORCC) + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + if (_disableMsg) + set (_disableMsg "${_disableMsg} Target uses automatic CMake Qt processing.") + else() + set (_disableMsg "Target uses automatic CMake Qt processing.") + endif() + set (_targetAddSCU FALSE) + endif() + endif() set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU}) cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles}) @@ -3138,21 +3155,6 @@ function (cotire_setup_unity_build_target _languages _configurations _target) # determine unity target sources set (_unityTargetSources "") cotire_collect_unity_target_sources(${_target} "${_languages}" _unityTargetSources) - # handle automatic Qt processing - get_target_property(_targetAutoMoc ${_target} AUTOMOC) - get_target_property(_targetAutoUic ${_target} AUTOUIC) - get_target_property(_targetAutoRcc ${_target} AUTORCC) - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # if the original target sources are subject to CMake's automatic Qt processing, - # also include implicitly generated _automoc.cpp file - if (CMAKE_VERSION VERSION_LESS "3.8.0") - list (APPEND _unityTargetSources "${_target}_automoc.cpp") - set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) - else() - list (APPEND _unityTargetSources "${_target}_autogen/moc_compilation.cpp") - set_property (SOURCE "${_target}_autogen/moc_compilation.cpp" PROPERTY GENERATED TRUE) - endif() - endif() # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created set (CMAKE_AUTOMOC OFF) set (CMAKE_AUTOUIC OFF) @@ -3166,21 +3168,6 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() - if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - # depend on original target's automoc target, if it exists - if (TARGET ${_target}_automoc) - add_dependencies(${_unityTargetName} ${_target}_automoc) - endif() - else() - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # depend on the original target's implicity generated _automoc target - if (CMAKE_VERSION VERSION_LESS "3.8.0") - add_dependencies(${_unityTargetName} ${_target}_automoc) - else() - add_dependencies(${_unityTargetName} ${_target}_autogen) - endif() - endif() - endif() # copy output location properties set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ diff --git a/MANUAL.md b/MANUAL.md index af1f1fe..6b172c9 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -616,16 +616,8 @@ the property value from its enclosing directory. To make all targets in the proj ### using cotire with Qt -Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build system. - -If a CMake target's `AUTOMOC` or `AUTOUIC` properties are set, the generated unity target will -automatically add a dependency to the implicitly generated `_automoc` target to ensure -that `moc` and `uic` are run on the individual source files. - -The unity target will also include the implicitly generated `_automoc.cpp` source file. - -The `Patches` directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based -variants of the *FSEditor* sample Qt application. +Cotire is compatible with both Qt projects that use CMake as build system, provided Qt targets +do not use CMake automatic moc, uid or rcc scanning. ### installing files generated by unity targets @@ -779,8 +771,6 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [ccch]:https://ccache.samba.org/ [ccch_pch]:https://ccache.samba.org/manual.html#_precompiled_headers [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiled-headers -[fsedit_qt4]:http://www.vikingsoft.eu/fseditor.html -[fsedit_qt5]:https://github.com/joonhwan/fsedit-qt5 [gcc_pch]:https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [msvc_pch]:https://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx [msvc_pch_create]:https://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx diff --git a/Patches/fsedit-qt5.patch b/Patches/fsedit-qt5.patch deleted file mode 100644 index c76aeab..0000000 --- a/Patches/fsedit-qt5.patch +++ /dev/null @@ -1,74 +0,0 @@ -diff -rupN fsedit-qt5-master/CMakeLists.txt fsedit-qt5-cotire/CMakeLists.txt ---- fsedit-qt5-master/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/CMakeLists.txt 2014-08-28 17:59:58.000000000 +0200 -@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8 FATAL - cmake_policy(SET CMP0020 NEW) - project(FSEditor) - -+include(cotire) -+set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") -+ - include(InstallRequiredSystemLibraries) - - set(VERSION_MAJOR 1) -diff -rupN fsedit-qt5-master/source/application/CMakeLists.txt fsedit-qt5-cotire/source/application/CMakeLists.txt ---- fsedit-qt5-master/source/application/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/source/application/CMakeLists.txt 2014-08-28 16:48:42.000000000 +0200 -@@ -20,3 +20,7 @@ install(TARGETS fseditor DESTINATION bin - - include(tr_sources) - add_tr_sources(${sources}) -+ -+if (COMMAND cotire) -+ cotire(fseditor) -+endif() -diff -rupN fsedit-qt5-master/source/libfstest/CMakeLists.txt fsedit-qt5-cotire/source/libfstest/CMakeLists.txt ---- fsedit-qt5-master/source/libfstest/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/source/libfstest/CMakeLists.txt 2014-08-28 16:49:11.000000000 +0200 -@@ -3,8 +3,12 @@ - - add_library(fstest STATIC fstest.h fstest.cpp) - target_link_libraries(fstest -- Qt5::Widgets # ${QT_LIBRARIES} -+ Qt5::Widgets Qt5::Test # ${QT_LIBRARIES} - ) - set_target_properties(fstest - PROPERTIES PROJECT_LABEL "libfstest" - ) -+ -+if (COMMAND cotire) -+ cotire(fstest) -+endif() -diff -rupN fsedit-qt5-master/source/libmodel/CMakeLists.txt fsedit-qt5-cotire/source/libmodel/CMakeLists.txt ---- fsedit-qt5-master/source/libmodel/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/source/libmodel/CMakeLists.txt 2014-08-28 16:49:18.000000000 +0200 -@@ -37,3 +37,7 @@ fstest(test_libmodel LibModel) - - include(tr_sources) - add_tr_sources(${sources} ${headers} ${moc_headers}) -+ -+if (COMMAND cotire) -+ cotire(model) -+endif() -diff -rupN fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt ---- fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt 2014-08-28 16:49:25.000000000 +0200 -@@ -21,3 +21,7 @@ target_link_libraries(modelcommands - - include(tr_sources) - add_tr_sources(${sources} ${headers}) -+ -+if (COMMAND cotire) -+ cotire(modelcommands) -+endif() -diff -rupN fsedit-qt5-master/source/libui/CMakeLists.txt fsedit-qt5-cotire/source/libui/CMakeLists.txt ---- fsedit-qt5-master/source/libui/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 -+++ fsedit-qt5-cotire/source/libui/CMakeLists.txt 2014-08-28 12:03:28.000000000 +0200 -@@ -48,3 +48,7 @@ target_link_libraries(ui - - include(tr_sources) - add_tr_sources(${sources} ${headers} ${moc_headers} ${forms}) -+ -+if (COMMAND cotire) -+ cotire(ui) -+endif() diff --git a/Patches/fseditor-1.0.patch b/Patches/fseditor-1.0.patch deleted file mode 100644 index 32598b0..0000000 --- a/Patches/fseditor-1.0.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff -rupN fseditor-1.0/CMakeLists.txt fseditor-1.0.cotire/CMakeLists.txt ---- fseditor-1.0/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/CMakeLists.txt 2014-08-28 18:28:39.000000000 +0200 -@@ -1,6 +1,9 @@ - CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) - PROJECT(FSEditor) - -+include(cotire) -+set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") -+ - INCLUDE(InstallRequiredSystemLibraries) - - SET(VERSION_MAJOR 1) -diff -rupN fseditor-1.0/source/application/CMakeLists.txt fseditor-1.0.cotire/source/application/CMakeLists.txt ---- fseditor-1.0/source/application/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/source/application/CMakeLists.txt 2014-08-28 18:24:56.000000000 +0200 -@@ -17,3 +17,7 @@ INSTALL(TARGETS fseditor DESTINATION bin - - INCLUDE(tr_sources) - ADD_TR_SOURCES(${sources}) -+ -+if (COMMAND cotire) -+ cotire(fseditor) -+endif() -diff -rupN fseditor-1.0/source/libfstest/CMakeLists.txt fseditor-1.0.cotire/source/libfstest/CMakeLists.txt ---- fseditor-1.0/source/libfstest/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/source/libfstest/CMakeLists.txt 2014-08-28 18:25:41.000000000 +0200 -@@ -3,3 +3,7 @@ INCLUDE(${QT_USE_FILE}) - - ADD_LIBRARY(fstest STATIC fstest.h fstest.cpp) - SET_TARGET_PROPERTIES(fstest PROPERTIES PROJECT_LABEL "libfstest") -+ -+if (COMMAND cotire) -+ cotire(fstest) -+endif() -diff -rupN fseditor-1.0/source/libmodel/CMakeLists.txt fseditor-1.0.cotire/source/libmodel/CMakeLists.txt ---- fseditor-1.0/source/libmodel/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/source/libmodel/CMakeLists.txt 2013-10-06 20:05:06.000000000 +0200 -@@ -34,3 +34,7 @@ FSTEST(test_libmodel LibModel) - - INCLUDE(tr_sources) - ADD_TR_SOURCES(${sources} ${headers} ${moc_headers}) -+ -+if (COMMAND cotire) -+ cotire(model) -+endif() -diff -rupN fseditor-1.0/source/libmodelcommands/CMakeLists.txt fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt ---- fseditor-1.0/source/libmodelcommands/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt 2013-10-06 20:05:11.000000000 +0200 -@@ -18,3 +18,7 @@ TARGET_LINK_LIBRARIES(modelcommands mode - - INCLUDE(tr_sources) - ADD_TR_SOURCES(${sources} ${headers}) -+ -+if (COMMAND cotire) -+ cotire(modelcommands) -+endif() -diff -rupN fseditor-1.0/source/libui/CMakeLists.txt fseditor-1.0.cotire/source/libui/CMakeLists.txt ---- fseditor-1.0/source/libui/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 -+++ fseditor-1.0.cotire/source/libui/CMakeLists.txt 2013-10-06 20:05:18.000000000 +0200 -@@ -44,3 +44,7 @@ TARGET_LINK_LIBRARIES(ui model modelcomm - - INCLUDE(tr_sources) - ADD_TR_SOURCES(${sources} ${headers} ${moc_headers} ${forms}) -+ -+if (COMMAND cotire) -+ cotire(ui) -+endif() diff --git a/README.md b/README.md index 0a048b2..b97dbf1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ features * Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode). * Compatible with CMake's [cross-compiling][ccrc] support. * Compatible with compiler wrappers like [ccache][ccch]. -* Applicable to CMake based Qt projects. * Tested with Windows, Linux and OS X. * MIT licensed. @@ -117,8 +116,8 @@ known issues [ccch]:https://ccache.samba.org/ [ccrc]:https://cmake.org/Wiki/CMake_Cross_Compiling -[cgwn]:http://www.cygwin.com/ -[clang]:http://clang.llvm.org/ +[cgwn]:https://www.cygwin.com/ +[clang]:https://clang.llvm.org/ [cmk]:https://cmake.org/download/ [gcc]:https://gcc.gnu.org/ [manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md @@ -131,7 +130,7 @@ known issues [xcdt]:https://developer.apple.com/xcode/ [PCHH]:https://gcc.gnu.org/wiki/PCHHaters [EoUB]:https://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ -[jom]:http://wiki.qt.io/Jom +[jom]:https://wiki.qt.io/Jom [intel]:https://software.intel.com/en-us/c-compilers [XGE]:https://www.incredibuild.com/ -[shrp]:http://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html +[shrp]:https://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html From 3fc4d93dc68ff8c98899ee39f7cadd23ffcfc260 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 16:28:15 +0100 Subject: [PATCH 158/169] set default minimum number of target sources to 2 --- CMake/cotire.cmake | 2 +- MANUAL.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index edc948f..48a6bfa 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3752,7 +3752,7 @@ else() set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING "Ignore sources with the listed file extensions from the generated unity source.") - set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING + set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "2" CACHE STRING "Minimum number of sources in target required to enable use of precompiled header.") if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT) diff --git a/MANUAL.md b/MANUAL.md index 6b172c9..272b205 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -324,7 +324,7 @@ directories. A target inherits the property value from its enclosing directory. ### disabling precompiled headers for small targets The cache variable `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES` can be set to the minimum number of -source files required to enable the use of a precompiled header. It defaults to 3. To override the +source files required to enable the use of a precompiled header. It defaults to 2. To override the default, run `cmake` with the following options: $ cmake -D COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES=5 From 461c388bc3e083c71bdfe54e8ccbd7c7a5a4a617 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 16:40:36 +0100 Subject: [PATCH 159/169] add section on generator expressions to manual --- MANUAL.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MANUAL.md b/MANUAL.md index 272b205..09f7ba4 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -727,6 +727,12 @@ different directory and you may get odd messages about missing source files. known issues ------------ +### generator expressions + +cotire uses the CMake command `file(GENERATE ...` to expand generator expressions used in various +compilation settings. This command does not handle certain CMake generator expressions like +`$` correctly. + ### Ninja compatibility Under Ninja indirect prefix header dependencies are ignored by the generated build system. Cotire From c9fe9fa65d871ba3be3605c31e0dd0aa6556b503 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 17:51:15 +0100 Subject: [PATCH 160/169] honor MANUALLY_ADDED_DEPENDENCIES for unity targets --- CMake/cotire.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 48a6bfa..9cd56ab 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3456,6 +3456,11 @@ function (cotire_target_link_libraries _target) message (STATUS "unity target ${_unityTargetName} interface link libraries: ${_unityLinkInterfaceLibraries}") endif() endif() + get_target_property(_manualDependencies ${_target} MANUALLY_ADDED_DEPENDENCIES) + if (_manualDependencies) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityManualDependencies ${_manualDependencies}) + add_dependencies("${_unityTargetName}" _unityManualDependencies) + endif() endif() endif() endfunction(cotire_target_link_libraries) From 410b9eca7b4c709837a04b4cafee06c9a17acdd3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 18:12:08 +0100 Subject: [PATCH 161/169] fix COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES property definition --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 9cd56ab..8490334 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3856,7 +3856,7 @@ else() FULL_DOCS "The variable can be set to an integer > 0." "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target." - "If not defined, defaults to 3." + "If not defined, defaults to 2." ) define_property( From 073e1725f0b086c1c4be2c0440292c50d0cde71c Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 18:24:05 +0100 Subject: [PATCH 162/169] print absolute path of unparsed line log --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 8490334..bc2de56 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1499,7 +1499,7 @@ function (cotire_generate_prefix_header _prefixFile) if (WIN32) file (TO_NATIVE_PATH "${_unparsedLinesFile}" _unparsedLinesLogPath) else() - file (RELATIVE_PATH _unparsedLinesLogPath "${CMAKE_BINARY_DIR}" "${_unparsedLinesFile}") + set (_unparsedLinesLogPath "${_unparsedLinesFile}") endif() message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesLogPath}") endif() From 85e38d526c45e8b6d50e6246db7c1d786708cfda Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 20:22:33 +0100 Subject: [PATCH 163/169] make sure unparsed line file contents ends with newline --- CMake/cotire.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index bc2de56..56b957a 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1505,7 +1505,7 @@ function (cotire_generate_prefix_header _prefixFile) endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() - file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}") + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") endfunction() function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) From 150e5c6a3e8b47ba8486e869385d2e8c4d904a82 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 17 Mar 2018 21:20:20 +0100 Subject: [PATCH 164/169] remove unnecessary quoting --- CMake/cotire.cmake | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 56b957a..eef78b9 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1535,7 +1535,7 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags # append to list list (APPEND _flags -H -E) if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") - list (APPEND _flags "-fdirectives-only") + list (APPEND _flags -fdirectives-only) endif() else() # return as a flag string @@ -1755,10 +1755,10 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio if ("${_language}" STREQUAL "CXX") list (APPEND _flags -Kc++) endif() - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") + list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-create "${_pchName}" -fsyntax-only "${_hostFile}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") if (NOT _pchSuppressMessages) - list (APPEND _flags "-Wpch-messages") + list (APPEND _flags -Wpch-messages) endif() endif() else() @@ -1818,7 +1818,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list - list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") + list (APPEND _flags -Winvalid-pch -include "${_prefixFile}") else() # return as a flag string set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") @@ -1830,7 +1830,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list - list (APPEND -include "${_prefixFile}") + list (APPEND _flags -include "${_prefixFile}") else() # return as a flag string set (_flags "-include \"${_prefixFile}\"") @@ -1907,10 +1907,10 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV endif() if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") + list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-use "${_pchName}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") if (NOT _pchSuppressMessages) - list (APPEND _flags "-Wpch-messages") + list (APPEND _flags -Wpch-messages) endif() endif() else() @@ -1926,7 +1926,7 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # no precompiled header, force inclusion of prefix header if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}") + list (APPEND _flags -include "${_prefixFile}") else() # return as a flag string set (_flags "-include \"${_prefixFile}\"") @@ -2948,7 +2948,11 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (_sourceFiles ${ARGN}) get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)") - set (_numberOfThreads "${CMAKE_MATCH_2}") + if (DEFINED CMAKE_MATCH_2) + set (_numberOfThreads "${CMAKE_MATCH_2}") + else() + set (_numberOfThreads "") + endif() if (NOT _numberOfThreads) # use all available cores ProcessorCount(_numberOfThreads) From bebfeb488618cfebe5f5ac7d38fdc5fa0eaa33de Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Mar 2018 10:20:02 +0100 Subject: [PATCH 165/169] honor source file property COMPILE_OPTIONS --- CMake/cotire.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index eef78b9..42d14e6 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -239,7 +239,13 @@ function (cotire_filter_language_source_files _language _target _sourceFilesVar # add to excluded sources, if file has custom compile flags list (APPEND _excludedSourceFiles "${_sourceFile}") else() - list (APPEND _sourceFiles "${_sourceFile}") + get_source_file_property(_sourceCompileOptions "${_sourceFile}" COMPILE_OPTIONS) + if (_sourceCompileOptions) + # add to excluded sources, if file has list of custom compile options + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") + endif() endif() endif() endforeach() From a8b50baf873f75c4c363a7cfd8b66898b94c4dcc Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Mar 2018 10:20:46 +0100 Subject: [PATCH 166/169] fix handing of MANUALLY_ADDED_DEPENDENCIES --- CMake/cotire.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 42d14e6..850aa85 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3121,6 +3121,7 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + # handle object libraries which are part of the target's sources get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$") cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles}) @@ -3469,7 +3470,9 @@ function (cotire_target_link_libraries _target) get_target_property(_manualDependencies ${_target} MANUALLY_ADDED_DEPENDENCIES) if (_manualDependencies) cotire_map_libraries("${_linkLibrariesStrategy}" _unityManualDependencies ${_manualDependencies}) - add_dependencies("${_unityTargetName}" _unityManualDependencies) + if (_unityManualDependencies) + add_dependencies("${_unityTargetName}" ${_unityManualDependencies}) + endif() endif() endif() endif() From 80fd4ee00f5c601c3a1457442e3fd481c48fdb44 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Mar 2018 10:43:51 +0100 Subject: [PATCH 167/169] enable parallel compilation of unity target for MSVC --- CMake/cotire.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 850aa85..97275d6 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -3309,6 +3309,13 @@ function (cotire_setup_unity_build_target _languages _configurations _target) set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) endif() endif() + # enable parallel compilation for MSVC + if (MSVC AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") + list (LENGTH _unityTargetSources _numberOfUnityTargetSources) + if (_numberOfUnityTargetSources GREATER 1) + set_property(TARGET ${_unityTargetName} APPEND PROPERTY COMPILE_OPTIONS "/MP") + endif() + endif() cotire_init_target(${_unityTargetName}) cotire_add_to_unity_all_target(${_unityTargetName}) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") From db777590be7cc4d14ee7c1937f7631f99335dea3 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Mar 2018 10:59:30 +0100 Subject: [PATCH 168/169] docu updates --- MANUAL.md | 8 ++++---- README.md | 5 +++-- license | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index 09f7ba4..c522eec 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -773,19 +773,19 @@ is not compatible with those of precompiled header file) upon compilation of cot Cotire is not compatible with [Xoreax IncrediBuild][XGE]. -[1260]:http://www.cmake.org/Bug/view.php?id=1260 +[1260]:https://cmake.org/Bug/view.php?id=1260 [ccch]:https://ccache.samba.org/ [ccch_pch]:https://ccache.samba.org/manual.html#_precompiled_headers -[clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiled-headers +[clang_pch]:https://clang.llvm.org/docs/UsersManual.html#precompiled-headers [gcc_pch]:https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [msvc_pch]:https://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx [msvc_pch_create]:https://msdn.microsoft.com/en-us/library/7zc28563(v=vs.90).aspx [msvc_pch_use]:https://msdn.microsoft.com/en-us/library/z0atkd6c(v=vs.90).aspx [ninja_issue]:https://cmake.org/Bug/view.php?id=13234 -[EoUB]:https://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ +[EoUB]:http://altdevblog.com/2011/08/14/the-evils-of-unity-builds/ [pch]:https://en.wikipedia.org/wiki/Precompiled_header [scu]:https://en.wikipedia.org/wiki/Single_Compilation_Unit -[objlib]:https://cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library +[objlib]:https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries [pfh]:https://en.wikipedia.org/wiki/Prefix_header [icc_linux]:https://software.intel.com/en-us/c-compilers/ipsxe-support [XGE]:https://www.incredibuild.com/ diff --git a/README.md b/README.md index b97dbf1..cc4c8de 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,8 @@ requirements * [CMake 2.8.12][cmk] or newer. The executable `cmake` should be on the system path. * [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows. -* [GCC][gcc] or [Clang][clang] under Linux or OS X. +* [Clang][clang] under Windows, Linux or OS X. +* [GCC][gcc] under Linux or OS X. * [Intel C++ compiler][intel] under Windows, Linux or OS X. * [Xcode][xcdt] application or Xcode Command Line Tools under OS X. @@ -129,7 +130,7 @@ known issues [vslstd]:https://www.visualstudio.com/ [xcdt]:https://developer.apple.com/xcode/ [PCHH]:https://gcc.gnu.org/wiki/PCHHaters -[EoUB]:https://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ +[EoUB]:http://altdevblog.com/2011/08/14/the-evils-of-unity-builds/ [jom]:https://wiki.qt.io/Jom [intel]:https://software.intel.com/en-us/c-compilers [XGE]:https://www.incredibuild.com/ diff --git a/license b/license index 33a6ea7..68c37ca 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -Copyright (c) 2012-2017 Sascha Kratky +Copyright (c) 2012-2018 Sascha Kratky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 391bf6b7609e14f5976bd5247b68d63cbf8d4d12 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 18 Mar 2018 14:54:52 +0100 Subject: [PATCH 169/169] update history --- HISTORY.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c92e0b1..db42354 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,16 @@ +## 1.8.0 (2018-03-18) + +* support for clang-cl.exe under Windows. +* faster prefix header generation for Clang. +* enable parallel compilation of unity target for MSVC. +* CMake 3.9 and 3.10 compatibility fixes. +* disable inclusion of timestamp in precompiled headers for Clang. +* work around ccache reporting incorrect configuration. +* honor `MANUALLY_ADDED_DEPENDENCIES` property upon generation of unity targets. +* use default setting of 2 for `COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES`. +* drop broken support for unity building of targets with automatic CMake Qt processing turned on. +* manual updates. + ## 1.7.10 (2017-06-16) * CMake 3.8 compatibility. @@ -18,7 +31,7 @@ * convert Windows paths in include directories to CMake paths (thanks wdx04). * replace object library with corresponding unity object library when using `COPY_UNITY` linking strategy. * better error reporting from prefix header generation. - + ## 1.7.8 (2016-03-27) * fix `COPY_UNITY` linking strategy for private link dependencies.