CMake/cotire.cmake

Tue, 15 Mar 2022 18:56:02 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 15 Mar 2022 18:56:02 +0200
changeset 184
35bbfad4d0f4
parent 7
68443f5be176
permissions
-rw-r--r--

Add missing svg icon

7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 # - cotire (compile time reducer)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 # See the cotire manual for usage hints.
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 #
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 #=============================================================================
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 # Copyright 2012-2018 Sascha Kratky
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 #
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 # Permission is hereby granted, free of charge, to any person
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 # obtaining a copy of this software and associated documentation
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 # files (the "Software"), to deal in the Software without
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 # restriction, including without limitation the rights to use,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 # copy, modify, merge, publish, distribute, sublicense, and/or sell
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 # copies of the Software, and to permit persons to whom the
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 # Software is furnished to do so, subject to the following
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 # conditions:
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 #
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 # The above copyright notice and this permission notice shall be
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 # included in all copies or substantial portions of the Software.
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 # OTHER DEALINGS IN THE SOFTWARE.
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 #=============================================================================
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 if(__COTIRE_INCLUDED)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 return()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 set(__COTIRE_INCLUDED TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 # call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 # cmake_minimum_required also sets the policy version as a side effect, which we have to avoid
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 if (NOT CMAKE_SCRIPT_MODE_FILE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38 cmake_policy(PUSH)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 cmake_minimum_required(VERSION 2.8.12)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41 if (NOT CMAKE_SCRIPT_MODE_FILE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 cmake_policy(POP)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
43 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
44
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 set (COTIRE_CMAKE_MODULE_VERSION "1.8.0")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 # activate select policies
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49 if (POLICY CMP0025)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
50 # Compiler id for Apple Clang is now AppleClang
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
51 cmake_policy(SET CMP0025 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
52 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
54 if (POLICY CMP0026)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
55 # disallow use of the LOCATION target property
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
56 cmake_policy(SET CMP0026 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
57 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
58
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
59 if (POLICY CMP0038)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
60 # targets may not link directly to themselves
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
61 cmake_policy(SET CMP0038 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
62 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
63
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
64 if (POLICY CMP0039)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
65 # utility targets may not have link dependencies
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
66 cmake_policy(SET CMP0039 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
67 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
68
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
69 if (POLICY CMP0040)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
70 # target in the TARGET signature of add_custom_command() must exist
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
71 cmake_policy(SET CMP0040 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
72 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
73
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
74 if (POLICY CMP0045)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
75 # error on non-existent target in get_target_property
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
76 cmake_policy(SET CMP0045 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
77 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
78
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
79 if (POLICY CMP0046)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
80 # error on non-existent dependency in add_dependencies
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
81 cmake_policy(SET CMP0046 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
82 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
83
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
84 if (POLICY CMP0049)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
85 # do not expand variables in target source entries
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
86 cmake_policy(SET CMP0049 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
87 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
88
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
89 if (POLICY CMP0050)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
90 # disallow add_custom_command SOURCE signatures
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
91 cmake_policy(SET CMP0050 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
92 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
93
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
94 if (POLICY CMP0051)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
95 # include TARGET_OBJECTS expressions in a target's SOURCES property
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
96 cmake_policy(SET CMP0051 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
97 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
98
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
99 if (POLICY CMP0053)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
100 # simplify variable reference and escape sequence evaluation
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
101 cmake_policy(SET CMP0053 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
102 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
103
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
104 if (POLICY CMP0054)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
105 # only interpret if() arguments as variables or keywords when unquoted
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
106 cmake_policy(SET CMP0054 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
107 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
108
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
109 if (POLICY CMP0055)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
110 # strict checking for break() command
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
111 cmake_policy(SET CMP0055 NEW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
112 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
113
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
114 include(CMakeParseArguments)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
115 include(ProcessorCount)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
116
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
117 function (cotire_get_configuration_types _configsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
118 set (_configs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
119 if (CMAKE_CONFIGURATION_TYPES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
120 list (APPEND _configs ${CMAKE_CONFIGURATION_TYPES})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
121 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
122 if (CMAKE_BUILD_TYPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
123 list (APPEND _configs "${CMAKE_BUILD_TYPE}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
124 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
125 if (_configs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
126 list (REMOVE_DUPLICATES _configs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
127 set (${_configsVar} ${_configs} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
128 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
129 set (${_configsVar} "None" PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
130 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
131 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
132
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
133 function (cotire_get_source_file_extension _sourceFile _extVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
134 # get_filename_component returns extension from first occurrence of . in file name
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
135 # this function computes the extension from last occurrence of . in file name
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
136 string (FIND "${_sourceFile}" "." _index REVERSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
137 if (_index GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
138 math (EXPR _index "${_index} + 1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
139 string (SUBSTRING "${_sourceFile}" ${_index} -1 _sourceExt)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
140 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
141 set (_sourceExt "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
142 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
143 set (${_extVar} "${_sourceExt}" PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
144 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
145
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
146 macro (cotire_check_is_path_relative_to _path _isRelativeVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
147 set (${_isRelativeVar} FALSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
148 if (IS_ABSOLUTE "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
149 foreach (_dir ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
150 file (RELATIVE_PATH _relPath "${_dir}" "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
151 if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\."))
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
152 set (${_isRelativeVar} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
153 break()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
154 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
155 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
156 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
157 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
158
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
159 function (cotire_filter_language_source_files _language _target _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
160 if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
161 set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
162 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
163 set (_languageExtensions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
164 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
165 if (CMAKE_${_language}_IGNORE_EXTENSIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
166 set (_ignoreExtensions "${CMAKE_${_language}_IGNORE_EXTENSIONS}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
167 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
168 set (_ignoreExtensions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
169 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
170 if (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
171 set (_excludeExtensions "${COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
172 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
173 set (_excludeExtensions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
174 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
175 if (COTIRE_DEBUG AND _languageExtensions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
176 message (STATUS "${_language} source file extensions: ${_languageExtensions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
177 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
178 if (COTIRE_DEBUG AND _ignoreExtensions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
179 message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
180 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
181 if (COTIRE_DEBUG AND _excludeExtensions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
182 message (STATUS "${_language} exclude extensions: ${_excludeExtensions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
183 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
184 if (CMAKE_VERSION VERSION_LESS "3.1.0")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
185 set (_allSourceFiles ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
186 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
187 # as of CMake 3.1 target sources may contain generator expressions
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
188 # since we cannot obtain required property information about source files added
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
189 # through generator expressions at configure time, we filter them out
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
190 string (GENEX_STRIP "${ARGN}" _allSourceFiles)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
191 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
192 set (_filteredSourceFiles "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
193 set (_excludedSourceFiles "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
194 foreach (_sourceFile ${_allSourceFiles})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
195 get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
196 get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
197 get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
198 if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
199 cotire_get_source_file_extension("${_sourceFile}" _sourceExt)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
200 if (_sourceExt)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
201 list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
202 if (_ignoreIndex LESS 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
203 list (FIND _excludeExtensions "${_sourceExt}" _excludeIndex)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
204 if (_excludeIndex GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
205 list (APPEND _excludedSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
206 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
207 list (FIND _languageExtensions "${_sourceExt}" _sourceIndex)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
208 if (_sourceIndex GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
209 # consider source file unless it is excluded explicitly
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
210 get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
211 if (_sourceIsExcluded)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
212 list (APPEND _excludedSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
213 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
214 list (APPEND _filteredSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
215 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
216 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
217 get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
218 if ("${_sourceLanguage}" STREQUAL "${_language}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
219 # add to excluded sources, if file is not ignored and has correct language without having the correct extension
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
220 list (APPEND _excludedSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
221 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
222 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
223 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
224 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
225 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
226 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
227 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
228 # separate filtered source files from already cotired ones
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
229 # the COTIRE_TARGET property of a source file may be set while a target is being processed by cotire
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
230 set (_sourceFiles "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
231 set (_cotiredSourceFiles "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
232 foreach (_sourceFile ${_filteredSourceFiles})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
233 get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
234 if (_sourceIsCotired)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
235 list (APPEND _cotiredSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
236 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
237 get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
238 if (_sourceCompileFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
239 # add to excluded sources, if file has custom compile flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
240 list (APPEND _excludedSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
241 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
242 get_source_file_property(_sourceCompileOptions "${_sourceFile}" COMPILE_OPTIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
243 if (_sourceCompileOptions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
244 # add to excluded sources, if file has list of custom compile options
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
245 list (APPEND _excludedSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
246 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
247 list (APPEND _sourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
248 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
249 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
250 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
251 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
252 if (COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
253 if (_sourceFiles)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
254 message (STATUS "Filtered ${_target} ${_language} sources: ${_sourceFiles}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
255 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
256 if (_excludedSourceFiles)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
257 message (STATUS "Excluded ${_target} ${_language} sources: ${_excludedSourceFiles}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
258 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
259 if (_cotiredSourceFiles)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
260 message (STATUS "Cotired ${_target} ${_language} sources: ${_cotiredSourceFiles}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
261 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
262 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
263 set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
264 set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
265 set (${_cotiredSourceFilesVar} ${_cotiredSourceFiles} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
266 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
267
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
268 function (cotire_get_objects_with_property_on _filteredObjectsVar _property _type)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
269 set (_filteredObjects "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
270 foreach (_object ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
271 get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
272 if (_isSet)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
273 get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
274 if (_propertyValue)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
275 list (APPEND _filteredObjects "${_object}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
276 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
277 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
278 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
279 set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
280 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
281
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
282 function (cotire_get_objects_with_property_off _filteredObjectsVar _property _type)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
283 set (_filteredObjects "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
284 foreach (_object ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
285 get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
286 if (_isSet)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
287 get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
288 if (NOT _propertyValue)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
289 list (APPEND _filteredObjects "${_object}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
290 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
291 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
292 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
293 set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
294 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
295
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
296 function (cotire_get_source_file_property_values _valuesVar _property)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
297 set (_values "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
298 foreach (_sourceFile ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
299 get_source_file_property(_propertyValue "${_sourceFile}" ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
300 if (_propertyValue)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
301 list (APPEND _values "${_propertyValue}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
302 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
303 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
304 set (${_valuesVar} ${_values} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
305 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
306
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
307 function (cotire_resolve_config_properties _configurations _propertiesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
308 set (_properties "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
309 foreach (_property ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
310 if ("${_property}" MATCHES "<CONFIG>")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
311 foreach (_config ${_configurations})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
312 string (TOUPPER "${_config}" _upperConfig)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
313 string (REPLACE "<CONFIG>" "${_upperConfig}" _configProperty "${_property}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
314 list (APPEND _properties ${_configProperty})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
315 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
316 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
317 list (APPEND _properties ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
318 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
319 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
320 set (${_propertiesVar} ${_properties} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
321 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
322
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
323 function (cotire_copy_set_properties _configurations _type _source _target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
324 cotire_resolve_config_properties("${_configurations}" _properties ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
325 foreach (_property ${_properties})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
326 get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
327 if (_isSet)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
328 get_property(_propertyValue ${_type} ${_source} PROPERTY ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
329 set_property(${_type} ${_target} PROPERTY ${_property} "${_propertyValue}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
330 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
331 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
332 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
333
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
334 function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
335 set (_targetRequirements "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
336 get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
337 while (_librariesToProcess)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
338 # remove from head
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
339 list (GET _librariesToProcess 0 _library)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
340 list (REMOVE_AT _librariesToProcess 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
341 if (_library MATCHES "^\\$<\\$<CONFIG:${_config}>:([A-Za-z0-9_:-]+)>$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
342 set (_library "${CMAKE_MATCH_1}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
343 elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$<CONFIG:>:([A-Za-z0-9_:-]+)>$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
344 set (_library "${CMAKE_MATCH_1}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
345 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
346 if (TARGET ${_library})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
347 list (FIND _targetRequirements ${_library} _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
348 if (_index LESS 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
349 list (APPEND _targetRequirements ${_library})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
350 # BFS traversal of transitive libraries
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
351 get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
352 if (_libraries)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
353 list (APPEND _librariesToProcess ${_libraries})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
354 list (REMOVE_DUPLICATES _librariesToProcess)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
355 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
356 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
357 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
358 endwhile()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
359 set (${_targetRequirementsVar} ${_targetRequirements} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
360 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
361
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
362 function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
363 if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
364 set (_flagPrefix "[/-]")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
365 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
366 set (_flagPrefix "--?")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
367 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
368 set (_optionFlag "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
369 set (_matchedOptions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
370 set (_unmatchedOptions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
371 foreach (_compileFlag ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
372 if (_compileFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
373 if (_optionFlag AND NOT "${_compileFlag}" MATCHES "^${_flagPrefix}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
374 # option with separate argument
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
375 list (APPEND _matchedOptions "${_compileFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
376 set (_optionFlag "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
377 elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
378 # remember option
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
379 set (_optionFlag "${CMAKE_MATCH_2}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
380 elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})(.+)$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
381 # option with joined argument
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
382 list (APPEND _matchedOptions "${CMAKE_MATCH_3}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
383 set (_optionFlag "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
384 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
385 # flush remembered option
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
386 if (_optionFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
387 list (APPEND _matchedOptions "${_optionFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
388 set (_optionFlag "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
389 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
390 # add to unfiltered options
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
391 list (APPEND _unmatchedOptions "${_compileFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
392 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
393 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
394 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
395 if (_optionFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
396 list (APPEND _matchedOptions "${_optionFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
397 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
398 if (COTIRE_DEBUG AND _matchedOptions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
399 message (STATUS "Filter ${_flagFilter} matched: ${_matchedOptions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
400 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
401 if (COTIRE_DEBUG AND _unmatchedOptions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
402 message (STATUS "Filter ${_flagFilter} unmatched: ${_unmatchedOptions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
403 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
404 set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
405 set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
406 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
407
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
408 function (cotire_is_target_supported _target _isSupportedVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
409 if (NOT TARGET "${_target}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
410 set (${_isSupportedVar} FALSE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
411 return()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
412 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
413 get_target_property(_imported ${_target} IMPORTED)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
414 if (_imported)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
415 set (${_isSupportedVar} FALSE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
416 return()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
417 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
418 get_target_property(_targetType ${_target} TYPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
419 if (NOT _targetType MATCHES "EXECUTABLE|(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
420 set (${_isSupportedVar} FALSE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
421 return()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
422 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
423 set (${_isSupportedVar} TRUE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
424 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
425
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
426 function (cotire_get_target_compile_flags _config _language _target _flagsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
427 string (TOUPPER "${_config}" _upperConfig)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
428 # collect options from CMake language variables
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
429 set (_compileFlags "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
430 if (CMAKE_${_language}_FLAGS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
431 set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
432 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
433 if (CMAKE_${_language}_FLAGS_${_upperConfig})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
434 set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
435 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
436 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
437 # add target compile flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
438 get_target_property(_targetflags ${_target} COMPILE_FLAGS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
439 if (_targetflags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
440 set (_compileFlags "${_compileFlags} ${_targetflags}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
441 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
442 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
443 if (UNIX)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
444 separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
445 elseif(WIN32)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
446 separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
447 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
448 separate_arguments(_compileFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
449 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
450 # target compile options
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
451 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
452 get_target_property(_targetOptions ${_target} COMPILE_OPTIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
453 if (_targetOptions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
454 list (APPEND _compileFlags ${_targetOptions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
455 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
456 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
457 # interface compile options from linked library targets
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
458 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
459 set (_linkedTargets "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
460 cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
461 foreach (_linkedTarget ${_linkedTargets})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
462 get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
463 if (_targetOptions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
464 list (APPEND _compileFlags ${_targetOptions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
465 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
466 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
467 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
468 # handle language standard properties
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
469 if (CMAKE_${_language}_STANDARD_DEFAULT)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
470 # used compiler supports language standard levels
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
471 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
472 get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
473 if (_targetLanguageStandard)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
474 set (_type "EXTENSION")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
475 get_property(_isSet TARGET ${_target} PROPERTY ${_language}_EXTENSIONS SET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
476 if (_isSet)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
477 get_target_property(_targetUseLanguageExtensions ${_target} ${_language}_EXTENSIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
478 if (NOT _targetUseLanguageExtensions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
479 set (_type "STANDARD")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
480 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
481 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
482 if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
483 list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
484 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
485 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
486 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
487 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
488 # handle the POSITION_INDEPENDENT_CODE target property
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
489 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
490 get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
491 if (_targetPIC)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
492 get_target_property(_targetType ${_target} TYPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
493 if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
494 list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIE}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
495 elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
496 list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIC}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
497 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
498 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
499 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
500 # handle visibility target properties
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
501 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
502 get_target_property(_targetVisibility ${_target} ${_language}_VISIBILITY_PRESET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
503 if (_targetVisibility AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
504 list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY}${_targetVisibility}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
505 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
506 get_target_property(_targetVisibilityInlines ${_target} VISIBILITY_INLINES_HIDDEN)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
507 if (_targetVisibilityInlines AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
508 list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
509 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
510 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
511 # platform specific flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
512 if (APPLE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
513 get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
514 if (NOT _architectures)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
515 get_target_property(_architectures ${_target} OSX_ARCHITECTURES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
516 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
517 if (_architectures)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
518 foreach (_arch ${_architectures})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
519 list (APPEND _compileFlags "-arch" "${_arch}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
520 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
521 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
522 if (CMAKE_OSX_SYSROOT)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
523 if (CMAKE_${_language}_SYSROOT_FLAG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
524 list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
525 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
526 list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
527 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
528 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
529 if (CMAKE_OSX_DEPLOYMENT_TARGET)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
530 if (CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
531 list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
532 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
533 list (APPEND _compileFlags "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
534 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
535 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
536 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
537 if (COTIRE_DEBUG AND _compileFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
538 message (STATUS "Target ${_target} compile flags: ${_compileFlags}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
539 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
540 set (${_flagsVar} ${_compileFlags} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
541 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
542
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
543 function (cotire_get_target_include_directories _config _language _target _includeDirsVar _systemIncludeDirsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
544 set (_includeDirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
545 set (_systemIncludeDirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
546 # default include dirs
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
547 if (CMAKE_INCLUDE_CURRENT_DIR)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
548 list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
549 list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
550 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
551 set (_targetFlags "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
552 cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
553 # parse additional include directories from target compile flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
554 if (CMAKE_INCLUDE_FLAG_${_language})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
555 string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
556 string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
557 if (_includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
558 set (_dirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
559 cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
560 if (_dirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
561 list (APPEND _includeDirs ${_dirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
562 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
563 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
564 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
565 # parse additional system include directories from target compile flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
566 if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
567 string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
568 string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
569 if (_includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
570 set (_dirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
571 cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
572 if (_dirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
573 list (APPEND _systemIncludeDirs ${_dirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
574 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
575 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
576 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
577 # target include directories
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
578 get_directory_property(_dirs DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
579 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
580 get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
581 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
582 list (APPEND _dirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
583 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
584 get_target_property(_targetDirs ${_target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
585 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
586 list (APPEND _systemIncludeDirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
587 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
588 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
589 # interface include directories from linked library targets
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
590 if (_target)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
591 set (_linkedTargets "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
592 cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
593 foreach (_linkedTarget ${_linkedTargets})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
594 get_target_property(_linkedTargetType ${_linkedTarget} TYPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
595 if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
596 _linkedTargetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
597 # CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE refers to CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
598 # at the time, when the target was created. These correspond to the target properties BINARY_DIR and SOURCE_DIR
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
599 # which are only available with CMake 3.4 or later.
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
600 get_target_property(_targetDirs ${_linkedTarget} BINARY_DIR)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
601 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
602 list (APPEND _dirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
603 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
604 get_target_property(_targetDirs ${_linkedTarget} SOURCE_DIR)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
605 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
606 list (APPEND _dirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
607 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
608 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
609 get_target_property(_targetDirs ${_linkedTarget} INTERFACE_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
610 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
611 list (APPEND _dirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
612 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
613 get_target_property(_targetDirs ${_linkedTarget} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
614 if (_targetDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
615 list (APPEND _systemIncludeDirs ${_targetDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
616 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
617 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
618 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
619 if (dirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
620 list (REMOVE_DUPLICATES _dirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
621 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
622 list (LENGTH _includeDirs _projectInsertIndex)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
623 foreach (_dir ${_dirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
624 if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
625 cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
626 if (_isRelative)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
627 list (LENGTH _includeDirs _len)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
628 if (_len EQUAL _projectInsertIndex)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
629 list (APPEND _includeDirs "${_dir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
630 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
631 list (INSERT _includeDirs _projectInsertIndex "${_dir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
632 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
633 math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
634 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
635 list (APPEND _includeDirs "${_dir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
636 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
637 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
638 list (APPEND _includeDirs "${_dir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
639 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
640 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
641 list (REMOVE_DUPLICATES _includeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
642 list (REMOVE_DUPLICATES _systemIncludeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
643 if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
644 list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
645 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
646 if (WIN32 AND NOT MINGW)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
647 # convert Windows paths in include directories to CMake paths
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
648 if (_includeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
649 set (_paths "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
650 foreach (_dir ${_includeDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
651 file (TO_CMAKE_PATH "${_dir}" _path)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
652 list (APPEND _paths "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
653 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
654 set (_includeDirs ${_paths})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
655 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
656 if (_systemIncludeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
657 set (_paths "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
658 foreach (_dir ${_systemIncludeDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
659 file (TO_CMAKE_PATH "${_dir}" _path)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
660 list (APPEND _paths "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
661 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
662 set (_systemIncludeDirs ${_paths})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
663 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
664 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
665 if (COTIRE_DEBUG AND _includeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
666 message (STATUS "Target ${_target} include dirs: ${_includeDirs}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
667 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
668 set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
669 if (COTIRE_DEBUG AND _systemIncludeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
670 message (STATUS "Target ${_target} system include dirs: ${_systemIncludeDirs}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
671 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
672 set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
673 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
674
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
675 function (cotire_get_target_export_symbol _target _exportSymbolVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
676 set (_exportSymbol "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
677 get_target_property(_targetType ${_target} TYPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
678 get_target_property(_enableExports ${_target} ENABLE_EXPORTS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
679 if (_targetType MATCHES "(SHARED|MODULE)_LIBRARY" OR
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
680 (_targetType STREQUAL "EXECUTABLE" AND _enableExports))
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
681 get_target_property(_exportSymbol ${_target} DEFINE_SYMBOL)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
682 if (NOT _exportSymbol)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
683 set (_exportSymbol "${_target}_EXPORTS")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
684 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
685 string (MAKE_C_IDENTIFIER "${_exportSymbol}" _exportSymbol)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
686 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
687 set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
688 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
689
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
690 function (cotire_get_target_compile_definitions _config _language _target _definitionsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
691 string (TOUPPER "${_config}" _upperConfig)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
692 set (_configDefinitions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
693 # CMAKE_INTDIR for multi-configuration build systems
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
694 if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
695 list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
696 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
697 # target export define symbol
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
698 cotire_get_target_export_symbol("${_target}" _defineSymbol)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
699 if (_defineSymbol)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
700 list (APPEND _configDefinitions "${_defineSymbol}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
701 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
702 # directory compile definitions
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
703 get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
704 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
705 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
706 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
707 get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS_${_upperConfig})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
708 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
709 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
710 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
711 # target compile definitions
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
712 get_target_property(_definitions ${_target} COMPILE_DEFINITIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
713 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
714 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
715 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
716 get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_upperConfig})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
717 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
718 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
719 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
720 # interface compile definitions from linked library targets
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
721 set (_linkedTargets "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
722 cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
723 foreach (_linkedTarget ${_linkedTargets})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
724 get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
725 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
726 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
727 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
728 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
729 # parse additional compile definitions from target compile flags
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
730 # and do not look at directory compile definitions, which we already handled
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
731 set (_targetFlags "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
732 cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
733 cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
734 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
735 list (APPEND _configDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
736 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
737 list (REMOVE_DUPLICATES _configDefinitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
738 if (COTIRE_DEBUG AND _configDefinitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
739 message (STATUS "Target ${_target} compile definitions: ${_configDefinitions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
740 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
741 set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
742 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
743
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
744 function (cotire_get_target_compiler_flags _config _language _target _compilerFlagsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
745 # parse target compile flags omitting compile definitions and include directives
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
746 set (_targetFlags "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
747 cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
748 set (_flagFilter "D")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
749 if (CMAKE_INCLUDE_FLAG_${_language})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
750 string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
751 string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
752 if (_includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
753 set (_flagFilter "${_flagFilter}|${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
754 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
755 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
756 if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
757 string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
758 string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
759 if (_includeFlag)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
760 set (_flagFilter "${_flagFilter}|${_includeFlag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
761 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
762 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
763 set (_compilerFlags "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
764 cotire_filter_compile_flags("${_language}" "${_flagFilter}" _ignore _compilerFlags ${_targetFlags})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
765 if (COTIRE_DEBUG AND _compilerFlags)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
766 message (STATUS "Target ${_target} compiler flags: ${_compilerFlags}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
767 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
768 set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
769 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
770
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
771 function (cotire_add_sys_root_paths _pathsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
772 if (APPLE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
773 if (CMAKE_OSX_SYSROOT AND CMAKE_${_language}_HAS_ISYSROOT)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
774 foreach (_path IN LISTS ${_pathsVar})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
775 if (IS_ABSOLUTE "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
776 get_filename_component(_path "${CMAKE_OSX_SYSROOT}/${_path}" ABSOLUTE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
777 if (EXISTS "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
778 list (APPEND ${_pathsVar} "${_path}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
779 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
780 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
781 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
782 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
783 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
784 set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
785 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
786
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
787 function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
788 set (_extraProperties ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
789 set (_result "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
790 if (_extraProperties)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
791 list (FIND _extraProperties "${_sourceFile}" _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
792 if (_index GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
793 math (EXPR _index "${_index} + 1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
794 list (LENGTH _extraProperties _len)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
795 math (EXPR _len "${_len} - 1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
796 foreach (_index RANGE ${_index} ${_len})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
797 list (GET _extraProperties ${_index} _value)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
798 if (_value MATCHES "${_pattern}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
799 list (APPEND _result "${_value}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
800 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
801 break()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
802 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
803 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
804 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
805 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
806 set (${_resultVar} ${_result} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
807 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
808
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
809 function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
810 set (_compileDefinitions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
811 if (NOT CMAKE_SCRIPT_MODE_FILE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
812 string (TOUPPER "${_config}" _upperConfig)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
813 get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
814 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
815 list (APPEND _compileDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
816 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
817 get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_upperConfig})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
818 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
819 list (APPEND _compileDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
820 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
821 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
822 cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+(=.*)?$" _definitions ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
823 if (_definitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
824 list (APPEND _compileDefinitions ${_definitions})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
825 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
826 if (COTIRE_DEBUG AND _compileDefinitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
827 message (STATUS "Source ${_sourceFile} compile definitions: ${_compileDefinitions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
828 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
829 set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
830 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
831
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
832 function (cotire_get_source_files_compile_definitions _config _language _definitionsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
833 set (_configDefinitions "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
834 foreach (_sourceFile ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
835 cotire_get_source_compile_definitions("${_config}" "${_language}" "${_sourceFile}" _sourceDefinitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
836 if (_sourceDefinitions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
837 list (APPEND _configDefinitions "${_sourceFile}" ${_sourceDefinitions} "-")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
838 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
839 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
840 set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
841 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
842
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
843 function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
844 set (_sourceUndefs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
845 if (NOT CMAKE_SCRIPT_MODE_FILE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
846 get_source_file_property(_undefs "${_sourceFile}" ${_property})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
847 if (_undefs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
848 list (APPEND _sourceUndefs ${_undefs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
849 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
850 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
851 cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+$" _undefs ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
852 if (_undefs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
853 list (APPEND _sourceUndefs ${_undefs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
854 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
855 if (COTIRE_DEBUG AND _sourceUndefs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
856 message (STATUS "Source ${_sourceFile} ${_property} undefs: ${_sourceUndefs}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
857 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
858 set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
859 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
860
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
861 function (cotire_get_source_files_undefs _property _sourceUndefsVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
862 set (_sourceUndefs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
863 foreach (_sourceFile ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
864 cotire_get_source_undefs("${_sourceFile}" ${_property} _undefs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
865 if (_undefs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
866 list (APPEND _sourceUndefs "${_sourceFile}" ${_undefs} "-")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
867 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
868 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
869 set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
870 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
871
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
872 macro (cotire_set_cmd_to_prologue _cmdVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
873 set (${_cmdVar} "${CMAKE_COMMAND}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
874 if (COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
875 list (APPEND ${_cmdVar} "--warn-uninitialized")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
876 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
877 list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
878 if (XCODE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
879 list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
880 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
881 if (COTIRE_VERBOSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
882 list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
883 elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
884 list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=$(VERBOSE)")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
885 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
886 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
887
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
888 function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerExe _compilerArg1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
889 if (NOT _compilerLauncher)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
890 set (_compilerLauncher ${CMAKE_${_language}_COMPILER_LAUNCHER})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
891 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
892 if (NOT _compilerExe)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
893 set (_compilerExe "${CMAKE_${_language}_COMPILER}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
894 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
895 if (NOT _compilerArg1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
896 set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
897 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
898 if (WIN32)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
899 file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
900 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
901 string (STRIP "${_compilerArg1}" _compilerArg1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
902 if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
903 # compiler launcher is only supported for Makefile and Ninja
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
904 set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
905 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
906 set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
907 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
908 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
909
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
910 macro (cotire_add_definitions_to_cmd _cmdVar _language)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
911 foreach (_definition ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
912 if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
913 list (APPEND ${_cmdVar} "/D${_definition}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
914 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
915 list (APPEND ${_cmdVar} "-D${_definition}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
916 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
917 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
918 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
919
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
920 function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
921 set (_includeDirs ${${_includesVar}} ${${_systemIncludesVar}})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
922 if (_includeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
923 list (REMOVE_DUPLICATES _includeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
924 foreach (_include ${_includeDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
925 if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
926 file (TO_NATIVE_PATH "${_include}" _include)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
927 list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
928 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
929 set (_index -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
930 if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
931 list (FIND ${_systemIncludesVar} "${_include}" _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
932 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
933 if (_index GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
934 list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
935 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
936 list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
937 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
938 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
939 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
940 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
941 set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
942 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
943
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
944 function (cotire_add_frameworks_to_cmd _cmdVar _language _includesVar _systemIncludesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
945 if (APPLE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
946 set (_frameworkDirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
947 foreach (_include ${${_includesVar}})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
948 if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
949 get_filename_component(_frameworkDir "${_include}" DIRECTORY)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
950 list (APPEND _frameworkDirs "${_frameworkDir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
951 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
952 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
953 set (_systemFrameworkDirs "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
954 foreach (_include ${${_systemIncludesVar}})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
955 if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
956 get_filename_component(_frameworkDir "${_include}" DIRECTORY)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
957 list (APPEND _systemFrameworkDirs "${_frameworkDir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
958 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
959 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
960 if (_systemFrameworkDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
961 list (APPEND _frameworkDirs ${_systemFrameworkDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
962 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
963 if (_frameworkDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
964 list (REMOVE_DUPLICATES _frameworkDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
965 foreach (_frameworkDir ${_frameworkDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
966 set (_index -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
967 if ("${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}" MATCHES ".+")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
968 list (FIND _systemFrameworkDirs "${_frameworkDir}" _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
969 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
970 if (_index GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
971 list (APPEND ${_cmdVar} "${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
972 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
973 list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
974 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
975 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
976 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
977 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
978 set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
979 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
980
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
981 macro (cotire_add_compile_flags_to_cmd _cmdVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
982 foreach (_flag ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
983 list (APPEND ${_cmdVar} "${_flag}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
984 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
985 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
986
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
987 function (cotire_check_file_up_to_date _fileIsUpToDateVar _file)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
988 if (EXISTS "${_file}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
989 set (_triggerFile "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
990 foreach (_dependencyFile ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
991 if (EXISTS "${_dependencyFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
992 # IS_NEWER_THAN returns TRUE if both files have the same timestamp
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
993 # thus we do the comparison in both directions to exclude ties
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
994 if ("${_dependencyFile}" IS_NEWER_THAN "${_file}" AND
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
995 NOT "${_file}" IS_NEWER_THAN "${_dependencyFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
996 set (_triggerFile "${_dependencyFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
997 break()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
998 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
999 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1000 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1001 if (_triggerFile)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1002 if (COTIRE_VERBOSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1003 get_filename_component(_fileName "${_file}" NAME)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1004 message (STATUS "${_fileName} update triggered by ${_triggerFile} change.")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1005 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1006 set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1007 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1008 if (COTIRE_VERBOSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1009 get_filename_component(_fileName "${_file}" NAME)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1010 message (STATUS "${_fileName} is up-to-date.")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1011 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1012 set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1013 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1014 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1015 if (COTIRE_VERBOSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1016 get_filename_component(_fileName "${_file}" NAME)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1017 message (STATUS "${_fileName} does not exist yet.")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1018 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1019 set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1020 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1021 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1022
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1023 macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1024 set (${_relPathVar} "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1025 foreach (_includeDir ${_includeDirs})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1026 if (IS_DIRECTORY "${_includeDir}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1027 file (RELATIVE_PATH _relPath "${_includeDir}" "${_headerFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1028 if (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1029 string (LENGTH "${${_relPathVar}}" _closestLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1030 string (LENGTH "${_relPath}" _relLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1031 if (_closestLen EQUAL 0 OR _relLen LESS _closestLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1032 set (${_relPathVar} "${_relPath}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1033 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1034 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1035 elseif ("${_includeDir}" STREQUAL "${_headerFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1036 # if path matches exactly, return short non-empty string
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1037 set (${_relPathVar} "1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1038 break()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1039 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1040 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1041 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1042
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1043 macro (cotire_check_header_file_location _headerFile _insideIncludeDirs _outsideIncludeDirs _headerIsInside)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1044 # check header path against ignored and honored include directories
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1045 cotire_find_closest_relative_path("${_headerFile}" "${_insideIncludeDirs}" _insideRelPath)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1046 if (_insideRelPath)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1047 # header is inside, but could be become outside if there is a shorter outside match
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1048 cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncludeDirs}" _outsideRelPath)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1049 if (_outsideRelPath)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1050 string (LENGTH "${_insideRelPath}" _insideRelPathLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1051 string (LENGTH "${_outsideRelPath}" _outsideRelPathLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1052 if (_outsideRelPathLen LESS _insideRelPathLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1053 set (${_headerIsInside} FALSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1054 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1055 set (${_headerIsInside} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1056 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1057 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1058 set (${_headerIsInside} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1059 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1060 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1061 # header is outside
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1062 set (${_headerIsInside} FALSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1063 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1064 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1065
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1066 macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1067 if (NOT EXISTS "${_headerFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1068 set (${_headerIsIgnoredVar} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1069 elseif (IS_DIRECTORY "${_headerFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1070 set (${_headerIsIgnoredVar} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1071 elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed" AND "${_headerFile}" MATCHES "\\.h$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1072 # heuristic: ignore C headers with embedded parent directory references or "-fixed" or "_fixed" in path
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1073 # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1074 # with the error message "error: no include path in which to search for header.h"
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1075 set (${_headerIsIgnoredVar} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1076 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1077 set (${_headerIsIgnoredVar} FALSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1078 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1079 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1080
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1081 macro (cotire_check_ignore_header_file_ext _headerFile _ignoreExtensionsVar _headerIsIgnoredVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1082 # check header file extension
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1083 cotire_get_source_file_extension("${_headerFile}" _headerFileExt)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1084 set (${_headerIsIgnoredVar} FALSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1085 if (_headerFileExt)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1086 list (FIND ${_ignoreExtensionsVar} "${_headerFileExt}" _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1087 if (_index GREATER -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1088 set (${_headerIsIgnoredVar} TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1089 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1090 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1091 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1092
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1093 macro (cotire_parse_line _line _headerFileVar _headerDepthVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1094 if (MSVC)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1095 # cl.exe /showIncludes produces different output, depending on the language pack used, e.g.:
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1096 # English: "Note: including file: C:\directory\file"
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1097 # German: "Hinweis: Einlesen der Datei: C:\directory\file"
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1098 # We use a very general regular expression, relying on the presence of the : characters
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1099 if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1100 string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1101 get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1102 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1103 set (${_headerFileVar} "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1104 set (${_headerDepthVar} 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1105 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1106 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1107 if (_line MATCHES "^(\\.+) (.*)$")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1108 # GCC like output
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1109 string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1110 if (IS_ABSOLUTE "${CMAKE_MATCH_2}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1111 set (${_headerFileVar} "${CMAKE_MATCH_2}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1112 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1113 get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" REALPATH)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1114 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1115 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1116 set (${_headerFileVar} "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1117 set (${_headerDepthVar} 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1118 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1119 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1120 endmacro()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1121
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1122 function (cotire_parse_includes _language _scanOutput _ignoredIncludeDirs _honoredIncludeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1123 if (WIN32)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1124 # prevent CMake macro invocation errors due to backslash characters in Windows paths
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1125 string (REPLACE "\\" "/" _scanOutput "${_scanOutput}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1126 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1127 # canonize slashes
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1128 string (REPLACE "//" "/" _scanOutput "${_scanOutput}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1129 # prevent semicolon from being interpreted as a line separator
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1130 string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1131 # then separate lines
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1132 string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1133 list (LENGTH _scanOutput _len)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1134 # remove duplicate lines to speed up parsing
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1135 list (REMOVE_DUPLICATES _scanOutput)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1136 list (LENGTH _scanOutput _uniqueLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1137 if (COTIRE_VERBOSE OR COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1138 message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1139 if (_ignoredExtensions)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1140 message (STATUS "Ignored extensions: ${_ignoredExtensions}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1141 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1142 if (_ignoredIncludeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1143 message (STATUS "Ignored paths: ${_ignoredIncludeDirs}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1144 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1145 if (_honoredIncludeDirs)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1146 message (STATUS "Included paths: ${_honoredIncludeDirs}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1147 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1148 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1149 set (_sourceFiles ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1150 set (_selectedIncludes "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1151 set (_unparsedLines "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1152 # stack keeps track of inside/outside project status of processed header files
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1153 set (_headerIsInsideStack "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1154 foreach (_line IN LISTS _scanOutput)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1155 if (_line)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1156 cotire_parse_line("${_line}" _headerFile _headerDepth)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1157 if (_headerFile)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1158 cotire_check_header_file_location("${_headerFile}" "${_ignoredIncludeDirs}" "${_honoredIncludeDirs}" _headerIsInside)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1159 if (COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1160 message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1161 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1162 # update stack
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1163 list (LENGTH _headerIsInsideStack _stackLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1164 if (_headerDepth GREATER _stackLen)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1165 math (EXPR _stackLen "${_stackLen} + 1")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1166 foreach (_index RANGE ${_stackLen} ${_headerDepth})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1167 list (APPEND _headerIsInsideStack ${_headerIsInside})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1168 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1169 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1170 foreach (_index RANGE ${_headerDepth} ${_stackLen})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1171 list (REMOVE_AT _headerIsInsideStack -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1172 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1173 list (APPEND _headerIsInsideStack ${_headerIsInside})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1174 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1175 if (COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1176 message (STATUS "${_headerIsInsideStack}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1177 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1178 # header is a candidate if it is outside project
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1179 if (NOT _headerIsInside)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1180 # get parent header file's inside/outside status
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1181 if (_headerDepth GREATER 1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1182 math (EXPR _index "${_headerDepth} - 2")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1183 list (GET _headerIsInsideStack ${_index} _parentHeaderIsInside)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1184 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1185 set (_parentHeaderIsInside TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1186 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1187 # select header file if parent header file is inside project
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1188 # (e.g., a project header file that includes a standard header file)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1189 if (_parentHeaderIsInside)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1190 cotire_check_ignore_header_file_path("${_headerFile}" _headerIsIgnored)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1191 if (NOT _headerIsIgnored)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1192 cotire_check_ignore_header_file_ext("${_headerFile}" _ignoredExtensions _headerIsIgnored)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1193 if (NOT _headerIsIgnored)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1194 list (APPEND _selectedIncludes "${_headerFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1195 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1196 # fix header's inside status on stack, it is ignored by extension now
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1197 list (REMOVE_AT _headerIsInsideStack -1)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1198 list (APPEND _headerIsInsideStack TRUE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1199 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1200 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1201 if (COTIRE_DEBUG)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1202 message (STATUS "${_headerFile} ${_ignoredExtensions} ${_headerIsIgnored}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1203 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1204 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1205 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1206 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1207 if (MSVC)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1208 # for cl.exe do not keep unparsed lines which solely consist of a source file name
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1209 string (FIND "${_sourceFiles}" "${_line}" _index)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1210 if (_index LESS 0)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1211 list (APPEND _unparsedLines "${_line}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1212 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1213 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1214 list (APPEND _unparsedLines "${_line}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1215 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1216 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1217 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1218 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1219 list (REMOVE_DUPLICATES _selectedIncludes)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1220 set (${_selectedIncludesVar} ${_selectedIncludes} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1221 set (${_unparsedLinesVar} ${_unparsedLines} PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1222 endfunction()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1223
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1224 function (cotire_scan_includes _includesVar)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1225 set(_options "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1226 set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES SCAN_RESULT)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1227 set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1228 IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1229 cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1230 set (_sourceFiles ${_option_UNPARSED_ARGUMENTS})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1231 if (NOT _option_LANGUAGE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1232 set (_option_LANGUAGE "CXX")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1233 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1234 if (NOT _option_COMPILER_ID)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1235 set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1236 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1237 if (NOT _option_COMPILER_VERSION)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1238 set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1239 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1240 cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1241 cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1242 cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1243 cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1244 cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1245 cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1246 # only consider existing source files for scanning
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1247 set (_existingSourceFiles "")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1248 foreach (_sourceFile ${_sourceFiles})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1249 if (EXISTS "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1250 list (APPEND _existingSourceFiles "${_sourceFile}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1251 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1252 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1253 if (NOT _existingSourceFiles)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1254 set (${_includesVar} "" PARENT_SCOPE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1255 return()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1256 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1257 # add source files to be scanned
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1258 if (WIN32)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1259 foreach (_sourceFile ${_existingSourceFiles})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1260 file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1261 list (APPEND _cmd "${_sourceFileNative}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1262 endforeach()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1263 else()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1264 list (APPEND _cmd ${_existingSourceFiles})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1265 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1266 if (COTIRE_VERBOSE)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1267 message (STATUS "execute_process: ${_cmd}")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1268 endif()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1269 if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1270 # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1271 unset (ENV{VS_UNICODE_OUTPUT})
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1272