mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
CMake: update cotire to 516d78476f
This commit is contained in:
parent
7daaa604cc
commit
b3b29cfda9
@ -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
|
||||
@ -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.10")
|
||||
|
||||
# activate select policies
|
||||
if (POLICY CMP0025)
|
||||
@ -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)
|
||||
|
||||
@ -293,7 +298,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 "<CONFIG>")
|
||||
@ -309,8 +314,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)
|
||||
@ -320,13 +325,18 @@ function (cotire_copy_set_properites _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 "^\\$<\\$<CONFIG:${_config}>:([A-Za-z0-9_:-]+)>$")
|
||||
set (_library "${CMAKE_MATCH_1}")
|
||||
elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$<CONFIG:>:([A-Za-z0-9_:-]+)>$")
|
||||
set (_library "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
if (TARGET ${_library})
|
||||
list (FIND _targetRequirements ${_library} _index)
|
||||
if (_index LESS 0)
|
||||
@ -441,7 +451,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)
|
||||
@ -450,22 +460,21 @@ 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)
|
||||
if (_targetLanguageStandard)
|
||||
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()
|
||||
else()
|
||||
if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION)
|
||||
list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}")
|
||||
if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION)
|
||||
list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@ -574,7 +583,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
|
||||
@ -628,6 +637,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 AND NOT MINGW)
|
||||
# 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()
|
||||
@ -685,7 +713,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)
|
||||
@ -841,6 +869,9 @@ macro (cotire_set_cmd_to_prologue _cmdVar)
|
||||
list (APPEND ${_cmdVar} "--warn-uninitialized")
|
||||
endif()
|
||||
list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>")
|
||||
if (XCODE)
|
||||
list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE")
|
||||
endif()
|
||||
if (COTIRE_VERBOSE)
|
||||
list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON")
|
||||
elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles")
|
||||
@ -884,16 +915,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()
|
||||
@ -1184,7 +1215,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})
|
||||
@ -1257,6 +1288,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)
|
||||
@ -1444,12 +1478,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()
|
||||
@ -1635,6 +1670,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")
|
||||
@ -1642,13 +1681,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()
|
||||
@ -1759,17 +1802,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()
|
||||
@ -1817,6 +1868,14 @@ 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 "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,
|
||||
# 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}
|
||||
@ -1856,10 +1915,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)
|
||||
@ -2148,7 +2228,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
|
||||
@ -2206,14 +2286,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 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)
|
||||
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}"
|
||||
@ -2445,8 +2529,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)
|
||||
@ -2478,7 +2566,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)
|
||||
@ -2639,10 +2727,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 "")
|
||||
@ -2857,6 +2947,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 "^\\$<TARGET_OBJECTS:.+>$")
|
||||
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})
|
||||
@ -2875,6 +2975,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()
|
||||
|
||||
@ -2917,8 +3026,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 <targetname>_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)
|
||||
@ -2933,9 +3047,20 @@ 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 <targetname>_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 <targetname>_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
|
||||
@ -2948,8 +3073,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)
|
||||
@ -2969,11 +3094,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_<CONFIG>
|
||||
LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_<CONFIG>
|
||||
OUTPUT_NAME OUTPUT_NAME_<CONFIG>
|
||||
@ -2981,7 +3106,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target)
|
||||
PREFIX <CONFIG>_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_<CONFIG>
|
||||
COMPILE_FLAGS COMPILE_OPTIONS
|
||||
Fortran_FORMAT Fortran_MODULE_DIRECTORY
|
||||
@ -2990,14 +3115,15 @@ 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}
|
||||
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
|
||||
@ -3005,7 +3131,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_<CONFIG>
|
||||
@ -3013,18 +3139,19 @@ function (cotire_setup_unity_build_target _languages _configurations _target)
|
||||
LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_<CONFIG>
|
||||
LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC
|
||||
STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_<CONFIG>
|
||||
NO_SONAME SOVERSION VERSION)
|
||||
NO_SONAME SOVERSION VERSION
|
||||
LINK_WHAT_YOU_USE BUILD_RPATH)
|
||||
# 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_<CONFIG> 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_properites("${_configurations}" TARGET ${_target} ${_unityTargetName}
|
||||
cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
|
||||
GNUtoMS
|
||||
COMPILE_PDB_NAME COMPILE_PDB_NAME_<CONFIG>
|
||||
COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
|
||||
@ -3036,9 +3163,11 @@ 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 VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY)
|
||||
# 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
|
||||
@ -3151,9 +3280,15 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar)
|
||||
if (_library MATCHES "^\\$<LINK_ONLY:(.+)>$")
|
||||
set (_libraryName "${CMAKE_MATCH_1}")
|
||||
set (_linkOnly TRUE)
|
||||
set (_objectLibrary FALSE)
|
||||
elseif (_library MATCHES "^\\$<TARGET_OBJECTS:(.+)>$")
|
||||
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)
|
||||
@ -3163,6 +3298,8 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar)
|
||||
if (TARGET "${_libraryUnityTargetName}")
|
||||
if (_linkOnly)
|
||||
list (APPEND _mappedLibraries "$<LINK_ONLY:${_libraryUnityTargetName}>")
|
||||
elseif (_objectLibrary)
|
||||
list (APPEND _mappedLibraries "$<TARGET_OBJECTS:${_libraryUnityTargetName}>")
|
||||
else()
|
||||
list (APPEND _mappedLibraries "${_libraryUnityTargetName}")
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user