(CFACT-223) Update to Cotire 1.6.9 with import library patch applied.
Updating cotire to 1.6.9 with a preemptive patch applied to fix the
import library name on Windows.
Peter Huene
9 years ago
43 | 43 | cmake_policy(POP) |
44 | 44 | endif() |
45 | 45 | |
46 | if (NOT CMAKE_VERSION VERSION_LESS "3.1.0") | |
47 | # include TARGET_OBJECTS expressions in a target's SOURCES property | |
48 | cmake_policy(SET CMP0051 NEW) | |
49 | # only interpret if() arguments as variables or keywords when unquoted | |
50 | cmake_policy(SET CMP0054 NEW) | |
51 | endif() | |
52 | ||
46 | 53 | set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") |
47 | set (COTIRE_CMAKE_MODULE_VERSION "1.6.6") | |
54 | set (COTIRE_CMAKE_MODULE_VERSION "1.6.9") | |
48 | 55 | |
49 | 56 | include(CMakeParseArguments) |
50 | 57 | include(ProcessorCount) |
84 | 91 | endif() |
85 | 92 | endfunction() |
86 | 93 | |
94 | function (cotire_get_configuration_types _configsVar) | |
95 | set (_configs "") | |
96 | if (CMAKE_CONFIGURATION_TYPES) | |
97 | list (APPEND _configs ${CMAKE_CONFIGURATION_TYPES}) | |
98 | endif() | |
99 | if (CMAKE_BUILD_TYPE) | |
100 | list (APPEND _configs "${CMAKE_BUILD_TYPE}") | |
101 | endif() | |
102 | if (_configs) | |
103 | list (REMOVE_DUPLICATES _configs) | |
104 | set (${_configsVar} ${_configs} PARENT_SCOPE) | |
105 | else() | |
106 | set (${_configsVar} "None" PARENT_SCOPE) | |
107 | endif() | |
108 | endfunction() | |
109 | ||
87 | 110 | function (cotire_get_source_file_extension _sourceFile _extVar) |
88 | 111 | # get_filename_component returns extension from first occurrence of . in file name |
89 | 112 | # this function computes the extension from last occurrence of . in file name |
134 | 157 | message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") |
135 | 158 | message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") |
136 | 159 | endif() |
137 | foreach (_sourceFile ${ARGN}) | |
160 | if (CMAKE_VERSION VERSION_LESS "3.1.0") | |
161 | set (_allSourceFiles ${ARGN}) | |
162 | else() | |
163 | # as of CMake 3.1 target sources may contain generator expressions | |
164 | # since we cannot obtain required property information about source files added | |
165 | # through generator expressions at configure time, we filter them out | |
166 | string (GENEX_STRIP "${ARGN}" _allSourceFiles) | |
167 | endif() | |
168 | foreach (_sourceFile ${_allSourceFiles}) | |
138 | 169 | get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) |
139 | 170 | get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) |
140 | 171 | get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) |
465 | 496 | if (_targetDirs) |
466 | 497 | list (APPEND _systemIncludeDirs ${_targetDirs}) |
467 | 498 | endif() |
468 | ||
469 | 499 | # interface include directories from linked library targets |
470 | 500 | cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) |
471 | 501 | foreach (_library ${_linkLibraries}) |
894 | 924 | # English: "Note: including file: C:\directory\file" |
895 | 925 | # German: "Hinweis: Einlesen der Datei: C:\directory\file" |
896 | 926 | # We use a very general regular expression, relying on the presence of the : characters |
897 | if (_line MATCHES ":( +)([^:]+:[^:]+)$") | |
927 | if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$") | |
898 | 928 | # Visual Studio compiler output |
899 | 929 | string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) |
900 | 930 | get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) |
1123 | 1153 | set(_options "") |
1124 | 1154 | set(_oneValueArgs LANGUAGE) |
1125 | 1155 | set(_multiValueArgs |
1126 | DEPENDS SOURCES_COMPILE_DEFINITIONS | |
1156 | DEPENDS SOURCE_LOCATIONS SOURCES_COMPILE_DEFINITIONS | |
1127 | 1157 | PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) |
1128 | 1158 | cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) |
1129 | 1159 | if (_option_DEPENDS) |
1157 | 1187 | endif() |
1158 | 1188 | endif() |
1159 | 1189 | set (_compileUndefinitions "") |
1190 | set (_index 0) | |
1160 | 1191 | foreach (_sourceFile ${_sourceFiles}) |
1161 | 1192 | cotire_get_source_compile_definitions( |
1162 | 1193 | "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions |
1188 | 1219 | list (INSERT _compileUndefinitions 0 "${_definition}") |
1189 | 1220 | endif() |
1190 | 1221 | endforeach() |
1191 | get_filename_component(_sourceFile "${_sourceFile}" ABSOLUTE) | |
1222 | if (_option_SOURCE_LOCATIONS) | |
1223 | # use explicitly provided source file location | |
1224 | list (GET _option_SOURCE_LOCATIONS ${_index} _sourceFileLocation) | |
1225 | else() | |
1226 | # use absolute path as source file location | |
1227 | get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE) | |
1228 | endif() | |
1192 | 1229 | if (WIN32) |
1193 | file (TO_NATIVE_PATH "${_sourceFile}" _sourceFile) | |
1194 | endif() | |
1195 | list (APPEND _contents "#include \"${_sourceFile}\"") | |
1230 | file (TO_NATIVE_PATH "${_sourceFileLocation}" _sourceFileLocation) | |
1231 | endif() | |
1232 | list (APPEND _contents "#include \"${_sourceFileLocation}\"") | |
1233 | math (EXPR _index "${_index} + 1") | |
1196 | 1234 | endforeach() |
1197 | 1235 | if (_compileUndefinitions) |
1198 | 1236 | cotire_append_undefs(_contents ${_compileUndefinitions}) |
1654 | 1692 | set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) |
1655 | 1693 | endif() |
1656 | 1694 | if (CMAKE_${_language}_COMPILER MATCHES "ccache") |
1657 | if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") | |
1695 | if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") | |
1658 | 1696 | set (${_msgVar} |
1659 | "ccache requires the environment variable CCACHE_SLOPPINESS to be set to time_macros." | |
1697 | "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." | |
1660 | 1698 | PARENT_SCOPE) |
1661 | 1699 | endif() |
1662 | 1700 | endif() |
1663 | 1701 | if (APPLE) |
1664 | 1702 | # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) |
1665 | if (CMAKE_CONFIGURATION_TYPES) | |
1666 | set (_configs ${CMAKE_CONFIGURATION_TYPES}) | |
1667 | elseif (CMAKE_BUILD_TYPE) | |
1668 | set (_configs ${CMAKE_BUILD_TYPE}) | |
1669 | else() | |
1670 | set (_configs "None") | |
1671 | endif() | |
1703 | cotire_get_configuration_types(_configs) | |
1672 | 1704 | foreach (_config ${_configs}) |
1673 | 1705 | set (_targetFlags "") |
1674 | 1706 | cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) |
1905 | 1937 | |
1906 | 1938 | function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar _targetConfigScriptVar) |
1907 | 1939 | set (COTIRE_TARGET_SOURCES ${ARGN}) |
1940 | cotire_get_source_file_property_values(COTIRE_TARGET_SOURCE_LOCATIONS LOCATION ${COTIRE_TARGET_SOURCES}) | |
1908 | 1941 | cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) |
1909 | 1942 | cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) |
1910 | 1943 | # set up variables to be configured |
1939 | 1972 | set (_contents "") |
1940 | 1973 | set (_contentsHasGeneratorExpressions FALSE) |
1941 | 1974 | foreach (_var IN LISTS _matchVars ITEMS |
1942 | MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES | |
1975 | XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES | |
1943 | 1976 | CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 |
1944 | 1977 | CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) |
1945 | 1978 | if (DEFINED ${_var}) |
2168 | 2201 | # see cotire_setup_pch_file_inclusion |
2169 | 2202 | if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") |
2170 | 2203 | get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) |
2171 | get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) | |
2172 | set (_flags "") | |
2173 | cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) | |
2174 | cotire_add_prefix_pch_inclusion_flags( | |
2175 | "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" | |
2176 | "${_prefixFile}" "${_pchFile}" _flags) | |
2177 | set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") | |
2204 | if (_prefixFile) | |
2205 | set (_flags "") | |
2206 | cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) | |
2207 | get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) | |
2208 | cotire_add_prefix_pch_inclusion_flags( | |
2209 | "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" | |
2210 | "${_prefixFile}" "${_pchFile}" _flags) | |
2211 | set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") | |
2212 | endif() | |
2178 | 2213 | endif() |
2179 | 2214 | endif() |
2180 | 2215 | endif() |
2186 | 2221 | foreach (_unityFile ${_unityFiles}) |
2187 | 2222 | file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") |
2188 | 2223 | set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) |
2189 | # set up compiled unity source dependencies | |
2224 | # set up compiled unity source dependencies via OBJECT_DEPENDS | |
2190 | 2225 | # this ensures that missing source files are generated before the unity file is compiled |
2191 | 2226 | if (COTIRE_DEBUG AND _dependencySources) |
2192 | 2227 | message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}") |
2193 | 2228 | endif() |
2194 | 2229 | if (_dependencySources) |
2195 | set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) | |
2230 | # the OBJECT_DEPENDS property requires a list of full paths | |
2231 | set (_objectDependsPaths "") | |
2232 | foreach (_sourceFile ${_dependencySources}) | |
2233 | get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION) | |
2234 | list (APPEND _objectDependsPaths "${_sourceLocation}") | |
2235 | endforeach() | |
2236 | set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths}) | |
2196 | 2237 | endif() |
2197 | 2238 | if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") |
2198 | 2239 | # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel |
2200 | 2241 | endif() |
2201 | 2242 | cotire_set_cmd_to_prologue(_unityCmd) |
2202 | 2243 | list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}") |
2244 | if (CMAKE_VERSION VERSION_LESS "3.1.0") | |
2245 | set (_unityCmdDepends "${_targetScript}") | |
2246 | else() | |
2247 | # CMake 3.1.0 supports generator expressions in arguments to DEPENDS | |
2248 | set (_unityCmdDepends "${_targetConfigScript}") | |
2249 | endif() | |
2203 | 2250 | if (COTIRE_DEBUG) |
2204 | message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript}") | |
2251 | message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}") | |
2205 | 2252 | endif() |
2206 | 2253 | add_custom_command( |
2207 | 2254 | OUTPUT "${_unityFile}" |
2208 | 2255 | COMMAND ${_unityCmd} |
2209 | DEPENDS "${_targetScript}" | |
2256 | DEPENDS ${_unityCmdDepends} | |
2210 | 2257 | COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" |
2211 | 2258 | WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) |
2212 | 2259 | list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) |
2382 | 2429 | set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) |
2383 | 2430 | endfunction() |
2384 | 2431 | |
2385 | function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar) | |
2432 | function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar _wholeTargetVar) | |
2386 | 2433 | set (_languages ${ARGN}) |
2387 | 2434 | set (_allSourceFiles "") |
2388 | 2435 | set (_allExcludedSourceFiles "") |
2389 | 2436 | set (_allCotiredSourceFiles "") |
2390 | 2437 | set (_targetLanguages "") |
2438 | set (_pchEligibleTargetLanguages "") | |
2391 | 2439 | get_target_property(_targetType ${_target} TYPE) |
2392 | 2440 | get_target_property(_targetSourceFiles ${_target} SOURCES) |
2393 | 2441 | get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) |
2417 | 2465 | if (_sourceFiles) |
2418 | 2466 | list (APPEND _allSourceFiles ${_sourceFiles}) |
2419 | 2467 | endif() |
2468 | list (LENGTH _sourceFiles _numberOfSources) | |
2469 | if (NOT _numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) | |
2470 | list (APPEND _pchEligibleTargetLanguages ${_language}) | |
2471 | endif() | |
2420 | 2472 | if (_excludedSources) |
2421 | 2473 | list (APPEND _allExcludedSourceFiles ${_excludedSources}) |
2422 | 2474 | endif() |
2432 | 2484 | set (_targetAddSCU FALSE) |
2433 | 2485 | endif() |
2434 | 2486 | if (_targetUsePCH) |
2435 | list (LENGTH _allSourceFiles _numberOfSources) | |
2436 | if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) | |
2437 | set (_disableMsg "Too few applicable sources.") | |
2438 | set (_targetUsePCH FALSE) | |
2439 | elseif (_allCotiredSourceFiles) | |
2487 | if (_allCotiredSourceFiles) | |
2440 | 2488 | cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles}) |
2441 | 2489 | list (REMOVE_DUPLICATES _cotireTargets) |
2442 | 2490 | string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}") |
2444 | 2492 | set (_disableMsg "${_disableMsg} Set target property COTIRE_ENABLE_PRECOMPILED_HEADER to FALSE for targets ${_target},") |
2445 | 2493 | set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.") |
2446 | 2494 | set (_targetMsgLevel SEND_ERROR) |
2495 | set (_targetUsePCH FALSE) | |
2496 | elseif (NOT _pchEligibleTargetLanguages) | |
2497 | set (_disableMsg "Too few applicable sources.") | |
2447 | 2498 | set (_targetUsePCH FALSE) |
2448 | 2499 | elseif (XCODE AND _allExcludedSourceFiles) |
2449 | 2500 | # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target |
2469 | 2520 | message (${_targetMsgLevel} "${_targetMsg}") |
2470 | 2521 | endif() |
2471 | 2522 | endif() |
2523 | list (LENGTH _targetLanguages _numberOfLanguages) | |
2524 | if (_numberOfLanguages GREATER 1 OR _allExcludedSourceFiles) | |
2525 | set (${_wholeTargetVar} FALSE PARENT_SCOPE) | |
2526 | else() | |
2527 | set (${_wholeTargetVar} TRUE PARENT_SCOPE) | |
2528 | endif() | |
2472 | 2529 | set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) |
2473 | 2530 | endfunction() |
2474 | 2531 | |
2496 | 2553 | set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) |
2497 | 2554 | endfunction() |
2498 | 2555 | |
2499 | function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTargetVar _cmdsVar) | |
2556 | function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTarget _cmdsVar) | |
2500 | 2557 | set (${_cmdsVar} "" PARENT_SCOPE) |
2501 | 2558 | get_target_property(_targetSourceFiles ${_target} SOURCES) |
2502 | 2559 | set (_sourceFiles "") |
2506 | 2563 | if (NOT _sourceFiles AND NOT _cotiredSources) |
2507 | 2564 | return() |
2508 | 2565 | endif() |
2509 | set (_wholeTarget ${${_wholeTargetVar}}) | |
2510 | 2566 | set (_cmds "") |
2511 | 2567 | # check for user provided unity source file list |
2512 | 2568 | get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT) |
2533 | 2589 | cotire_setup_prefix_generation_from_unity_command( |
2534 | 2590 | ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) |
2535 | 2591 | endif() |
2536 | get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) | |
2592 | # check if selected language has enough sources at all | |
2593 | list (LENGTH _sourceFiles _numberOfSources) | |
2594 | if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) | |
2595 | set (_targetUsePCH FALSE) | |
2596 | else() | |
2597 | get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) | |
2598 | endif() | |
2537 | 2599 | if (_targetUsePCH) |
2538 | 2600 | cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) |
2539 | 2601 | if (_pchFile) |
2540 | 2602 | cotire_setup_pch_file_compilation( |
2541 | 2603 | ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) |
2542 | if (_excludedSources) | |
2543 | set (_wholeTarget FALSE) | |
2544 | endif() | |
2545 | 2604 | cotire_setup_pch_file_inclusion( |
2546 | 2605 | ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) |
2547 | 2606 | endif() |
2548 | 2607 | elseif (_prefixHeaderFiles) |
2549 | # user provided prefix header must be included | |
2550 | cotire_setup_prefix_file_inclusion( | |
2551 | ${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) | |
2608 | # user provided prefix header must be included unconditionally | |
2609 | cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) | |
2552 | 2610 | endif() |
2553 | 2611 | endif() |
2554 | 2612 | # mark target as cotired for language |
2559 | 2617 | set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}") |
2560 | 2618 | endif() |
2561 | 2619 | endif() |
2562 | set (${_wholeTargetVar} ${_wholeTarget} PARENT_SCOPE) | |
2563 | 2620 | set (${_cmdsVar} ${_cmds} PARENT_SCOPE) |
2564 | 2621 | endfunction() |
2565 | 2622 | |
2699 | 2756 | LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_<CONFIG> |
2700 | 2757 | OUTPUT_NAME OUTPUT_NAME_<CONFIG> |
2701 | 2758 | RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_<CONFIG> |
2702 | PREFIX <CONFIG>_POSTFIX SUFFIX) | |
2759 | PREFIX <CONFIG>_POSTFIX SUFFIX | |
2760 | IMPORT_PREFIX IMPORT_SUFFIX) | |
2703 | 2761 | # copy compile stuff |
2704 | 2762 | cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} |
2705 | 2763 | COMPILE_DEFINITIONS COMPILE_DEFINITIONS_<CONFIG> |
2776 | 2834 | get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) |
2777 | 2835 | endif() |
2778 | 2836 | if (NOT _option_CONFIGURATIONS) |
2779 | if (CMAKE_CONFIGURATION_TYPES) | |
2780 | set (_option_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) | |
2781 | elseif (CMAKE_BUILD_TYPE) | |
2782 | set (_option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}") | |
2783 | else() | |
2784 | set (_option_CONFIGURATIONS "None") | |
2785 | endif() | |
2837 | cotire_get_configuration_types(_option_CONFIGURATIONS) | |
2786 | 2838 | endif() |
2787 | 2839 | # trivial checks |
2788 | 2840 | get_target_property(_imported ${_target} IMPORTED) |
2815 | 2867 | endif() |
2816 | 2868 | endif() |
2817 | 2869 | # choose languages that apply to the target |
2818 | cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages ${_option_LANGUAGES}) | |
2870 | cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) | |
2819 | 2871 | if (NOT _targetLanguages) |
2820 | 2872 | return() |
2821 | endif() | |
2822 | list (LENGTH _targetLanguages _numberOfLanguages) | |
2823 | if (_numberOfLanguages GREATER 1) | |
2824 | set (_wholeTarget FALSE) | |
2825 | else() | |
2826 | set (_wholeTarget TRUE) | |
2827 | 2873 | endif() |
2828 | 2874 | set (_cmds "") |
2829 | 2875 | foreach (_language ${_targetLanguages}) |
2830 | 2876 | cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" |
2831 | "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} _wholeTarget _cmd) | |
2877 | "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} ${_wholeTarget} _cmd) | |
2832 | 2878 | if (_cmd) |
2833 | 2879 | list (APPEND _cmds ${_cmd}) |
2834 | 2880 | endif() |
2852 | 2898 | set (_mappedLibraries "") |
2853 | 2899 | foreach (_library ${ARGN}) |
2854 | 2900 | if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") |
2901 | # use target's corresponding unity target, if available | |
2855 | 2902 | get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) |
2856 | 2903 | if (TARGET "${_libraryUnityTargetName}") |
2857 | 2904 | list (APPEND _mappedLibraries "${_libraryUnityTargetName}") |
2877 | 2924 | if (CMAKE_VERSION VERSION_LESS "2.8.11") |
2878 | 2925 | message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") |
2879 | 2926 | else() |
2927 | set (_unityLinkLibraries "") | |
2880 | 2928 | get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) |
2929 | if (_linkLibraries) | |
2930 | list (APPEND _unityLinkLibraries ${_linkLibraries}) | |
2931 | endif() | |
2881 | 2932 | get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) |
2882 | cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries} ${_interfaceLinkLibraries}) | |
2933 | if (_interfaceLinkLibraries) | |
2934 | list (APPEND _unityLinkLibraries ${_interfaceLinkLibraries}) | |
2935 | endif() | |
2936 | cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_unityLinkLibraries}) | |
2883 | 2937 | if (COTIRE_DEBUG) |
2884 | 2938 | message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") |
2885 | 2939 | endif() |
3025 | 3079 | list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) |
3026 | 3080 | if (_index GREATER -1) |
3027 | 3081 | set (_sources ${COTIRE_TARGET_SOURCES}) |
3082 | set (_sourceLocations ${COTIRE_TARGET_SOURCE_LOCATIONS}) | |
3028 | 3083 | set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) |
3029 | 3084 | else() |
3030 | 3085 | if (COTIRE_DEBUG) |
3031 | 3086 | message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") |
3032 | 3087 | endif() |
3033 | 3088 | set (_sources "") |
3089 | set (_sourceLocations "") | |
3034 | 3090 | set (_sourcesDefinitions "") |
3035 | 3091 | endif() |
3036 | 3092 | set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) |
3040 | 3096 | |
3041 | 3097 | if ("${COTIRE_ARGV1}" STREQUAL "unity") |
3042 | 3098 | |
3099 | if (XCODE) | |
3100 | # executing pre-build action under Xcode, check dependency on target script | |
3101 | set (_dependsOption DEPENDS "${COTIRE_ARGV2}") | |
3102 | else() | |
3103 | # executing custom command, no need to re-check for dependencies | |
3104 | set (_dependsOption "") | |
3105 | endif() | |
3106 | ||
3043 | 3107 | cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) |
3108 | cotire_select_unity_source_files("${COTIRE_ARGV3}" _sourceLocations ${_sourceLocations}) | |
3109 | ||
3044 | 3110 | cotire_generate_unity_source( |
3045 | 3111 | "${COTIRE_ARGV3}" ${_sources} |
3046 | 3112 | LANGUAGE "${COTIRE_TARGET_LANGUAGE}" |
3047 | DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" | |
3113 | SOURCE_LOCATIONS ${_sourceLocations} | |
3048 | 3114 | SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} |
3049 | 3115 | PRE_UNDEFS ${_targetPreUndefs} |
3050 | 3116 | POST_UNDEFS ${_targetPostUndefs} |
3051 | 3117 | SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} |
3052 | SOURCES_POST_UNDEFS ${_sourcesPostUndefs}) | |
3118 | SOURCES_POST_UNDEFS ${_sourcesPostUndefs} | |
3119 | ${_dependsOption}) | |
3053 | 3120 | |
3054 | 3121 | elseif ("${COTIRE_ARGV1}" STREQUAL "prefix") |
3122 | ||
3123 | if (XCODE) | |
3124 | # executing pre-build action under Xcode, check dependency on unity file and prefix dependencies | |
3125 | set (_dependsOption DEPENDS "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS}) | |
3126 | else() | |
3127 | # executing custom command, no need to re-check for dependencies | |
3128 | set (_dependsOption "") | |
3129 | endif() | |
3055 | 3130 | |
3056 | 3131 | set (_files "") |
3057 | 3132 | foreach (_index RANGE 4 ${COTIRE_ARGC}) |
3067 | 3142 | COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" |
3068 | 3143 | COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" |
3069 | 3144 | LANGUAGE "${COTIRE_TARGET_LANGUAGE}" |
3070 | DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS} | |
3071 | 3145 | IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" |
3072 | 3146 | INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} |
3073 | 3147 | IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" |
3075 | 3149 | INCLUDE_DIRECTORIES ${_includeDirs} |
3076 | 3150 | SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} |
3077 | 3151 | COMPILE_DEFINITIONS ${_compileDefinitions} |
3078 | COMPILE_FLAGS ${_compileFlags}) | |
3152 | COMPILE_FLAGS ${_compileFlags} | |
3153 | ${_dependsOption}) | |
3079 | 3154 | |
3080 | 3155 | elseif ("${COTIRE_ARGV1}" STREQUAL "precompile") |
3081 | 3156 | |
3112 | 3187 | list (APPEND _files "${COTIRE_ARGV${_index}}") |
3113 | 3188 | endif() |
3114 | 3189 | endforeach() |
3190 | ||
3115 | 3191 | if (COTIRE_TARGET_LANGUAGE) |
3116 | 3192 | cotire_generate_unity_source(${_files} LANGUAGE "${COTIRE_TARGET_LANGUAGE}") |
3117 | 3193 | else() |