/src/CMake/Source/cmTarget.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #include "cmTarget.h" |
4 | | |
5 | | #include <algorithm> |
6 | | #include <cassert> |
7 | | #include <iterator> |
8 | | #include <map> |
9 | | #include <set> |
10 | | #include <sstream> |
11 | | #include <unordered_map> |
12 | | #include <unordered_set> |
13 | | |
14 | | #include <cm/memory> |
15 | | #include <cm/string_view> |
16 | | #include <cmext/algorithm> |
17 | | #include <cmext/string_view> |
18 | | |
19 | | #include "cmsys/RegularExpression.hxx" |
20 | | |
21 | | #include "cmAlgorithms.h" |
22 | | #include "cmCustomCommand.h" |
23 | | #include "cmFileSet.h" |
24 | | #include "cmFindPackageStack.h" |
25 | | #include "cmGeneratorExpression.h" |
26 | | #include "cmGlobalGenerator.h" |
27 | | #include "cmList.h" |
28 | | #include "cmListFileCache.h" |
29 | | #include "cmMakefile.h" |
30 | | #include "cmMessageType.h" |
31 | | #include "cmProperty.h" |
32 | | #include "cmPropertyDefinition.h" |
33 | | #include "cmPropertyMap.h" |
34 | | #include "cmRange.h" |
35 | | #include "cmSourceFile.h" |
36 | | #include "cmSourceFileLocation.h" |
37 | | #include "cmSourceFileLocationKind.h" |
38 | | #include "cmState.h" |
39 | | #include "cmStateDirectory.h" |
40 | | #include "cmStateSnapshot.h" |
41 | | #include "cmSystemTools.h" |
42 | | #include "cmTargetPropertyComputer.h" |
43 | | #include "cmValue.h" |
44 | | #include "cmXcFramework.h" |
45 | | #include "cmake.h" |
46 | | |
47 | | template <> |
48 | | std::string const& cmTargetPropertyComputer::ImportedLocation<cmTarget>( |
49 | | cmTarget const* tgt, std::string const& config) |
50 | 0 | { |
51 | 0 | static std::string loc; |
52 | 0 | assert(tgt->IsImported()); |
53 | 0 | loc = tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); |
54 | 0 | return loc; |
55 | 0 | } |
56 | | |
57 | | template <> |
58 | | cmValue cmTargetPropertyComputer::GetSources<cmTarget>(cmTarget const* tgt) |
59 | 0 | { |
60 | 0 | cmBTStringRange entries = tgt->GetSourceEntries(); |
61 | 0 | if (entries.empty()) { |
62 | 0 | return nullptr; |
63 | 0 | } |
64 | | |
65 | 0 | std::ostringstream ss; |
66 | 0 | char const* sep = ""; |
67 | 0 | for (auto const& entry : entries) { |
68 | 0 | cmList files{ entry.Value }; |
69 | 0 | for (std::string const& file : files) { |
70 | 0 | if ((cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") && |
71 | 0 | file.back() == '>') || |
72 | 0 | cmGeneratorExpression::Find(file) == std::string::npos) { |
73 | 0 | ss << sep; |
74 | 0 | sep = ";"; |
75 | 0 | ss << file; |
76 | 0 | } else { |
77 | 0 | cmSourceFile* sf = tgt->GetMakefile()->GetOrCreateSource(file); |
78 | | // Construct what is known about this source file location. |
79 | 0 | cmSourceFileLocation const& location = sf->GetLocation(); |
80 | 0 | std::string sname = location.GetDirectory(); |
81 | 0 | if (!sname.empty()) { |
82 | 0 | sname += "/"; |
83 | 0 | } |
84 | 0 | sname += location.GetName(); |
85 | |
|
86 | 0 | ss << sep; |
87 | 0 | sep = ";"; |
88 | | // Append this list entry. |
89 | 0 | ss << sname; |
90 | 0 | } |
91 | 0 | } |
92 | 0 | } |
93 | 0 | static std::string srcs; |
94 | 0 | srcs = ss.str(); |
95 | 0 | return cmValue(srcs); |
96 | 0 | } |
97 | | |
98 | | namespace { |
99 | | struct FileSetEntries |
100 | | { |
101 | | FileSetEntries(cm::static_string_view propertyName) |
102 | 0 | : PropertyName(propertyName) |
103 | 0 | { |
104 | 0 | } |
105 | | |
106 | | cm::static_string_view const PropertyName; |
107 | | std::vector<BT<std::string>> Entries; |
108 | | }; |
109 | | |
110 | | struct FileSetType |
111 | | { |
112 | | FileSetType(cm::static_string_view typeName, |
113 | | cm::static_string_view defaultDirectoryProperty, |
114 | | cm::static_string_view defaultPathProperty, |
115 | | cm::static_string_view directoryPrefix, |
116 | | cm::static_string_view pathPrefix, |
117 | | cm::static_string_view typeDescription, |
118 | | cm::static_string_view defaultDescription, |
119 | | cm::static_string_view arbitraryDescription, |
120 | | FileSetEntries selfEntries, FileSetEntries interfaceEntries) |
121 | 0 | : TypeName(typeName) |
122 | 0 | , DefaultDirectoryProperty(defaultDirectoryProperty) |
123 | 0 | , DefaultPathProperty(defaultPathProperty) |
124 | 0 | , DirectoryPrefix(directoryPrefix) |
125 | 0 | , PathPrefix(pathPrefix) |
126 | 0 | , TypeDescription(typeDescription) |
127 | 0 | , DefaultDescription(defaultDescription) |
128 | 0 | , ArbitraryDescription(arbitraryDescription) |
129 | 0 | , SelfEntries(std::move(selfEntries)) |
130 | 0 | , InterfaceEntries(std::move(interfaceEntries)) |
131 | 0 | { |
132 | 0 | } |
133 | | |
134 | | cm::static_string_view const TypeName; |
135 | | cm::static_string_view const DefaultDirectoryProperty; |
136 | | cm::static_string_view const DefaultPathProperty; |
137 | | cm::static_string_view const DirectoryPrefix; |
138 | | cm::static_string_view const PathPrefix; |
139 | | cm::static_string_view const TypeDescription; |
140 | | cm::static_string_view const DefaultDescription; |
141 | | cm::static_string_view const ArbitraryDescription; |
142 | | |
143 | | FileSetEntries SelfEntries; |
144 | | FileSetEntries InterfaceEntries; |
145 | | |
146 | | enum class Action |
147 | | { |
148 | | Set, |
149 | | Append, |
150 | | }; |
151 | | |
152 | | template <typename ValueType> |
153 | | bool WriteProperties(cmTarget* tgt, cmTargetInternals* impl, |
154 | | std::string const& prop, ValueType value, |
155 | | Action action); |
156 | | std::pair<bool, cmValue> ReadProperties(cmTarget const* tgt, |
157 | | cmTargetInternals const* impl, |
158 | | std::string const& prop) const; |
159 | | |
160 | | void AddFileSet(std::string const& name, cmFileSetVisibility vis, |
161 | | cmListFileBacktrace bt); |
162 | | }; |
163 | | |
164 | | struct UsageRequirementProperty |
165 | | { |
166 | | enum class AppendEmpty |
167 | | { |
168 | | Yes, |
169 | | No, |
170 | | }; |
171 | | |
172 | | UsageRequirementProperty(cm::static_string_view name, |
173 | | AppendEmpty appendEmpty = AppendEmpty::No) |
174 | 0 | : Name(name) |
175 | 0 | , AppendBehavior(appendEmpty) |
176 | 0 | { |
177 | 0 | } |
178 | | |
179 | | void CopyFromEntries(cmBTStringRange entries) |
180 | 0 | { |
181 | 0 | cm::append(this->Entries, entries); |
182 | 0 | } |
183 | | |
184 | | enum class Action |
185 | | { |
186 | | Set, |
187 | | Prepend, |
188 | | Append, |
189 | | }; |
190 | | |
191 | | template <typename ValueType> |
192 | | bool Write(cmTargetInternals const* impl, |
193 | | cm::optional<cmListFileBacktrace> const& bt, |
194 | | std::string const& prop, ValueType value, Action action); |
195 | | template <typename ValueType> |
196 | | void WriteDirect(cmTargetInternals const* impl, |
197 | | cm::optional<cmListFileBacktrace> const& bt, |
198 | | ValueType value, Action action); |
199 | | void WriteDirect(BT<std::string> value, Action action); |
200 | | std::pair<bool, cmValue> Read(std::string const& prop) const; |
201 | | |
202 | | cm::static_string_view const Name; |
203 | | AppendEmpty const AppendBehavior; |
204 | | |
205 | | std::vector<BT<std::string>> Entries; |
206 | | }; |
207 | | |
208 | | struct TargetProperty |
209 | | { |
210 | | enum class InitCondition |
211 | | { |
212 | | // Always initialize the property. |
213 | | Always, |
214 | | // Never initialize the property. |
215 | | Never, |
216 | | // Only initialize if the target can compile sources. |
217 | | CanCompileSources, |
218 | | // Only apply to Xcode generators. |
219 | | NeedsXcode, |
220 | | // Only apply to Xcode generators on targets that can compile sources. |
221 | | NeedsXcodeAndCanCompileSources, |
222 | | // Needs to be a "normal" target (any non-global, non-utility target). |
223 | | NormalTarget, |
224 | | // Any non-imported target. |
225 | | NonImportedTarget, |
226 | | // Needs to be a "normal" target (any non-global, non-utility target) that |
227 | | // is not `IMPORTED`. |
228 | | NormalNonImportedTarget, |
229 | | // Needs to be a "normal" target with an artifact (no `INTERFACE` |
230 | | // libraries). |
231 | | TargetWithArtifact, |
232 | | // Needs to be a "normal" target with an artifact that is not an |
233 | | // executable. |
234 | | NonExecutableWithArtifact, |
235 | | // Needs to be a linkable library target (no `OBJECT` or `MODULE` |
236 | | // libraries). |
237 | | LinkableLibraryTarget, |
238 | | // Needs to be an executable. |
239 | | ExecutableTarget, |
240 | | // Needs to be a shared library (`SHARED`). |
241 | | SharedLibraryTarget, |
242 | | // Needs to be a target with meaningful symbol exports (`SHARED` or |
243 | | // `EXECUTABLE`). |
244 | | TargetWithSymbolExports, |
245 | | // Targets with "commands" associated with them. Basically everything |
246 | | // except global and `INTERFACE` targets. |
247 | | TargetWithCommands, |
248 | | }; |
249 | | |
250 | | enum class Repetition |
251 | | { |
252 | | Once, |
253 | | PerConfig, |
254 | | PerConfigPrefix, |
255 | | }; |
256 | | |
257 | | TargetProperty(cm::static_string_view name) |
258 | 12 | : Name(name) |
259 | 12 | { |
260 | 12 | } |
261 | | |
262 | | TargetProperty(cm::static_string_view name, cm::static_string_view dflt, |
263 | | InitCondition init) |
264 | 36 | : Name(name) |
265 | 36 | , Default(dflt) |
266 | 36 | , InitConditional(init) |
267 | 36 | { |
268 | 36 | } |
269 | | |
270 | | TargetProperty(cm::static_string_view name, InitCondition init) |
271 | 724 | : Name(name) |
272 | 724 | , InitConditional(init) |
273 | 724 | { |
274 | 724 | } |
275 | | |
276 | | TargetProperty(cm::static_string_view name, InitCondition init, |
277 | | Repetition repeat) |
278 | 36 | : Name(name) |
279 | 36 | , InitConditional(init) |
280 | 36 | , Repeat(repeat) |
281 | 36 | { |
282 | 36 | } |
283 | | |
284 | | cm::static_string_view const Name; |
285 | | // Explicit initialization is needed for AppleClang in Xcode 8 and below |
286 | | // NOLINTNEXTLINE(readability-redundant-member-init) |
287 | | cm::optional<cm::static_string_view> const Default = {}; |
288 | | InitCondition const InitConditional = InitCondition::Always; |
289 | | Repetition const Repeat = Repetition::Once; |
290 | | }; |
291 | | |
292 | | #define IC TargetProperty::InitCondition |
293 | | #define R TargetProperty::Repetition |
294 | | |
295 | | /* clang-format off */ |
296 | | #define COMMON_LANGUAGE_PROPERTIES(lang) \ |
297 | | { #lang "_COMPILER_LAUNCHER"_s, IC::CanCompileSources }, \ |
298 | | { #lang "_STANDARD"_s, IC::CanCompileSources }, \ |
299 | | { #lang "_STANDARD_REQUIRED"_s, IC::CanCompileSources }, \ |
300 | | { #lang "_EXTENSIONS"_s, IC::CanCompileSources }, \ |
301 | | { #lang "_VISIBILITY_PRESET"_s, IC::CanCompileSources } |
302 | | /* clang-format on */ |
303 | | |
304 | | TargetProperty const StaticTargetProperties[] = { |
305 | | /* clang-format off */ |
306 | | // -- Debugger Properties |
307 | | { "DEBUGGER_WORKING_DIRECTORY"_s, IC::ExecutableTarget }, |
308 | | // Compilation properties |
309 | | { "COMPILE_WARNING_AS_ERROR"_s, IC::CanCompileSources }, |
310 | | { "INTERPROCEDURAL_OPTIMIZATION"_s, IC::CanCompileSources }, |
311 | | { "INTERPROCEDURAL_OPTIMIZATION_"_s, IC::TargetWithArtifact, R::PerConfig }, |
312 | | { "NO_SYSTEM_FROM_IMPORTED"_s, IC::CanCompileSources }, |
313 | | // Set to `True` for `SHARED` and `MODULE` targets. |
314 | | { "POSITION_INDEPENDENT_CODE"_s, IC::CanCompileSources }, |
315 | | { "VISIBILITY_INLINES_HIDDEN"_s, IC::CanCompileSources }, |
316 | | // -- Features |
317 | | // ---- PCH |
318 | | { "DISABLE_PRECOMPILE_HEADERS"_s, IC::CanCompileSources }, |
319 | | { "PCH_WARN_INVALID"_s, "ON"_s, IC::CanCompileSources }, |
320 | | { "PCH_INSTANTIATE_TEMPLATES"_s, "ON"_s, IC::CanCompileSources }, |
321 | | // -- Platforms |
322 | | // ---- Android |
323 | | { "ANDROID_API"_s, IC::CanCompileSources }, |
324 | | { "ANDROID_API_MIN"_s, IC::CanCompileSources }, |
325 | | { "ANDROID_ARCH"_s, IC::CanCompileSources }, |
326 | | { "ANDROID_ASSETS_DIRECTORIES"_s, IC::CanCompileSources }, |
327 | | { "ANDROID_JAVA_SOURCE_DIR"_s, IC::CanCompileSources }, |
328 | | { "ANDROID_STL_TYPE"_s, IC::CanCompileSources }, |
329 | | // ---- macOS |
330 | | { "OSX_ARCHITECTURES"_s, IC::CanCompileSources }, |
331 | | // ---- Windows |
332 | | { "MSVC_DEBUG_INFORMATION_FORMAT"_s, IC::CanCompileSources }, |
333 | | { "MSVC_RUNTIME_CHECKS"_s, IC::CanCompileSources }, |
334 | | { "MSVC_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, |
335 | | { "VS_JUST_MY_CODE_DEBUGGING"_s, IC::CanCompileSources }, |
336 | | { "VS_DEBUGGER_COMMAND"_s, IC::ExecutableTarget }, |
337 | | { "VS_DEBUGGER_COMMAND_ARGUMENTS"_s, IC::ExecutableTarget }, |
338 | | { "VS_DEBUGGER_ENVIRONMENT"_s, IC::ExecutableTarget }, |
339 | | { "VS_DEBUGGER_WORKING_DIRECTORY"_s, IC::ExecutableTarget }, |
340 | | { "VS_USE_DEBUG_LIBRARIES"_s, IC::NonImportedTarget }, |
341 | | // ---- OpenWatcom |
342 | | { "WATCOM_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, |
343 | | // ---- AIX |
344 | | { "AIX_SHARED_LIBRARY_ARCHIVE"_s, IC::SharedLibraryTarget }, |
345 | | // -- Language |
346 | | // ---- C |
347 | | COMMON_LANGUAGE_PROPERTIES(C), |
348 | | // ---- C++ |
349 | | COMMON_LANGUAGE_PROPERTIES(CXX), |
350 | | { "CXX_MODULE_STD"_s, IC::CanCompileSources }, |
351 | | // ---- CSharp |
352 | | { "DOTNET_SDK"_s, IC::NonImportedTarget }, |
353 | | { "DOTNET_TARGET_FRAMEWORK"_s, IC::TargetWithCommands }, |
354 | | { "DOTNET_TARGET_FRAMEWORK_VERSION"_s, IC::TargetWithCommands }, |
355 | | // ---- CUDA |
356 | | COMMON_LANGUAGE_PROPERTIES(CUDA), |
357 | | { "CUDA_SEPARABLE_COMPILATION"_s, IC::CanCompileSources }, |
358 | | { "CUDA_ARCHITECTURES"_s, IC::CanCompileSources }, |
359 | | // ---- Fortran |
360 | | { "Fortran_FORMAT"_s, IC::CanCompileSources }, |
361 | | { "Fortran_MODULE_DIRECTORY"_s, IC::CanCompileSources }, |
362 | | { "Fortran_COMPILER_LAUNCHER"_s, IC::CanCompileSources }, |
363 | | { "Fortran_PREPROCESS"_s, IC::CanCompileSources }, |
364 | | { "Fortran_VISIBILITY_PRESET"_s, IC::CanCompileSources }, |
365 | | // ---- HIP |
366 | | COMMON_LANGUAGE_PROPERTIES(HIP), |
367 | | { "HIP_ARCHITECTURES"_s, IC::CanCompileSources }, |
368 | | // ---- ISPC |
369 | | { "ISPC_COMPILER_LAUNCHER"_s, IC::CanCompileSources }, |
370 | | { "ISPC_HEADER_DIRECTORY"_s, IC::CanCompileSources }, |
371 | | { "ISPC_HEADER_SUFFIX"_s, "_ispc.h"_s, IC::CanCompileSources }, |
372 | | { "ISPC_INSTRUCTION_SETS"_s, IC::CanCompileSources }, |
373 | | // ---- Objective C |
374 | | COMMON_LANGUAGE_PROPERTIES(OBJC), |
375 | | // ---- Objective C++ |
376 | | COMMON_LANGUAGE_PROPERTIES(OBJCXX), |
377 | | // ---- Swift |
378 | | { "Swift_LANGUAGE_VERSION"_s, IC::CanCompileSources }, |
379 | | { "Swift_MODULE_DIRECTORY"_s, IC::CanCompileSources }, |
380 | | { "Swift_COMPILATION_MODE"_s, IC::CanCompileSources }, |
381 | | // ---- moc |
382 | | { "AUTOMOC"_s, IC::CanCompileSources }, |
383 | | { "AUTOMOC_COMPILER_PREDEFINES"_s, IC::CanCompileSources }, |
384 | | { "AUTOMOC_INCLUDE_DIRECTORIES"_s, IC::CanCompileSources }, |
385 | | { "AUTOMOC_MACRO_NAMES"_s, IC::CanCompileSources }, |
386 | | { "AUTOMOC_MOC_OPTIONS"_s, IC::CanCompileSources }, |
387 | | { "AUTOMOC_PATH_PREFIX"_s, IC::CanCompileSources }, |
388 | | { "AUTOMOC_EXECUTABLE"_s, IC::CanCompileSources }, |
389 | | // ---- uic |
390 | | { "AUTOUIC"_s, IC::CanCompileSources }, |
391 | | { "AUTOUIC_OPTIONS"_s, IC::CanCompileSources }, |
392 | | { "AUTOUIC_SEARCH_PATHS"_s, IC::CanCompileSources }, |
393 | | { "AUTOUIC_EXECUTABLE"_s, IC::CanCompileSources }, |
394 | | // ---- rcc |
395 | | { "AUTORCC"_s, IC::CanCompileSources }, |
396 | | { "AUTORCC_OPTIONS"_s, IC::CanCompileSources }, |
397 | | { "AUTORCC_EXECUTABLE"_s, IC::CanCompileSources }, |
398 | | |
399 | | // Linking properties |
400 | | { "LINKER_TYPE"_s, IC::CanCompileSources }, |
401 | | { "LINK_WARNING_AS_ERROR"_s, IC::CanCompileSources }, |
402 | | { "ENABLE_EXPORTS"_s, IC::TargetWithSymbolExports }, |
403 | | { "LINK_LIBRARIES_ONLY_TARGETS"_s, IC::NormalNonImportedTarget }, |
404 | | { "LINK_LIBRARIES_STRATEGY"_s, IC::NormalNonImportedTarget }, |
405 | | { "LINK_SEARCH_START_STATIC"_s, IC::CanCompileSources }, |
406 | | { "LINK_SEARCH_END_STATIC"_s, IC::CanCompileSources }, |
407 | | // Initialize per-configuration name postfix property from the variable only |
408 | | // for non-executable targets. This preserves compatibility with previous |
409 | | // CMake versions in which executables did not support this variable. |
410 | | // Projects may still specify the property directly. |
411 | | { "_POSTFIX"_s, IC::NonExecutableWithArtifact, R::PerConfigPrefix }, |
412 | | // -- Dependent library lookup |
413 | | { "MACOSX_RPATH"_s, IC::CanCompileSources }, |
414 | | // ---- Build |
415 | | { "BUILD_RPATH"_s, IC::CanCompileSources }, |
416 | | { "BUILD_RPATH_USE_ORIGIN"_s, IC::CanCompileSources }, |
417 | | { "SKIP_BUILD_RPATH"_s, "OFF"_s, IC::CanCompileSources }, |
418 | | { "BUILD_WITH_INSTALL_RPATH"_s, "OFF"_s, IC::CanCompileSources }, |
419 | | { "BUILD_WITH_INSTALL_NAME_DIR"_s, IC::CanCompileSources }, |
420 | | // ---- Install |
421 | | { "INSTALL_NAME_DIR"_s, IC::CanCompileSources }, |
422 | | { "INSTALL_OBJECT_NAME_STRATEGY"_s, IC::CanCompileSources }, |
423 | | { "INSTALL_OBJECT_ONLY_USE_DESTINATION"_s, IC::CanCompileSources }, |
424 | | { "INSTALL_REMOVE_ENVIRONMENT_RPATH"_s, IC::CanCompileSources }, |
425 | | { "INSTALL_RPATH"_s, ""_s, IC::CanCompileSources }, |
426 | | { "INSTALL_RPATH_USE_LINK_PATH"_s, "OFF"_s, IC::CanCompileSources }, |
427 | | // -- Platforms |
428 | | // ---- AIX |
429 | | { "AIX_EXPORT_ALL_SYMBOLS"_s, IC::TargetWithSymbolExports }, |
430 | | // ---- Android |
431 | | { "ANDROID_GUI"_s, IC::ExecutableTarget }, |
432 | | { "ANDROID_JAR_DIRECTORIES"_s, IC::CanCompileSources }, |
433 | | { "ANDROID_JAR_DEPENDENCIES"_s, IC::CanCompileSources }, |
434 | | { "ANDROID_NATIVE_LIB_DIRECTORIES"_s, IC::CanCompileSources }, |
435 | | { "ANDROID_NATIVE_LIB_DEPENDENCIES"_s, IC::CanCompileSources }, |
436 | | { "ANDROID_PROGUARD"_s, IC::CanCompileSources }, |
437 | | { "ANDROID_PROGUARD_CONFIG_PATH"_s, IC::CanCompileSources }, |
438 | | { "ANDROID_SECURE_PROPS_PATH"_s, IC::CanCompileSources }, |
439 | | // ---- iOS |
440 | | { "IOS_INSTALL_COMBINED"_s, IC::CanCompileSources }, |
441 | | // ---- macOS |
442 | | { "FRAMEWORK_MULTI_CONFIG_POSTFIX_"_s, IC::LinkableLibraryTarget, R::PerConfig }, |
443 | | // ---- Windows |
444 | | { "DLL_NAME_WITH_SOVERSION"_s, IC::SharedLibraryTarget }, |
445 | | { "GNUtoMS"_s, IC::CanCompileSources }, |
446 | | { "WIN32_EXECUTABLE"_s, IC::CanCompileSources }, |
447 | | { "WINDOWS_EXPORT_ALL_SYMBOLS"_s, IC::TargetWithSymbolExports }, |
448 | | // -- Languages |
449 | | // ---- C |
450 | | { "C_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
451 | | // ---- C++ |
452 | | { "CXX_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
453 | | // ---- CUDA |
454 | | { "CUDA_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
455 | | { "CUDA_RESOLVE_DEVICE_SYMBOLS"_s, IC::CanCompileSources }, |
456 | | { "CUDA_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, |
457 | | // ---- HIP |
458 | | { "HIP_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
459 | | { "HIP_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, |
460 | | // ---- Objective C |
461 | | { "OBJC_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
462 | | // ---- Objective C++ |
463 | | { "OBJCXX_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
464 | | // ---- Fortran |
465 | | { "Fortran_LINKER_LAUNCHER"_s, IC::CanCompileSources }, |
466 | | |
467 | | // Static analysis |
468 | | { "SKIP_LINTING"_s, IC::CanCompileSources }, |
469 | | // -- C |
470 | | { "C_CLANG_TIDY"_s, IC::CanCompileSources }, |
471 | | { "C_CLANG_TIDY_EXPORT_FIXES_DIR"_s, IC::CanCompileSources }, |
472 | | { "C_CPPLINT"_s, IC::CanCompileSources }, |
473 | | { "C_CPPCHECK"_s, IC::CanCompileSources }, |
474 | | { "C_ICSTAT"_s, IC::CanCompileSources }, |
475 | | { "C_INCLUDE_WHAT_YOU_USE"_s, IC::CanCompileSources }, |
476 | | { "C_PVS_STUDIO"_s, IC::CanCompileSources }, |
477 | | // -- C++ |
478 | | { "CXX_CLANG_TIDY"_s, IC::CanCompileSources }, |
479 | | { "CXX_CLANG_TIDY_EXPORT_FIXES_DIR"_s, IC::CanCompileSources }, |
480 | | { "CXX_CPPLINT"_s, IC::CanCompileSources }, |
481 | | { "CXX_CPPCHECK"_s, IC::CanCompileSources }, |
482 | | { "CXX_ICSTAT"_s, IC::CanCompileSources }, |
483 | | { "CXX_INCLUDE_WHAT_YOU_USE"_s, IC::CanCompileSources }, |
484 | | { "CXX_PVS_STUDIO"_s, IC::CanCompileSources }, |
485 | | // -- Objective C |
486 | | { "OBJC_CLANG_TIDY"_s, IC::CanCompileSources }, |
487 | | { "OBJC_CLANG_TIDY_EXPORT_FIXES_DIR"_s, IC::CanCompileSources }, |
488 | | // -- Objective C++ |
489 | | { "OBJCXX_CLANG_TIDY"_s, IC::CanCompileSources }, |
490 | | { "OBJCXX_CLANG_TIDY_EXPORT_FIXES_DIR"_s, IC::CanCompileSources }, |
491 | | // -- Linking |
492 | | { "LINK_WHAT_YOU_USE"_s, IC::CanCompileSources }, |
493 | | |
494 | | // Build graph properties |
495 | | { "LINK_DEPENDS_NO_SHARED"_s, IC::CanCompileSources }, |
496 | | { "UNITY_BUILD"_s, IC::CanCompileSources }, |
497 | | { "UNITY_BUILD_UNIQUE_ID"_s, IC::CanCompileSources }, |
498 | | { "UNITY_BUILD_BATCH_SIZE"_s, "8"_s, IC::CanCompileSources }, |
499 | | { "UNITY_BUILD_MODE"_s, "BATCH"_s, IC::CanCompileSources }, |
500 | | { "UNITY_BUILD_RELOCATABLE"_s, IC::CanCompileSources }, |
501 | | { "OPTIMIZE_DEPENDENCIES"_s, IC::CanCompileSources }, |
502 | | { "VERIFY_INTERFACE_HEADER_SETS"_s }, |
503 | | { "VERIFY_PRIVATE_HEADER_SETS"_s }, |
504 | | // -- Android |
505 | | { "ANDROID_ANT_ADDITIONAL_OPTIONS"_s, IC::CanCompileSources }, |
506 | | { "ANDROID_PROCESS_MAX"_s, IC::CanCompileSources }, |
507 | | { "ANDROID_SKIP_ANT_STEP"_s, IC::CanCompileSources }, |
508 | | // -- Autogen |
509 | | { "AUTOGEN_COMMAND_LINE_LENGTH_MAX"_s, IC::CanCompileSources }, |
510 | | { "AUTOGEN_ORIGIN_DEPENDS"_s, IC::CanCompileSources }, |
511 | | { "AUTOGEN_PARALLEL"_s, IC::CanCompileSources }, |
512 | | { "AUTOGEN_USE_SYSTEM_INCLUDE"_s, IC::CanCompileSources }, |
513 | | { "AUTOGEN_BETTER_GRAPH_MULTI_CONFIG"_s, IC::CanCompileSources }, |
514 | | // -- moc |
515 | | { "AUTOMOC_DEPEND_FILTERS"_s, IC::CanCompileSources }, |
516 | | // -- C++ |
517 | | { "CXX_SCAN_FOR_MODULES"_s, IC::CanCompileSources }, |
518 | | // -- Ninja |
519 | | { "JOB_POOL_COMPILE"_s, IC::CanCompileSources }, |
520 | | { "JOB_POOL_LINK"_s, IC::CanCompileSources }, |
521 | | { "JOB_POOL_PRECOMPILE_HEADER"_s, IC::CanCompileSources }, |
522 | | // -- Visual Studio |
523 | | { "VS_NO_COMPILE_BATCHING"_s, IC::CanCompileSources }, |
524 | | { "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"_s, IC::CanCompileSources}, |
525 | | |
526 | | // Output location properties |
527 | | { "ARCHIVE_OUTPUT_DIRECTORY"_s, IC::CanCompileSources }, |
528 | | { "ARCHIVE_OUTPUT_DIRECTORY_"_s, IC::TargetWithArtifact, R::PerConfig }, |
529 | | { "COMPILE_PDB_OUTPUT_DIRECTORY"_s, IC::CanCompileSources }, |
530 | | { "COMPILE_PDB_OUTPUT_DIRECTORY_"_s, IC::TargetWithArtifact, R::PerConfig }, |
531 | | { "LIBRARY_OUTPUT_DIRECTORY"_s, IC::CanCompileSources }, |
532 | | { "LIBRARY_OUTPUT_DIRECTORY_"_s, IC::TargetWithArtifact, R::PerConfig }, |
533 | | { "PDB_OUTPUT_DIRECTORY"_s, IC::CanCompileSources }, |
534 | | { "PDB_OUTPUT_DIRECTORY_"_s, IC::TargetWithArtifact, R::PerConfig }, |
535 | | { "RUNTIME_OUTPUT_DIRECTORY"_s, IC::CanCompileSources }, |
536 | | { "RUNTIME_OUTPUT_DIRECTORY_"_s, IC::TargetWithArtifact, R::PerConfig }, |
537 | | |
538 | | // macOS bundle properties |
539 | | { "FRAMEWORK"_s, IC::CanCompileSources }, |
540 | | { "FRAMEWORK_MULTI_CONFIG_POSTFIX"_s, IC::CanCompileSources }, |
541 | | { "MACOSX_BUNDLE"_s, IC::CanCompileSources }, |
542 | | |
543 | | // Usage requirement properties |
544 | | { "LINK_INTERFACE_LIBRARIES"_s, IC::CanCompileSources }, |
545 | | { "MAP_IMPORTED_CONFIG_"_s, IC::NormalTarget, R::PerConfig }, |
546 | | { "EXPORT_FIND_PACKAGE_NAME"_s, IC::NormalTarget }, |
547 | | |
548 | | // Metadata |
549 | | { "CROSSCOMPILING_EMULATOR"_s, IC::ExecutableTarget }, |
550 | | { "EXPORT_BUILD_DATABASE"_s, IC::CanCompileSources }, |
551 | | { "EXPORT_COMPILE_COMMANDS"_s, IC::CanCompileSources }, |
552 | | { "FOLDER"_s }, |
553 | | { "TEST_LAUNCHER"_s, IC::ExecutableTarget }, |
554 | | |
555 | | // Xcode properties |
556 | | { "XCODE_GENERATE_SCHEME"_s, IC::NeedsXcode }, |
557 | | |
558 | | #ifdef __APPLE__ |
559 | | { "XCODE_SCHEME_ADDRESS_SANITIZER"_s, IC::NeedsXcodeAndCanCompileSources }, |
560 | | { "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN"_s, IC::NeedsXcodeAndCanCompileSources }, |
561 | | { "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING"_s, IC::NeedsXcodeAndCanCompileSources }, |
562 | | { "XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE"_s, IC::NeedsXcodeAndCanCompileSources }, |
563 | | { "XCODE_SCHEME_THREAD_SANITIZER"_s, IC::NeedsXcodeAndCanCompileSources }, |
564 | | { "XCODE_SCHEME_THREAD_SANITIZER_STOP"_s, IC::NeedsXcodeAndCanCompileSources }, |
565 | | { "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER"_s, IC::NeedsXcodeAndCanCompileSources }, |
566 | | { "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP"_s, IC::NeedsXcodeAndCanCompileSources }, |
567 | | { "XCODE_SCHEME_LAUNCH_CONFIGURATION"_s, IC::NeedsXcodeAndCanCompileSources }, |
568 | | { "XCODE_SCHEME_TEST_CONFIGURATION"_s, IC::NeedsXcodeAndCanCompileSources }, |
569 | | { "XCODE_SCHEME_ENABLE_GPU_API_VALIDATION"_s, IC::NeedsXcodeAndCanCompileSources }, |
570 | | { "XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION"_s, IC::NeedsXcodeAndCanCompileSources }, |
571 | | { "XCODE_SCHEME_WORKING_DIRECTORY"_s, IC::NeedsXcodeAndCanCompileSources }, |
572 | | { "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER"_s, IC::NeedsXcodeAndCanCompileSources }, |
573 | | { "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP"_s, IC::NeedsXcodeAndCanCompileSources }, |
574 | | { "XCODE_SCHEME_MALLOC_SCRIBBLE"_s, IC::NeedsXcodeAndCanCompileSources }, |
575 | | { "XCODE_SCHEME_MALLOC_GUARD_EDGES"_s, IC::NeedsXcodeAndCanCompileSources }, |
576 | | { "XCODE_SCHEME_GUARD_MALLOC"_s, IC::NeedsXcodeAndCanCompileSources }, |
577 | | { "XCODE_SCHEME_LAUNCH_MODE"_s, IC::NeedsXcodeAndCanCompileSources }, |
578 | | { "XCODE_SCHEME_LLDB_INIT_FILE"_s, IC::NeedsXcodeAndCanCompileSources }, |
579 | | { "XCODE_SCHEME_ZOMBIE_OBJECTS"_s, IC::NeedsXcodeAndCanCompileSources }, |
580 | | { "XCODE_SCHEME_MALLOC_STACK"_s, IC::NeedsXcodeAndCanCompileSources }, |
581 | | { "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE"_s, IC::NeedsXcodeAndCanCompileSources }, |
582 | | { "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS"_s, IC::NeedsXcodeAndCanCompileSources }, |
583 | | { "XCODE_SCHEME_ENVIRONMENT"_s, IC::NeedsXcodeAndCanCompileSources }, |
584 | | { "XCODE_LINK_BUILD_PHASE_MODE"_s, "NONE"_s, IC::NeedsXcodeAndCanCompileSources }, |
585 | | #endif |
586 | | /* clang-format on */ |
587 | | }; |
588 | | |
589 | | #undef COMMON_LANGUAGE_PROPERTIES |
590 | | #undef IC |
591 | | #undef R |
592 | | } |
593 | | |
594 | | class cmTargetInternals |
595 | | { |
596 | | public: |
597 | | cmStateEnums::TargetType TargetType; |
598 | | cmTarget::Origin Origin = cmTarget::Origin::Unknown; |
599 | | cmMakefile* Makefile; |
600 | | cmPolicies::PolicyMap PolicyMap; |
601 | | cmTarget const* TemplateTarget; |
602 | | std::string Name; |
603 | | std::string InstallPath; |
604 | | std::string RuntimeInstallPath; |
605 | | cmPropertyMap Properties; |
606 | | bool IsGeneratorProvided; |
607 | | bool HaveInstallRule; |
608 | | bool IsDLLPlatform; |
609 | | bool IsAIX; |
610 | | bool IsApple; |
611 | | bool IsAndroid; |
612 | | bool BuildInterfaceIncludesAppended; |
613 | | bool PerConfig; |
614 | | bool IsSymbolic; |
615 | | bool IsForTryCompile{ false }; |
616 | | cmTarget::Visibility TargetVisibility; |
617 | | std::set<BT<std::pair<std::string, bool>>> Utilities; |
618 | | std::set<std::string> CodegenDependencies; |
619 | | std::vector<cmCustomCommand> PreBuildCommands; |
620 | | std::vector<cmCustomCommand> PreLinkCommands; |
621 | | std::vector<cmCustomCommand> PostBuildCommands; |
622 | | std::vector<cmInstallTargetGenerator*> InstallGenerators; |
623 | | std::set<std::string> SystemIncludeDirectories; |
624 | | cmTarget::LinkLibraryVectorType OriginalLinkLibraries; |
625 | | std::map<std::string, BTs<std::string>> LanguageStandardProperties; |
626 | | std::map<cmTargetExport const*, std::vector<std::string>> |
627 | | InstallIncludeDirectoriesEntries; |
628 | | std::vector<std::pair<cmTarget::TLLSignature, cmListFileContext>> |
629 | | TLLCommands; |
630 | | std::map<std::string, cmFileSet> FileSets; |
631 | | cmListFileBacktrace Backtrace; |
632 | | cmFindPackageStack FindPackageStack; |
633 | | |
634 | | UsageRequirementProperty IncludeDirectories; |
635 | | UsageRequirementProperty CompileOptions; |
636 | | UsageRequirementProperty CompileFeatures; |
637 | | UsageRequirementProperty CompileDefinitions; |
638 | | UsageRequirementProperty PrecompileHeaders; |
639 | | UsageRequirementProperty Sources; |
640 | | UsageRequirementProperty LinkOptions; |
641 | | UsageRequirementProperty LinkDirectories; |
642 | | UsageRequirementProperty LinkLibraries; |
643 | | UsageRequirementProperty InterfaceLinkLibraries; |
644 | | UsageRequirementProperty InterfaceLinkLibrariesDirect; |
645 | | UsageRequirementProperty InterfaceLinkLibrariesDirectExclude; |
646 | | UsageRequirementProperty ImportedCxxModulesIncludeDirectories; |
647 | | UsageRequirementProperty ImportedCxxModulesCompileDefinitions; |
648 | | UsageRequirementProperty ImportedCxxModulesCompileFeatures; |
649 | | UsageRequirementProperty ImportedCxxModulesCompileOptions; |
650 | | UsageRequirementProperty ImportedCxxModulesLinkLibraries; |
651 | | |
652 | | FileSetType HeadersFileSets; |
653 | | FileSetType CxxModulesFileSets; |
654 | | |
655 | | cmTargetInternals(); |
656 | | |
657 | | bool IsImported() const; |
658 | | |
659 | | bool CheckImportedLibName(std::string const& prop, |
660 | | std::string const& value) const; |
661 | | |
662 | | template <typename ValueType> |
663 | | void AddDirectoryToFileSet(cmTarget* self, std::string const& fileSetName, |
664 | | ValueType value, cm::string_view fileSetType, |
665 | | cm::string_view description, |
666 | | FileSetType::Action action); |
667 | | template <typename ValueType> |
668 | | void AddPathToFileSet(cmTarget* self, std::string const& fileSetName, |
669 | | ValueType value, cm::string_view fileSetType, |
670 | | cm::string_view description, |
671 | | FileSetType::Action action); |
672 | | cmValue GetFileSetDirectories(cmTarget const* self, |
673 | | std::string const& fileSetName, |
674 | | cm::string_view fileSetType) const; |
675 | | cmValue GetFileSetPaths(cmTarget const* self, std::string const& fileSetName, |
676 | | cm::string_view fileSetType) const; |
677 | | |
678 | | cmListFileBacktrace GetBacktrace( |
679 | | cm::optional<cmListFileBacktrace> const& bt) const |
680 | 0 | { |
681 | 0 | return bt ? *bt : this->Makefile->GetBacktrace(); |
682 | 0 | } |
683 | | }; |
684 | | |
685 | | cmTargetInternals::cmTargetInternals() |
686 | 0 | : IncludeDirectories("INCLUDE_DIRECTORIES"_s) |
687 | 0 | , CompileOptions("COMPILE_OPTIONS"_s) |
688 | 0 | , CompileFeatures("COMPILE_FEATURES"_s) |
689 | 0 | , CompileDefinitions("COMPILE_DEFINITIONS"_s) |
690 | 0 | , PrecompileHeaders("PRECOMPILE_HEADERS"_s) |
691 | 0 | , Sources("SOURCES"_s, UsageRequirementProperty::AppendEmpty::Yes) |
692 | 0 | , LinkOptions("LINK_OPTIONS"_s) |
693 | 0 | , LinkDirectories("LINK_DIRECTORIES"_s) |
694 | 0 | , LinkLibraries("LINK_LIBRARIES"_s) |
695 | 0 | , InterfaceLinkLibraries("INTERFACE_LINK_LIBRARIES"_s) |
696 | 0 | , InterfaceLinkLibrariesDirect("INTERFACE_LINK_LIBRARIES_DIRECT"_s) |
697 | 0 | , InterfaceLinkLibrariesDirectExclude( |
698 | 0 | "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s) |
699 | 0 | , ImportedCxxModulesIncludeDirectories( |
700 | 0 | "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES"_s) |
701 | 0 | , ImportedCxxModulesCompileDefinitions( |
702 | 0 | "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS"_s) |
703 | 0 | , ImportedCxxModulesCompileFeatures( |
704 | 0 | "IMPORTED_CXX_MODULES_COMPILE_FEATURES"_s) |
705 | 0 | , ImportedCxxModulesCompileOptions("IMPORTED_CXX_MODULES_COMPILE_OPTIONS"_s) |
706 | 0 | , ImportedCxxModulesLinkLibraries("IMPORTED_CXX_MODULES_LINK_LIBRARIES"_s) |
707 | 0 | , HeadersFileSets("HEADERS"_s, "HEADER_DIRS"_s, "HEADER_SET"_s, |
708 | 0 | "HEADER_DIRS_"_s, "HEADER_SET_"_s, "Header"_s, |
709 | 0 | "The default header set"_s, "Header set"_s, |
710 | 0 | FileSetEntries("HEADER_SETS"_s), |
711 | 0 | FileSetEntries("INTERFACE_HEADER_SETS"_s)) |
712 | 0 | , CxxModulesFileSets("CXX_MODULES"_s, "CXX_MODULE_DIRS"_s, |
713 | 0 | "CXX_MODULE_SET"_s, "CXX_MODULE_DIRS_"_s, |
714 | 0 | "CXX_MODULE_SET_"_s, "C++ module"_s, |
715 | 0 | "The default C++ module set"_s, "C++ module set"_s, |
716 | 0 | FileSetEntries("CXX_MODULE_SETS"_s), |
717 | 0 | FileSetEntries("INTERFACE_CXX_MODULE_SETS"_s)) |
718 | 0 | { |
719 | 0 | } |
720 | | |
721 | | template <typename ValueType> |
722 | | bool FileSetType::WriteProperties(cmTarget* tgt, cmTargetInternals* impl, |
723 | | std::string const& prop, ValueType value, |
724 | | Action action) |
725 | 0 | { |
726 | 0 | if (prop == this->DefaultDirectoryProperty) { |
727 | 0 | impl->AddDirectoryToFileSet(tgt, std::string(this->TypeName), value, |
728 | 0 | this->TypeName, this->DefaultDescription, |
729 | 0 | action); |
730 | 0 | return true; |
731 | 0 | } |
732 | 0 | if (prop == this->DefaultPathProperty) { |
733 | 0 | impl->AddPathToFileSet(tgt, std::string(this->TypeName), value, |
734 | 0 | this->TypeName, this->DefaultDescription, action); |
735 | 0 | return true; |
736 | 0 | } |
737 | 0 | if (cmHasPrefix(prop, this->DirectoryPrefix)) { |
738 | 0 | auto fileSetName = prop.substr(this->DirectoryPrefix.size()); |
739 | 0 | if (fileSetName.empty()) { |
740 | 0 | impl->Makefile->IssueMessage( |
741 | 0 | MessageType::FATAL_ERROR, |
742 | 0 | cmStrCat(this->ArbitraryDescription, " name cannot be empty.")); |
743 | 0 | } else { |
744 | 0 | impl->AddDirectoryToFileSet( |
745 | 0 | tgt, fileSetName, value, this->TypeName, |
746 | 0 | cmStrCat(this->ArbitraryDescription, " \"", fileSetName, '"'), action); |
747 | 0 | } |
748 | 0 | return true; |
749 | 0 | } |
750 | 0 | if (cmHasPrefix(prop, this->PathPrefix)) { |
751 | 0 | auto fileSetName = prop.substr(this->PathPrefix.size()); |
752 | 0 | if (fileSetName.empty()) { |
753 | 0 | impl->Makefile->IssueMessage( |
754 | 0 | MessageType::FATAL_ERROR, |
755 | 0 | cmStrCat(this->ArbitraryDescription, " name cannot be empty.")); |
756 | 0 | } else { |
757 | 0 | impl->AddPathToFileSet( |
758 | 0 | tgt, fileSetName, value, this->TypeName, |
759 | 0 | cmStrCat(this->ArbitraryDescription, " \"", fileSetName, '"'), action); |
760 | 0 | } |
761 | 0 | return true; |
762 | 0 | } |
763 | 0 | return false; |
764 | 0 | } Unexecuted instantiation: cmTarget.cxx:bool (anonymous namespace)::FileSetType::WriteProperties<cmValue>(cmTarget*, cmTargetInternals*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmValue, (anonymous namespace)::FileSetType::Action) Unexecuted instantiation: cmTarget.cxx:bool (anonymous namespace)::FileSetType::WriteProperties<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(cmTarget*, cmTargetInternals*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::FileSetType::Action) |
765 | | |
766 | | std::pair<bool, cmValue> FileSetType::ReadProperties( |
767 | | cmTarget const* tgt, cmTargetInternals const* impl, |
768 | | std::string const& prop) const |
769 | 0 | { |
770 | 0 | bool did_read = false; |
771 | 0 | cmValue value = nullptr; |
772 | 0 | if (prop == this->DefaultDirectoryProperty) { |
773 | 0 | value = impl->GetFileSetDirectories(tgt, std::string(this->TypeName), |
774 | 0 | this->TypeName); |
775 | 0 | did_read = true; |
776 | 0 | } else if (prop == this->DefaultPathProperty) { |
777 | 0 | value = |
778 | 0 | impl->GetFileSetPaths(tgt, std::string(this->TypeName), this->TypeName); |
779 | 0 | did_read = true; |
780 | 0 | } else if (prop == this->SelfEntries.PropertyName) { |
781 | 0 | static std::string output; |
782 | 0 | output = cmList::to_string(this->SelfEntries.Entries); |
783 | 0 | value = cmValue(output); |
784 | 0 | did_read = true; |
785 | 0 | } else if (prop == this->InterfaceEntries.PropertyName) { |
786 | 0 | static std::string output; |
787 | 0 | output = cmList::to_string(this->InterfaceEntries.Entries); |
788 | 0 | value = cmValue(output); |
789 | 0 | did_read = true; |
790 | 0 | } else if (cmHasPrefix(prop, this->DirectoryPrefix)) { |
791 | 0 | std::string fileSetName = prop.substr(this->DirectoryPrefix.size()); |
792 | 0 | if (!fileSetName.empty()) { |
793 | 0 | value = impl->GetFileSetDirectories(tgt, fileSetName, this->TypeName); |
794 | 0 | } |
795 | 0 | did_read = true; |
796 | 0 | } else if (cmHasPrefix(prop, this->PathPrefix)) { |
797 | 0 | std::string fileSetName = prop.substr(this->PathPrefix.size()); |
798 | 0 | if (!fileSetName.empty()) { |
799 | 0 | value = impl->GetFileSetPaths(tgt, fileSetName, this->TypeName); |
800 | 0 | } |
801 | 0 | did_read = true; |
802 | 0 | } |
803 | 0 | return { did_read, value }; |
804 | 0 | } |
805 | | |
806 | | void FileSetType::AddFileSet(std::string const& name, cmFileSetVisibility vis, |
807 | | cmListFileBacktrace bt) |
808 | 0 | { |
809 | 0 | if (cmFileSetVisibilityIsForSelf(vis)) { |
810 | 0 | this->SelfEntries.Entries.emplace_back(name, bt); |
811 | 0 | } |
812 | 0 | if (cmFileSetVisibilityIsForInterface(vis)) { |
813 | 0 | this->InterfaceEntries.Entries.emplace_back(name, std::move(bt)); |
814 | 0 | } |
815 | 0 | } |
816 | | |
817 | | template <typename ValueType> |
818 | | bool UsageRequirementProperty::Write( |
819 | | cmTargetInternals const* impl, cm::optional<cmListFileBacktrace> const& bt, |
820 | | std::string const& prop, ValueType value, Action action) |
821 | 0 | { |
822 | 0 | if (prop == this->Name) { |
823 | 0 | this->WriteDirect(impl, bt, value, action); |
824 | 0 | return true; |
825 | 0 | } |
826 | 0 | return false; |
827 | 0 | } |
828 | | |
829 | | template <typename ValueType> |
830 | | void UsageRequirementProperty::WriteDirect( |
831 | | cmTargetInternals const* impl, cm::optional<cmListFileBacktrace> const& bt, |
832 | | ValueType value, Action action) |
833 | 0 | { |
834 | 0 | if (action == Action::Set) { |
835 | 0 | this->Entries.clear(); |
836 | 0 | } |
837 | 0 | if (value) { |
838 | 0 | cmListFileBacktrace lfbt = impl->GetBacktrace(bt); |
839 | 0 | if (action == Action::Prepend) { |
840 | 0 | this->Entries.emplace(this->Entries.begin(), value, lfbt); |
841 | 0 | } else if (action == Action::Set || cmNonempty(value) || |
842 | 0 | this->AppendBehavior == AppendEmpty::Yes) { |
843 | 0 | this->Entries.emplace_back(value, lfbt); |
844 | 0 | } |
845 | 0 | } |
846 | 0 | } |
847 | | |
848 | | void UsageRequirementProperty::WriteDirect(BT<std::string> value, |
849 | | Action action) |
850 | 0 | { |
851 | 0 | if (action == Action::Set) { |
852 | 0 | this->Entries.clear(); |
853 | 0 | } |
854 | 0 | if (action == Action::Prepend) { |
855 | 0 | this->Entries.emplace(this->Entries.begin(), std::move(value)); |
856 | 0 | } else { |
857 | 0 | this->Entries.emplace_back(std::move(value)); |
858 | 0 | } |
859 | 0 | } |
860 | | |
861 | | std::pair<bool, cmValue> UsageRequirementProperty::Read( |
862 | | std::string const& prop) const |
863 | 0 | { |
864 | 0 | bool did_read = false; |
865 | 0 | cmValue value = nullptr; |
866 | 0 | if (prop == this->Name) { |
867 | 0 | if (!this->Entries.empty()) { |
868 | | // Storage to back the returned `cmValue`. |
869 | 0 | static std::string output; |
870 | 0 | output = cmList::to_string(this->Entries); |
871 | 0 | value = cmValue(output); |
872 | 0 | } |
873 | 0 | did_read = true; |
874 | 0 | } |
875 | 0 | return { did_read, value }; |
876 | 0 | } |
877 | | |
878 | | cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, |
879 | | Visibility vis, cmMakefile* mf, PerConfig perConfig) |
880 | 0 | : impl(cm::make_unique<cmTargetInternals>()) |
881 | 0 | { |
882 | 0 | assert(mf); |
883 | 0 | this->impl->TargetType = type; |
884 | 0 | this->impl->Makefile = mf; |
885 | 0 | this->impl->Name = name; |
886 | 0 | this->impl->TemplateTarget = nullptr; |
887 | 0 | this->impl->IsGeneratorProvided = false; |
888 | 0 | this->impl->HaveInstallRule = false; |
889 | 0 | this->impl->IsDLLPlatform = false; |
890 | 0 | this->impl->IsAIX = false; |
891 | 0 | this->impl->IsApple = false; |
892 | 0 | this->impl->IsAndroid = false; |
893 | 0 | this->impl->IsSymbolic = false; |
894 | 0 | this->impl->TargetVisibility = vis; |
895 | 0 | this->impl->BuildInterfaceIncludesAppended = false; |
896 | 0 | this->impl->PerConfig = (perConfig == PerConfig::Yes); |
897 | | |
898 | | // Check whether this is a DLL platform. |
899 | 0 | this->impl->IsDLLPlatform = |
900 | 0 | !this->impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX") |
901 | 0 | .empty(); |
902 | | |
903 | | // Check whether we are targeting AIX. |
904 | 0 | { |
905 | 0 | std::string const& systemName = |
906 | 0 | this->impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"); |
907 | 0 | this->impl->IsAIX = (systemName == "AIX" || systemName == "OS400"); |
908 | 0 | } |
909 | | |
910 | | // Check whether we are targeting Apple. |
911 | 0 | this->impl->IsApple = this->impl->Makefile->IsOn("APPLE"); |
912 | | |
913 | | // Check whether we are targeting an Android platform. |
914 | 0 | this->impl->IsAndroid = (this->impl->Makefile->GetSafeDefinition( |
915 | 0 | "CMAKE_SYSTEM_NAME") == "Android"); |
916 | | |
917 | | // Save the backtrace of target construction. |
918 | 0 | this->impl->Backtrace = this->impl->Makefile->GetBacktrace(); |
919 | 0 | if (this->impl->IsImported()) { |
920 | 0 | this->impl->FindPackageStack = this->impl->Makefile->GetFindPackageStack(); |
921 | 0 | } |
922 | |
|
923 | 0 | if (this->IsNormal()) { |
924 | | // Initialize the INCLUDE_DIRECTORIES property based on the current value |
925 | | // of the same directory property: |
926 | 0 | this->impl->IncludeDirectories.CopyFromEntries( |
927 | 0 | this->impl->Makefile->GetIncludeDirectoriesEntries()); |
928 | |
|
929 | 0 | { |
930 | 0 | auto const& sysInc = this->impl->Makefile->GetSystemIncludeDirectories(); |
931 | 0 | this->impl->SystemIncludeDirectories.insert(sysInc.begin(), |
932 | 0 | sysInc.end()); |
933 | 0 | } |
934 | |
|
935 | 0 | this->impl->CompileOptions.CopyFromEntries( |
936 | 0 | this->impl->Makefile->GetCompileOptionsEntries()); |
937 | 0 | this->impl->LinkOptions.CopyFromEntries( |
938 | 0 | this->impl->Makefile->GetLinkOptionsEntries()); |
939 | 0 | this->impl->LinkDirectories.CopyFromEntries( |
940 | 0 | this->impl->Makefile->GetLinkDirectoriesEntries()); |
941 | 0 | } |
942 | | |
943 | | // Record current policies for later use. |
944 | 0 | this->impl->Makefile->RecordPolicies(this->impl->PolicyMap); |
945 | |
|
946 | 0 | std::set<TargetProperty::InitCondition> metConditions; |
947 | 0 | metConditions.insert(TargetProperty::InitCondition::Always); |
948 | 0 | if (this->CanCompileSources()) { |
949 | 0 | metConditions.insert(TargetProperty::InitCondition::CanCompileSources); |
950 | 0 | } |
951 | 0 | if (this->GetGlobalGenerator()->IsXcode()) { |
952 | 0 | metConditions.insert(TargetProperty::InitCondition::NeedsXcode); |
953 | 0 | if (this->CanCompileSources()) { |
954 | 0 | metConditions.insert( |
955 | 0 | TargetProperty::InitCondition::NeedsXcodeAndCanCompileSources); |
956 | 0 | } |
957 | 0 | } |
958 | 0 | if (!this->IsImported()) { |
959 | 0 | metConditions.insert(TargetProperty::InitCondition::NonImportedTarget); |
960 | 0 | } |
961 | 0 | if (this->impl->TargetType != cmStateEnums::UTILITY && |
962 | 0 | this->impl->TargetType != cmStateEnums::GLOBAL_TARGET) { |
963 | 0 | metConditions.insert(TargetProperty::InitCondition::NormalTarget); |
964 | 0 | if (this->IsNormal()) { |
965 | 0 | metConditions.insert( |
966 | 0 | TargetProperty::InitCondition::NormalNonImportedTarget); |
967 | 0 | } |
968 | 0 | if (this->impl->TargetType != cmStateEnums::INTERFACE_LIBRARY) { |
969 | 0 | metConditions.insert(TargetProperty::InitCondition::TargetWithArtifact); |
970 | 0 | if (this->impl->TargetType != cmStateEnums::EXECUTABLE) { |
971 | 0 | metConditions.insert( |
972 | 0 | TargetProperty::InitCondition::NonExecutableWithArtifact); |
973 | 0 | } |
974 | 0 | } |
975 | 0 | if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY || |
976 | 0 | this->impl->TargetType == cmStateEnums::STATIC_LIBRARY) { |
977 | 0 | metConditions.insert( |
978 | 0 | TargetProperty::InitCondition::LinkableLibraryTarget); |
979 | 0 | } |
980 | 0 | if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY) { |
981 | 0 | metConditions.insert(TargetProperty::InitCondition::SharedLibraryTarget); |
982 | 0 | } |
983 | 0 | } |
984 | 0 | if (this->impl->TargetType == cmStateEnums::EXECUTABLE) { |
985 | 0 | metConditions.insert(TargetProperty::InitCondition::ExecutableTarget); |
986 | 0 | } |
987 | 0 | if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY || |
988 | 0 | this->impl->TargetType == cmStateEnums::EXECUTABLE) { |
989 | 0 | metConditions.insert( |
990 | 0 | TargetProperty::InitCondition::TargetWithSymbolExports); |
991 | 0 | } |
992 | 0 | if (this->impl->TargetType <= cmStateEnums::GLOBAL_TARGET) { |
993 | 0 | metConditions.insert(TargetProperty::InitCondition::TargetWithCommands); |
994 | 0 | } |
995 | |
|
996 | 0 | std::vector<std::string> configNames = |
997 | 0 | mf->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); |
998 | 0 | for (auto& config : configNames) { |
999 | 0 | config = cmSystemTools::UpperCase(config); |
1000 | 0 | } |
1001 | |
|
1002 | 0 | std::string defKey; |
1003 | 0 | defKey.reserve(128); |
1004 | 0 | defKey += "CMAKE_"; |
1005 | 0 | auto initProperty = [this, mf, &defKey](std::string const& property, |
1006 | 0 | char const* default_value) { |
1007 | | // special init for ENABLE_EXPORTS |
1008 | | // For SHARED_LIBRARY, only CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS variable |
1009 | | // is used |
1010 | | // For EXECUTABLE, CMAKE_EXECUTABLE_ENABLE_EXPORTS or else |
1011 | | // CMAKE_ENABLE_EXPORTS variables are used |
1012 | 0 | if (property == "ENABLE_EXPORTS"_s) { |
1013 | | // Replace everything after "CMAKE_" |
1014 | 0 | defKey.replace( |
1015 | 0 | defKey.begin() + 6, defKey.end(), |
1016 | 0 | cmStrCat(this->impl->TargetType == cmStateEnums::EXECUTABLE |
1017 | 0 | ? "EXECUTABLE" |
1018 | 0 | : "SHARED_LIBRARY", |
1019 | 0 | '_', property)); |
1020 | 0 | if (cmValue value = mf->GetDefinition(defKey)) { |
1021 | 0 | this->SetProperty(property, value); |
1022 | 0 | return; |
1023 | 0 | } |
1024 | 0 | if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY) { |
1025 | 0 | if (default_value) { |
1026 | 0 | this->SetProperty(property, default_value); |
1027 | 0 | } |
1028 | 0 | return; |
1029 | 0 | } |
1030 | 0 | } |
1031 | | |
1032 | | // Imported targets must set AIX_SHARED_LIBRARY_ARCHIVE explicitly. |
1033 | 0 | if (this->IsImported() && property == "AIX_SHARED_LIBRARY_ARCHIVE"_s) { |
1034 | 0 | return; |
1035 | 0 | } |
1036 | | |
1037 | | // Replace everything after "CMAKE_" |
1038 | 0 | defKey.replace(defKey.begin() + 6, defKey.end(), property); |
1039 | 0 | if (cmValue value = mf->GetDefinition(defKey)) { |
1040 | 0 | this->SetProperty(property, value); |
1041 | 0 | } else if (default_value) { |
1042 | 0 | this->SetProperty(property, default_value); |
1043 | 0 | } |
1044 | 0 | }; |
1045 | |
|
1046 | 0 | std::string dflt_storage; |
1047 | 0 | for (auto const& tp : StaticTargetProperties) { |
1048 | | // Ignore properties that we have not met the condition for. |
1049 | 0 | if (!metConditions.count(tp.InitConditional)) { |
1050 | 0 | continue; |
1051 | 0 | } |
1052 | | |
1053 | 0 | char const* dflt = nullptr; |
1054 | 0 | if (tp.Default) { |
1055 | 0 | dflt_storage = std::string(*tp.Default); |
1056 | 0 | dflt = dflt_storage.c_str(); |
1057 | 0 | } |
1058 | |
|
1059 | 0 | if (tp.Repeat == TargetProperty::Repetition::Once) { |
1060 | 0 | initProperty(std::string(tp.Name), dflt); |
1061 | 0 | } else { |
1062 | 0 | std::string propertyName; |
1063 | 0 | for (auto const& configName : configNames) { |
1064 | 0 | if (tp.Repeat == TargetProperty::Repetition::PerConfig) { |
1065 | 0 | propertyName = cmStrCat(tp.Name, configName); |
1066 | 0 | } else if (tp.Repeat == TargetProperty::Repetition::PerConfigPrefix) { |
1067 | 0 | propertyName = cmStrCat(configName, tp.Name); |
1068 | 0 | } |
1069 | 0 | initProperty(propertyName, dflt); |
1070 | 0 | } |
1071 | 0 | } |
1072 | 0 | } |
1073 | | |
1074 | | // Clean up some property defaults. |
1075 | 0 | if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY || |
1076 | 0 | this->impl->TargetType == cmStateEnums::MODULE_LIBRARY) { |
1077 | 0 | this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); |
1078 | 0 | } |
1079 | | |
1080 | | // check for "CMAKE_VS_GLOBALS" variable and set up target properties |
1081 | | // if any |
1082 | 0 | cmValue globals = mf->GetDefinition("CMAKE_VS_GLOBALS"); |
1083 | 0 | if (globals) { |
1084 | 0 | std::string const genName = mf->GetGlobalGenerator()->GetName(); |
1085 | 0 | if (cmHasLiteralPrefix(genName, "Visual Studio")) { |
1086 | 0 | cmList props{ *globals }; |
1087 | 0 | std::string const vsGlobal = "VS_GLOBAL_"; |
1088 | 0 | for (std::string const& i : props) { |
1089 | | // split NAME=VALUE |
1090 | 0 | std::string::size_type const assignment = i.find('='); |
1091 | 0 | if (assignment != std::string::npos) { |
1092 | 0 | std::string const propName = vsGlobal + i.substr(0, assignment); |
1093 | 0 | std::string const propValue = i.substr(assignment + 1); |
1094 | 0 | initProperty(propName, propValue.c_str()); |
1095 | 0 | } |
1096 | 0 | } |
1097 | 0 | } |
1098 | 0 | } |
1099 | |
|
1100 | 0 | if (!this->IsNormal() || mf->GetPropertyAsBool("SYSTEM")) { |
1101 | 0 | this->SetProperty("SYSTEM", "ON"); |
1102 | 0 | } |
1103 | |
|
1104 | 0 | for (auto const& prop : mf->GetState()->GetPropertyDefinitions().GetMap()) { |
1105 | 0 | auto iter = prop.second.find(cmProperty::TARGET); |
1106 | 0 | if (iter != prop.second.end()) { |
1107 | 0 | if (!iter->second.GetInitializeFromVariable().empty()) { |
1108 | 0 | if (auto value = |
1109 | 0 | mf->GetDefinition(iter->second.GetInitializeFromVariable())) { |
1110 | 0 | this->SetProperty(prop.first, value); |
1111 | 0 | } |
1112 | 0 | } |
1113 | 0 | } |
1114 | 0 | } |
1115 | 0 | } |
1116 | | |
1117 | 0 | cmTarget::cmTarget(cmTarget&&) noexcept = default; |
1118 | 0 | cmTarget::~cmTarget() = default; |
1119 | | |
1120 | 0 | cmTarget& cmTarget::operator=(cmTarget&&) noexcept = default; |
1121 | | |
1122 | | cmStateEnums::TargetType cmTarget::GetType() const |
1123 | 0 | { |
1124 | 0 | return this->impl->TargetType; |
1125 | 0 | } |
1126 | | |
1127 | | void cmTarget::SetOrigin(Origin origin) |
1128 | 0 | { |
1129 | 0 | assert(origin != cmTarget::Origin::Unknown); |
1130 | 0 | assert(this->impl->Origin == cmTarget::Origin::Unknown); |
1131 | 0 | this->impl->Origin = origin; |
1132 | 0 | } |
1133 | | |
1134 | | cmTarget::Origin cmTarget::GetOrigin() const |
1135 | 0 | { |
1136 | 0 | return this->impl->Origin; |
1137 | 0 | } |
1138 | | |
1139 | | cmMakefile* cmTarget::GetMakefile() const |
1140 | 0 | { |
1141 | 0 | return this->impl->Makefile; |
1142 | 0 | } |
1143 | | |
1144 | | cmPolicies::PolicyMap const& cmTarget::GetPolicyMap() const |
1145 | 0 | { |
1146 | 0 | return this->impl->PolicyMap; |
1147 | 0 | } |
1148 | | |
1149 | | std::string const& cmTarget::GetName() const |
1150 | 0 | { |
1151 | 0 | return this->impl->Name; |
1152 | 0 | } |
1153 | | |
1154 | | std::string const& cmTarget::GetTemplateName() const |
1155 | 0 | { |
1156 | 0 | if (this->impl->TemplateTarget) { |
1157 | 0 | return this->impl->TemplateTarget->GetTemplateName(); |
1158 | 0 | } |
1159 | 0 | return this->impl->Name; |
1160 | 0 | } |
1161 | | |
1162 | | cmPolicies::PolicyStatus cmTarget::GetPolicyStatus( |
1163 | | cmPolicies::PolicyID policy) const |
1164 | 0 | { |
1165 | 0 | return this->impl->PolicyMap.Get(policy); |
1166 | 0 | } |
1167 | | |
1168 | | cmGlobalGenerator* cmTarget::GetGlobalGenerator() const |
1169 | 0 | { |
1170 | 0 | return this->impl->Makefile->GetGlobalGenerator(); |
1171 | 0 | } |
1172 | | |
1173 | | BTs<std::string> const* cmTarget::GetLanguageStandardProperty( |
1174 | | std::string const& propertyName) const |
1175 | 0 | { |
1176 | 0 | auto entry = this->impl->LanguageStandardProperties.find(propertyName); |
1177 | 0 | if (entry != this->impl->LanguageStandardProperties.end()) { |
1178 | 0 | return &entry->second; |
1179 | 0 | } |
1180 | | |
1181 | 0 | return nullptr; |
1182 | 0 | } |
1183 | | |
1184 | | void cmTarget::SetLanguageStandardProperty(std::string const& lang, |
1185 | | std::string const& value, |
1186 | | std::string const& feature) |
1187 | 0 | { |
1188 | 0 | cmListFileBacktrace featureBacktrace; |
1189 | 0 | for (auto const& entry : this->impl->CompileFeatures.Entries) { |
1190 | 0 | if (entry.Value == feature) { |
1191 | 0 | featureBacktrace = entry.Backtrace; |
1192 | 0 | break; |
1193 | 0 | } |
1194 | 0 | } |
1195 | |
|
1196 | 0 | BTs<std::string>& languageStandardProperty = |
1197 | 0 | this->impl->LanguageStandardProperties[cmStrCat(lang, "_STANDARD")]; |
1198 | 0 | if (languageStandardProperty.Value != value) { |
1199 | 0 | languageStandardProperty.Value = value; |
1200 | 0 | languageStandardProperty.Backtraces.clear(); |
1201 | 0 | } |
1202 | 0 | languageStandardProperty.Backtraces.emplace_back(featureBacktrace); |
1203 | 0 | } |
1204 | | |
1205 | | void cmTarget::AddUtility(std::string const& name, bool cross, |
1206 | | cmMakefile const* mf) |
1207 | 0 | { |
1208 | 0 | this->impl->Utilities.insert(BT<std::pair<std::string, bool>>( |
1209 | 0 | { name, cross }, mf ? mf->GetBacktrace() : cmListFileBacktrace())); |
1210 | 0 | } |
1211 | | |
1212 | | void cmTarget::AddUtility(BT<std::pair<std::string, bool>> util) |
1213 | 0 | { |
1214 | 0 | this->impl->Utilities.emplace(std::move(util)); |
1215 | 0 | } |
1216 | | |
1217 | | void cmTarget::AddCodegenDependency(std::string const& name) |
1218 | 0 | { |
1219 | 0 | this->impl->CodegenDependencies.emplace(name); |
1220 | 0 | } |
1221 | | |
1222 | | std::set<std::string> const& cmTarget::GetCodegenDeps() const |
1223 | 0 | { |
1224 | 0 | return this->impl->CodegenDependencies; |
1225 | 0 | } |
1226 | | |
1227 | | std::set<BT<std::pair<std::string, bool>>> const& cmTarget::GetUtilities() |
1228 | | const |
1229 | 0 | { |
1230 | 0 | return this->impl->Utilities; |
1231 | 0 | } |
1232 | | |
1233 | | cmListFileBacktrace const& cmTarget::GetBacktrace() const |
1234 | 0 | { |
1235 | 0 | return this->impl->Backtrace; |
1236 | 0 | } |
1237 | | |
1238 | | cmFindPackageStack const& cmTarget::GetFindPackageStack() const |
1239 | 0 | { |
1240 | 0 | return this->impl->FindPackageStack; |
1241 | 0 | } |
1242 | | |
1243 | | bool cmTarget::IsExecutableWithExports() const |
1244 | 0 | { |
1245 | 0 | return (this->GetType() == cmStateEnums::EXECUTABLE && |
1246 | 0 | this->GetPropertyAsBool("ENABLE_EXPORTS")); |
1247 | 0 | } |
1248 | | |
1249 | | bool cmTarget::IsSharedLibraryWithExports() const |
1250 | 0 | { |
1251 | 0 | return (this->GetType() == cmStateEnums::SHARED_LIBRARY && |
1252 | 0 | this->GetPropertyAsBool("ENABLE_EXPORTS")); |
1253 | 0 | } |
1254 | | |
1255 | | bool cmTarget::IsFrameworkOnApple() const |
1256 | 0 | { |
1257 | 0 | return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || |
1258 | 0 | this->GetType() == cmStateEnums::STATIC_LIBRARY) && |
1259 | 0 | this->IsApple() && this->GetPropertyAsBool("FRAMEWORK")); |
1260 | 0 | } |
1261 | | |
1262 | | bool cmTarget::IsArchivedAIXSharedLibrary() const |
1263 | 0 | { |
1264 | 0 | if (this->GetType() == cmStateEnums::SHARED_LIBRARY && this->IsAIX()) { |
1265 | 0 | cmValue value = this->GetProperty("AIX_SHARED_LIBRARY_ARCHIVE"); |
1266 | 0 | if (!value.IsEmpty()) { |
1267 | 0 | return value.IsOn(); |
1268 | 0 | } |
1269 | 0 | if (this->IsImported()) { |
1270 | 0 | return false; |
1271 | 0 | } |
1272 | 0 | switch (this->GetPolicyStatusCMP0182()) { |
1273 | 0 | case cmPolicies::WARN: |
1274 | 0 | case cmPolicies::OLD: |
1275 | | // The OLD behavior's default is to disable shared library archives. |
1276 | 0 | break; |
1277 | 0 | case cmPolicies::NEW: |
1278 | | // The NEW behavior's default is to enable shared library archives. |
1279 | 0 | return true; |
1280 | 0 | } |
1281 | 0 | } |
1282 | 0 | return false; |
1283 | 0 | } |
1284 | | |
1285 | | bool cmTarget::IsAppBundleOnApple() const |
1286 | 0 | { |
1287 | 0 | return (this->GetType() == cmStateEnums::EXECUTABLE && this->IsApple() && |
1288 | 0 | this->GetPropertyAsBool("MACOSX_BUNDLE")); |
1289 | 0 | } |
1290 | | |
1291 | | bool cmTarget::IsAndroidGuiExecutable() const |
1292 | 0 | { |
1293 | 0 | return (this->GetType() == cmStateEnums::EXECUTABLE && |
1294 | 0 | this->impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")); |
1295 | 0 | } |
1296 | | |
1297 | | bool cmTarget::HasKnownObjectFileLocation(std::string* reason) const |
1298 | 0 | { |
1299 | 0 | return this->GetGlobalGenerator()->HasKnownObjectFileLocation(*this, reason); |
1300 | 0 | } |
1301 | | |
1302 | | std::vector<cmCustomCommand> const& cmTarget::GetPreBuildCommands() const |
1303 | 0 | { |
1304 | 0 | return this->impl->PreBuildCommands; |
1305 | 0 | } |
1306 | | |
1307 | | void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd) |
1308 | 0 | { |
1309 | 0 | this->impl->PreBuildCommands.push_back(cmd); |
1310 | 0 | } |
1311 | | |
1312 | | void cmTarget::AddPreBuildCommand(cmCustomCommand&& cmd) |
1313 | 0 | { |
1314 | 0 | this->impl->PreBuildCommands.push_back(std::move(cmd)); |
1315 | 0 | } |
1316 | | |
1317 | | std::vector<cmCustomCommand> const& cmTarget::GetPreLinkCommands() const |
1318 | 0 | { |
1319 | 0 | return this->impl->PreLinkCommands; |
1320 | 0 | } |
1321 | | |
1322 | | void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd) |
1323 | 0 | { |
1324 | 0 | this->impl->PreLinkCommands.push_back(cmd); |
1325 | 0 | } |
1326 | | |
1327 | | void cmTarget::AddPreLinkCommand(cmCustomCommand&& cmd) |
1328 | 0 | { |
1329 | 0 | this->impl->PreLinkCommands.push_back(std::move(cmd)); |
1330 | 0 | } |
1331 | | |
1332 | | std::vector<cmCustomCommand> const& cmTarget::GetPostBuildCommands() const |
1333 | 0 | { |
1334 | 0 | return this->impl->PostBuildCommands; |
1335 | 0 | } |
1336 | | |
1337 | | void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd) |
1338 | 0 | { |
1339 | 0 | this->impl->PostBuildCommands.push_back(cmd); |
1340 | 0 | } |
1341 | | |
1342 | | void cmTarget::AddPostBuildCommand(cmCustomCommand&& cmd) |
1343 | 0 | { |
1344 | 0 | this->impl->PostBuildCommands.push_back(std::move(cmd)); |
1345 | 0 | } |
1346 | | |
1347 | | void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) |
1348 | 0 | { |
1349 | 0 | if (!srcs.empty()) { |
1350 | 0 | this->impl->Sources.WriteDirect(this->impl.get(), {}, |
1351 | 0 | cmValue(cmJoin(srcs, ";")), |
1352 | 0 | UsageRequirementProperty::Action::Append); |
1353 | 0 | } |
1354 | 0 | } |
1355 | | |
1356 | | void cmTarget::AddSources(std::vector<std::string> const& srcs) |
1357 | 0 | { |
1358 | 0 | std::vector<std::string> srcFiles; |
1359 | 0 | for (std::string const& filename : srcs) { |
1360 | 0 | if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) { |
1361 | 0 | this->impl->Makefile->GetOrCreateSource(filename); |
1362 | 0 | } |
1363 | 0 | srcFiles.emplace_back(filename); |
1364 | 0 | } |
1365 | 0 | this->AddTracedSources(srcFiles); |
1366 | 0 | } |
1367 | | |
1368 | | struct CreateLocation |
1369 | | { |
1370 | | cmMakefile const* Makefile; |
1371 | | |
1372 | | CreateLocation(cmMakefile const* mf) |
1373 | 0 | : Makefile(mf) |
1374 | 0 | { |
1375 | 0 | } |
1376 | | |
1377 | | cmSourceFileLocation operator()(std::string const& filename) const |
1378 | 0 | { |
1379 | 0 | return cmSourceFileLocation(this->Makefile, filename); |
1380 | 0 | } |
1381 | | }; |
1382 | | |
1383 | | struct LocationMatcher |
1384 | | { |
1385 | | cmSourceFileLocation const& Needle; |
1386 | | |
1387 | | LocationMatcher(cmSourceFileLocation const& needle) |
1388 | 0 | : Needle(needle) |
1389 | 0 | { |
1390 | 0 | } |
1391 | | |
1392 | | bool operator()(cmSourceFileLocation& loc) |
1393 | 0 | { |
1394 | 0 | return loc.Matches(this->Needle); |
1395 | 0 | } |
1396 | | }; |
1397 | | |
1398 | | struct TargetPropertyEntryFinder |
1399 | | { |
1400 | | private: |
1401 | | cmSourceFileLocation const& Needle; |
1402 | | |
1403 | | public: |
1404 | | TargetPropertyEntryFinder(cmSourceFileLocation const& needle) |
1405 | 0 | : Needle(needle) |
1406 | 0 | { |
1407 | 0 | } |
1408 | | |
1409 | | bool operator()(BT<std::string> const& entry) |
1410 | 0 | { |
1411 | 0 | cmList files{ entry.Value }; |
1412 | 0 | std::vector<cmSourceFileLocation> locations; |
1413 | 0 | locations.reserve(files.size()); |
1414 | 0 | std::transform(files.begin(), files.end(), std::back_inserter(locations), |
1415 | 0 | CreateLocation(this->Needle.GetMakefile())); |
1416 | |
|
1417 | 0 | return std::find_if(locations.begin(), locations.end(), |
1418 | 0 | LocationMatcher(this->Needle)) != locations.end(); |
1419 | 0 | } |
1420 | | }; |
1421 | | |
1422 | | cmSourceFile* cmTarget::AddSource(std::string const& src, bool before) |
1423 | 0 | { |
1424 | 0 | cmSourceFileLocation sfl(this->impl->Makefile, src, |
1425 | 0 | cmSourceFileLocationKind::Known); |
1426 | 0 | auto const& sources = this->impl->Sources.Entries; |
1427 | 0 | if (std::find_if(sources.begin(), sources.end(), |
1428 | 0 | TargetPropertyEntryFinder(sfl)) == sources.end()) { |
1429 | 0 | this->impl->Sources.WriteDirect( |
1430 | 0 | this->impl.get(), {}, cmValue(src), |
1431 | 0 | before ? UsageRequirementProperty::Action::Prepend |
1432 | 0 | : UsageRequirementProperty::Action::Append); |
1433 | 0 | } |
1434 | 0 | if (cmGeneratorExpression::Find(src) != std::string::npos) { |
1435 | 0 | return nullptr; |
1436 | 0 | } |
1437 | 0 | return this->impl->Makefile->GetOrCreateSource( |
1438 | 0 | src, false, cmSourceFileLocationKind::Known); |
1439 | 0 | } |
1440 | | |
1441 | | void cmTarget::ClearDependencyInformation(cmMakefile& mf) const |
1442 | 0 | { |
1443 | 0 | std::string depname = cmStrCat(this->GetName(), "_LIB_DEPENDS"); |
1444 | 0 | mf.RemoveCacheDefinition(depname); |
1445 | 0 | } |
1446 | | |
1447 | | std::string cmTarget::GetDebugGeneratorExpressions( |
1448 | | std::string const& value, cmTargetLinkLibraryType llt) const |
1449 | 0 | { |
1450 | 0 | if (llt == GENERAL_LibraryType) { |
1451 | 0 | return value; |
1452 | 0 | } |
1453 | | |
1454 | | // Get the list of configurations considered to be DEBUG. |
1455 | 0 | std::vector<std::string> debugConfigs = |
1456 | 0 | this->impl->Makefile->GetCMakeInstance()->GetDebugConfigs(); |
1457 | |
|
1458 | 0 | std::string configString = "$<CONFIG:" + debugConfigs[0] + ">"; |
1459 | |
|
1460 | 0 | if (debugConfigs.size() > 1) { |
1461 | 0 | for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) { |
1462 | 0 | configString += ",$<CONFIG:" + conf + ">"; |
1463 | 0 | } |
1464 | 0 | configString = "$<OR:" + configString + ">"; |
1465 | 0 | } |
1466 | |
|
1467 | 0 | if (llt == OPTIMIZED_LibraryType) { |
1468 | 0 | configString = "$<NOT:" + configString + ">"; |
1469 | 0 | } |
1470 | 0 | return "$<" + configString + ":" + value + ">"; |
1471 | 0 | } |
1472 | | |
1473 | | static std::string targetNameGenex(std::string const& lib) |
1474 | 0 | { |
1475 | 0 | return "$<TARGET_NAME:" + lib + ">"; |
1476 | 0 | } |
1477 | | |
1478 | | bool cmTarget::PushTLLCommandTrace(TLLSignature signature, |
1479 | | cmListFileContext const& lfc) |
1480 | 0 | { |
1481 | 0 | bool ret = true; |
1482 | 0 | if (!this->impl->TLLCommands.empty()) { |
1483 | 0 | if (this->impl->TLLCommands.back().first != signature) { |
1484 | 0 | ret = false; |
1485 | 0 | } |
1486 | 0 | } |
1487 | 0 | if (this->impl->TLLCommands.empty() || |
1488 | 0 | this->impl->TLLCommands.back().second != lfc) { |
1489 | 0 | this->impl->TLLCommands.emplace_back(signature, lfc); |
1490 | 0 | } |
1491 | 0 | return ret; |
1492 | 0 | } |
1493 | | |
1494 | | void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const |
1495 | 0 | { |
1496 | 0 | char const* sigString = |
1497 | 0 | (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); |
1498 | 0 | s << "The uses of the " << sigString << " signature are here:\n"; |
1499 | 0 | for (auto const& cmd : this->impl->TLLCommands) { |
1500 | 0 | if (cmd.first == sig) { |
1501 | 0 | cmListFileContext lfc = cmd.second; |
1502 | 0 | lfc.FilePath = cmSystemTools::RelativeIfUnder( |
1503 | 0 | this->impl->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath); |
1504 | 0 | s << " * " << lfc << '\n'; |
1505 | 0 | } |
1506 | 0 | } |
1507 | 0 | } |
1508 | | |
1509 | | std::string const& cmTarget::GetInstallPath() const |
1510 | 0 | { |
1511 | 0 | return this->impl->InstallPath; |
1512 | 0 | } |
1513 | | |
1514 | | void cmTarget::SetInstallPath(std::string const& name) |
1515 | 0 | { |
1516 | 0 | this->impl->InstallPath = name; |
1517 | 0 | } |
1518 | | |
1519 | | std::string const& cmTarget::GetRuntimeInstallPath() const |
1520 | 0 | { |
1521 | 0 | return this->impl->RuntimeInstallPath; |
1522 | 0 | } |
1523 | | |
1524 | | void cmTarget::SetRuntimeInstallPath(std::string const& name) |
1525 | 0 | { |
1526 | 0 | this->impl->RuntimeInstallPath = name; |
1527 | 0 | } |
1528 | | |
1529 | | bool cmTarget::GetHaveInstallRule() const |
1530 | 0 | { |
1531 | 0 | return this->impl->HaveInstallRule; |
1532 | 0 | } |
1533 | | |
1534 | | void cmTarget::SetHaveInstallRule(bool hir) |
1535 | 0 | { |
1536 | 0 | this->impl->HaveInstallRule = hir; |
1537 | 0 | } |
1538 | | |
1539 | | void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g) |
1540 | 0 | { |
1541 | 0 | this->impl->InstallGenerators.emplace_back(g); |
1542 | 0 | } |
1543 | | |
1544 | | std::vector<cmInstallTargetGenerator*> const& cmTarget::GetInstallGenerators() |
1545 | | const |
1546 | 0 | { |
1547 | 0 | return this->impl->InstallGenerators; |
1548 | 0 | } |
1549 | | |
1550 | | bool cmTarget::GetIsGeneratorProvided() const |
1551 | 0 | { |
1552 | 0 | return this->impl->IsGeneratorProvided; |
1553 | 0 | } |
1554 | | |
1555 | | void cmTarget::SetIsGeneratorProvided(bool igp) |
1556 | 0 | { |
1557 | 0 | this->impl->IsGeneratorProvided = igp; |
1558 | 0 | } |
1559 | | |
1560 | | cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries() |
1561 | | const |
1562 | 0 | { |
1563 | 0 | return this->impl->OriginalLinkLibraries; |
1564 | 0 | } |
1565 | | |
1566 | | void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, |
1567 | | cmTargetLinkLibraryType llt) |
1568 | 0 | { |
1569 | 0 | cmTarget* tgt = mf.FindTargetToUse(lib); |
1570 | 0 | { |
1571 | 0 | bool const isNonImportedTarget = tgt && !tgt->IsImported(); |
1572 | |
|
1573 | 0 | std::string const libName = |
1574 | 0 | (isNonImportedTarget && llt != GENERAL_LibraryType) |
1575 | 0 | ? targetNameGenex(lib) |
1576 | 0 | : lib; |
1577 | 0 | this->AppendProperty("LINK_LIBRARIES", |
1578 | 0 | this->GetDebugGeneratorExpressions(libName, llt), |
1579 | 0 | mf.GetBacktrace()); |
1580 | 0 | } |
1581 | |
|
1582 | 0 | if (cmGeneratorExpression::Find(lib) != std::string::npos || |
1583 | 0 | (tgt && |
1584 | 0 | (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY || |
1585 | 0 | tgt->GetType() == cmStateEnums::OBJECT_LIBRARY)) || |
1586 | 0 | (this->impl->Name == lib)) { |
1587 | 0 | return; |
1588 | 0 | } |
1589 | | |
1590 | 0 | this->impl->OriginalLinkLibraries.emplace_back(lib, llt); |
1591 | | |
1592 | | // Add the explicit dependency information for libraries. This is |
1593 | | // simply a set of libraries separated by ";". There should always |
1594 | | // be a trailing ";". These library names are not canonical, in that |
1595 | | // they may be "-framework x", "-ly", "/path/libz.a", etc. |
1596 | | // We shouldn't remove duplicates here because external libraries |
1597 | | // may be purposefully duplicated to handle recursive dependencies, |
1598 | | // and we removing one instance will break the link line. Duplicates |
1599 | | // will be appropriately eliminated at emit time. |
1600 | 0 | if (this->impl->TargetType >= cmStateEnums::STATIC_LIBRARY && |
1601 | 0 | this->impl->TargetType <= cmStateEnums::MODULE_LIBRARY && |
1602 | 0 | (this->GetPolicyStatusCMP0073() == cmPolicies::OLD || |
1603 | 0 | this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) { |
1604 | 0 | std::string targetEntry = cmStrCat(this->impl->Name, "_LIB_DEPENDS"); |
1605 | 0 | std::string dependencies; |
1606 | 0 | cmValue old_val = mf.GetDefinition(targetEntry); |
1607 | 0 | if (old_val) { |
1608 | 0 | dependencies += *old_val; |
1609 | 0 | } |
1610 | 0 | switch (llt) { |
1611 | 0 | case GENERAL_LibraryType: |
1612 | 0 | dependencies += "general"; |
1613 | 0 | break; |
1614 | 0 | case DEBUG_LibraryType: |
1615 | 0 | dependencies += "debug"; |
1616 | 0 | break; |
1617 | 0 | case OPTIMIZED_LibraryType: |
1618 | 0 | dependencies += "optimized"; |
1619 | 0 | break; |
1620 | 0 | } |
1621 | 0 | dependencies += ";"; |
1622 | 0 | dependencies += lib; |
1623 | 0 | dependencies += ";"; |
1624 | 0 | mf.AddCacheDefinition(targetEntry, dependencies, |
1625 | 0 | "Dependencies for the target", cmStateEnums::STATIC); |
1626 | 0 | } |
1627 | 0 | } |
1628 | | |
1629 | | void cmTarget::AddSystemIncludeDirectories(std::set<std::string> const& incs) |
1630 | 0 | { |
1631 | 0 | this->impl->SystemIncludeDirectories.insert(incs.begin(), incs.end()); |
1632 | 0 | } |
1633 | | |
1634 | | std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const |
1635 | 0 | { |
1636 | 0 | return this->impl->SystemIncludeDirectories; |
1637 | 0 | } |
1638 | | |
1639 | | void cmTarget::AddInstallIncludeDirectories(cmTargetExport const& te, |
1640 | | cmStringRange incs) |
1641 | 0 | { |
1642 | 0 | std::copy( |
1643 | 0 | incs.begin(), incs.end(), |
1644 | 0 | std::back_inserter(this->impl->InstallIncludeDirectoriesEntries[&te])); |
1645 | 0 | } |
1646 | | |
1647 | | cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries( |
1648 | | cmTargetExport const& te) const |
1649 | 0 | { |
1650 | 0 | auto i = this->impl->InstallIncludeDirectoriesEntries.find(&te); |
1651 | 0 | if (i == this->impl->InstallIncludeDirectoriesEntries.end()) { |
1652 | 0 | decltype(i->second) empty; |
1653 | 0 | return cmMakeRange(empty); |
1654 | 0 | } |
1655 | 0 | return cmMakeRange(i->second); |
1656 | 0 | } |
1657 | | |
1658 | | cmBTStringRange cmTarget::GetIncludeDirectoriesEntries() const |
1659 | 0 | { |
1660 | 0 | return cmMakeRange(this->impl->IncludeDirectories.Entries); |
1661 | 0 | } |
1662 | | |
1663 | | cmBTStringRange cmTarget::GetCompileOptionsEntries() const |
1664 | 0 | { |
1665 | 0 | return cmMakeRange(this->impl->CompileOptions.Entries); |
1666 | 0 | } |
1667 | | |
1668 | | cmBTStringRange cmTarget::GetCompileFeaturesEntries() const |
1669 | 0 | { |
1670 | 0 | return cmMakeRange(this->impl->CompileFeatures.Entries); |
1671 | 0 | } |
1672 | | |
1673 | | cmBTStringRange cmTarget::GetCompileDefinitionsEntries() const |
1674 | 0 | { |
1675 | 0 | return cmMakeRange(this->impl->CompileDefinitions.Entries); |
1676 | 0 | } |
1677 | | |
1678 | | cmBTStringRange cmTarget::GetPrecompileHeadersEntries() const |
1679 | 0 | { |
1680 | 0 | return cmMakeRange(this->impl->PrecompileHeaders.Entries); |
1681 | 0 | } |
1682 | | |
1683 | | cmBTStringRange cmTarget::GetSourceEntries() const |
1684 | 0 | { |
1685 | 0 | return cmMakeRange(this->impl->Sources.Entries); |
1686 | 0 | } |
1687 | | |
1688 | | cmBTStringRange cmTarget::GetLinkOptionsEntries() const |
1689 | 0 | { |
1690 | 0 | return cmMakeRange(this->impl->LinkOptions.Entries); |
1691 | 0 | } |
1692 | | |
1693 | | cmBTStringRange cmTarget::GetLinkDirectoriesEntries() const |
1694 | 0 | { |
1695 | 0 | return cmMakeRange(this->impl->LinkDirectories.Entries); |
1696 | 0 | } |
1697 | | |
1698 | | cmBTStringRange cmTarget::GetLinkImplementationEntries() const |
1699 | 0 | { |
1700 | 0 | return cmMakeRange(this->impl->LinkLibraries.Entries); |
1701 | 0 | } |
1702 | | |
1703 | | cmBTStringRange cmTarget::GetLinkInterfaceEntries() const |
1704 | 0 | { |
1705 | 0 | return cmMakeRange(this->impl->InterfaceLinkLibraries.Entries); |
1706 | 0 | } |
1707 | | |
1708 | | cmBTStringRange cmTarget::GetLinkInterfaceDirectEntries() const |
1709 | 0 | { |
1710 | 0 | return cmMakeRange(this->impl->InterfaceLinkLibrariesDirect.Entries); |
1711 | 0 | } |
1712 | | |
1713 | | cmBTStringRange cmTarget::GetLinkInterfaceDirectExcludeEntries() const |
1714 | 0 | { |
1715 | 0 | return cmMakeRange(this->impl->InterfaceLinkLibrariesDirectExclude.Entries); |
1716 | 0 | } |
1717 | | |
1718 | | void cmTarget::CopyPolicyStatuses(cmTarget const* tgt) |
1719 | 0 | { |
1720 | | // Normal targets cannot be the target of a copy. |
1721 | 0 | assert(!this->IsNormal()); |
1722 | | // Imported targets cannot be the target of a copy. |
1723 | 0 | assert(!this->IsImported()); |
1724 | | // Only imported targets can be the source of a copy. |
1725 | 0 | assert(tgt->IsImported()); |
1726 | |
|
1727 | 0 | this->impl->PolicyMap = tgt->impl->PolicyMap; |
1728 | 0 | this->impl->TemplateTarget = tgt; |
1729 | 0 | } |
1730 | | |
1731 | | void cmTarget::CopyImportedCxxModulesEntries(cmTarget const* tgt) |
1732 | 0 | { |
1733 | | // Normal targets cannot be the target of a copy. |
1734 | 0 | assert(!this->IsNormal()); |
1735 | | // Imported targets cannot be the target of a copy. |
1736 | 0 | assert(!this->IsImported()); |
1737 | | // Only imported targets can be the source of a copy. |
1738 | 0 | assert(tgt->IsImported()); |
1739 | |
|
1740 | 0 | this->impl->IncludeDirectories.Entries.clear(); |
1741 | 0 | this->impl->IncludeDirectories.CopyFromEntries( |
1742 | 0 | cmMakeRange(tgt->impl->ImportedCxxModulesIncludeDirectories.Entries)); |
1743 | 0 | this->impl->CompileDefinitions.Entries.clear(); |
1744 | 0 | this->impl->CompileDefinitions.CopyFromEntries( |
1745 | 0 | cmMakeRange(tgt->impl->ImportedCxxModulesCompileDefinitions.Entries)); |
1746 | 0 | this->impl->CompileFeatures.Entries.clear(); |
1747 | 0 | this->impl->CompileFeatures.CopyFromEntries( |
1748 | 0 | cmMakeRange(tgt->impl->ImportedCxxModulesCompileFeatures.Entries)); |
1749 | 0 | this->impl->CompileOptions.Entries.clear(); |
1750 | 0 | this->impl->CompileOptions.CopyFromEntries( |
1751 | 0 | cmMakeRange(tgt->impl->ImportedCxxModulesCompileOptions.Entries)); |
1752 | 0 | this->impl->LinkLibraries.Entries.clear(); |
1753 | 0 | this->impl->LinkLibraries.CopyFromEntries( |
1754 | 0 | cmMakeRange(tgt->impl->ImportedCxxModulesLinkLibraries.Entries)); |
1755 | | |
1756 | | // Copy the C++ module fileset entries from `tgt`'s `INTERFACE` to this |
1757 | | // target's `PRIVATE`. |
1758 | 0 | this->impl->CxxModulesFileSets.SelfEntries.Entries.clear(); |
1759 | 0 | this->impl->CxxModulesFileSets.SelfEntries.Entries = |
1760 | 0 | tgt->impl->CxxModulesFileSets.InterfaceEntries.Entries; |
1761 | 0 | } |
1762 | | |
1763 | | void cmTarget::CopyImportedCxxModulesProperties(cmTarget const* tgt) |
1764 | 0 | { |
1765 | | // Normal targets cannot be the target of a copy. |
1766 | 0 | assert(!this->IsNormal()); |
1767 | | // Imported targets cannot be the target of a copy. |
1768 | 0 | assert(!this->IsImported()); |
1769 | | // Only imported targets can be the source of a copy. |
1770 | 0 | assert(tgt->IsImported()); |
1771 | | |
1772 | | // The list of properties that are relevant here include: |
1773 | | // - compilation-specific properties for any language or platform |
1774 | | // - compilation-specific properties for C++ |
1775 | | // - build graph-specific properties that affect compilation |
1776 | | // - IDE metadata properties |
1777 | | // - static analysis properties |
1778 | |
|
1779 | 0 | static std::string const propertiesToCopy[] = { |
1780 | | // Compilation properties |
1781 | 0 | "DEFINE_SYMBOL", |
1782 | 0 | "DEPRECATION", |
1783 | 0 | "NO_SYSTEM_FROM_IMPORTED", |
1784 | 0 | "POSITION_INDEPENDENT_CODE", |
1785 | 0 | "VISIBILITY_INLINES_HIDDEN", |
1786 | | // -- Platforms |
1787 | | // ---- Android |
1788 | 0 | "ANDROID_API", |
1789 | 0 | "ANDROID_API_MIN", |
1790 | 0 | "ANDROID_ARCH", |
1791 | 0 | "ANDROID_STL_TYPE", |
1792 | | // ---- macOS |
1793 | 0 | "OSX_ARCHITECTURES", |
1794 | | // ---- Windows |
1795 | 0 | "MSVC_DEBUG_INFORMATION_FORMAT", |
1796 | 0 | "MSVC_RUNTIME_CHECKS", |
1797 | 0 | "MSVC_RUNTIME_LIBRARY", |
1798 | 0 | "VS_PLATFORM_TOOLSET", |
1799 | | // ---- OpenWatcom |
1800 | 0 | "WATCOM_RUNTIME_LIBRARY", |
1801 | | // -- Language |
1802 | | // ---- C++ |
1803 | 0 | "CXX_COMPILER_LAUNCHER", |
1804 | 0 | "CXX_STANDARD", |
1805 | 0 | "CXX_STANDARD_REQUIRED", |
1806 | 0 | "CXX_EXTENSIONS", |
1807 | 0 | "CXX_VISIBILITY_PRESET", |
1808 | 0 | "CXX_MODULE_STD", |
1809 | | |
1810 | | // Static analysis |
1811 | 0 | "CXX_CLANG_TIDY", |
1812 | 0 | "CXX_CLANG_TIDY_EXPORT_FIXES_DIR", |
1813 | 0 | "CXX_CPPLINT", |
1814 | 0 | "CXX_CPPCHECK", |
1815 | 0 | "CXX_ICSTAT", |
1816 | 0 | "CXX_INCLUDE_WHAT_YOU_USE", |
1817 | 0 | "CXX_PVS_STUDIO", |
1818 | 0 | "SKIP_LINTING", |
1819 | | |
1820 | | // Build graph properties |
1821 | 0 | "EXCLUDE_FROM_ALL", |
1822 | 0 | "EXCLUDE_FROM_DEFAULT_BUILD", |
1823 | 0 | "OPTIMIZE_DEPENDENCIES", |
1824 | | // -- Ninja |
1825 | 0 | "JOB_POOL_COMPILE", |
1826 | | // -- Visual Studio |
1827 | 0 | "VS_NO_COMPILE_BATCHING", |
1828 | 0 | "VS_PROJECT_IMPORT", |
1829 | | |
1830 | | // Metadata |
1831 | 0 | "EchoString", |
1832 | 0 | "EXPORT_COMPILE_COMMANDS", |
1833 | | // Do *not* copy this property; it should be re-initialized at synthesis |
1834 | | // time from the `CMAKE_EXPORT_BUILD_DATABASE` variable as `IMPORTED` |
1835 | | // targets ignore the property initialization. |
1836 | | // "EXPORT_BUILD_DATABASE", |
1837 | 0 | "FOLDER", |
1838 | 0 | "LABELS", |
1839 | 0 | "PROJECT_LABEL", |
1840 | 0 | "SYSTEM", |
1841 | 0 | }; |
1842 | |
|
1843 | 0 | auto copyProperty = [this, tgt](std::string const& prop) -> cmValue { |
1844 | 0 | cmValue value = tgt->GetProperty(prop); |
1845 | | // Always set the property; it may have been explicitly unset. |
1846 | 0 | this->SetProperty(prop, value); |
1847 | 0 | return value; |
1848 | 0 | }; |
1849 | |
|
1850 | 0 | for (auto const& prop : propertiesToCopy) { |
1851 | 0 | copyProperty(prop); |
1852 | 0 | } |
1853 | |
|
1854 | 0 | static cm::static_string_view const perConfigPropertiesToCopy[] = { |
1855 | 0 | "EXCLUDE_FROM_DEFAULT_BUILD_"_s, |
1856 | 0 | "IMPORTED_CXX_MODULES_"_s, |
1857 | 0 | "MAP_IMPORTED_CONFIG_"_s, |
1858 | 0 | "OSX_ARCHITECTURES_"_s, |
1859 | 0 | }; |
1860 | |
|
1861 | 0 | std::vector<std::string> configNames = |
1862 | 0 | this->impl->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); |
1863 | 0 | for (std::string const& configName : configNames) { |
1864 | 0 | std::string configUpper = cmSystemTools::UpperCase(configName); |
1865 | 0 | for (auto const& perConfigProp : perConfigPropertiesToCopy) { |
1866 | 0 | copyProperty(cmStrCat(perConfigProp, configUpper)); |
1867 | 0 | } |
1868 | 0 | } |
1869 | |
|
1870 | 0 | if (this->GetGlobalGenerator()->IsXcode()) { |
1871 | 0 | cmValue xcodeGenerateScheme = copyProperty("XCODE_GENERATE_SCHEME"); |
1872 | | |
1873 | | // TODO: Make sure these show up on the imported target in the first place |
1874 | | // XCODE_ATTRIBUTE_??? |
1875 | |
|
1876 | 0 | if (xcodeGenerateScheme.IsOn()) { |
1877 | | #ifdef __APPLE__ |
1878 | | static std::string const xcodeSchemePropertiesToCopy[] = { |
1879 | | // FIXME: Do all of these apply? Do they matter? |
1880 | | "XCODE_SCHEME_ADDRESS_SANITIZER", |
1881 | | "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", |
1882 | | "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER", |
1883 | | "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS", |
1884 | | "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE", |
1885 | | "XCODE_SCHEME_ENABLE_GPU_API_VALIDATION", |
1886 | | "XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION", |
1887 | | "XCODE_SCHEME_GUARD_MALLOC", |
1888 | | "XCODE_SCHEME_LAUNCH_CONFIGURATION", |
1889 | | "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP", |
1890 | | "XCODE_SCHEME_MALLOC_GUARD_EDGES", |
1891 | | "XCODE_SCHEME_MALLOC_SCRIBBLE", |
1892 | | "XCODE_SCHEME_MALLOC_STACK", |
1893 | | "XCODE_SCHEME_THREAD_SANITIZER", |
1894 | | "XCODE_SCHEME_THREAD_SANITIZER_STOP", |
1895 | | "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER", |
1896 | | "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP", |
1897 | | "XCODE_SCHEME_ZOMBIE_OBJECTS", |
1898 | | }; |
1899 | | |
1900 | | for (auto const& xcodeProperty : xcodeSchemePropertiesToCopy) { |
1901 | | copyProperty(xcodeProperty); |
1902 | | } |
1903 | | #endif |
1904 | 0 | } |
1905 | 0 | } |
1906 | 0 | } |
1907 | | |
1908 | | cmBTStringRange cmTarget::GetHeaderSetsEntries() const |
1909 | 0 | { |
1910 | 0 | return cmMakeRange(this->impl->HeadersFileSets.SelfEntries.Entries); |
1911 | 0 | } |
1912 | | |
1913 | | cmBTStringRange cmTarget::GetCxxModuleSetsEntries() const |
1914 | 0 | { |
1915 | 0 | return cmMakeRange(this->impl->CxxModulesFileSets.SelfEntries.Entries); |
1916 | 0 | } |
1917 | | |
1918 | | cmBTStringRange cmTarget::GetInterfaceHeaderSetsEntries() const |
1919 | 0 | { |
1920 | 0 | return cmMakeRange(this->impl->HeadersFileSets.InterfaceEntries.Entries); |
1921 | 0 | } |
1922 | | |
1923 | | cmBTStringRange cmTarget::GetInterfaceCxxModuleSetsEntries() const |
1924 | 0 | { |
1925 | 0 | return cmMakeRange(this->impl->CxxModulesFileSets.InterfaceEntries.Entries); |
1926 | 0 | } |
1927 | | |
1928 | | namespace { |
1929 | | #define MAKE_PROP(PROP) const std::string prop##PROP = #PROP |
1930 | | MAKE_PROP(C_STANDARD); |
1931 | | MAKE_PROP(CXX_STANDARD); |
1932 | | MAKE_PROP(CUDA_STANDARD); |
1933 | | MAKE_PROP(HIP_STANDARD); |
1934 | | MAKE_PROP(OBJC_STANDARD); |
1935 | | MAKE_PROP(OBJCXX_STANDARD); |
1936 | | MAKE_PROP(COMPILE_DEFINITIONS); |
1937 | | MAKE_PROP(COMPILE_FEATURES); |
1938 | | MAKE_PROP(COMPILE_OPTIONS); |
1939 | | MAKE_PROP(PRECOMPILE_HEADERS); |
1940 | | MAKE_PROP(CUDA_CUBIN_COMPILATION); |
1941 | | MAKE_PROP(CUDA_FATBIN_COMPILATION); |
1942 | | MAKE_PROP(CUDA_OPTIX_COMPILATION); |
1943 | | MAKE_PROP(CUDA_PTX_COMPILATION); |
1944 | | MAKE_PROP(IMPORTED); |
1945 | | MAKE_PROP(IMPORTED_GLOBAL); |
1946 | | MAKE_PROP(INCLUDE_DIRECTORIES); |
1947 | | MAKE_PROP(LINK_OPTIONS); |
1948 | | MAKE_PROP(IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES); |
1949 | | MAKE_PROP(IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS); |
1950 | | MAKE_PROP(IMPORTED_CXX_MODULES_COMPILE_FEATURES); |
1951 | | MAKE_PROP(IMPORTED_CXX_MODULES_COMPILE_OPTIONS); |
1952 | | MAKE_PROP(IMPORTED_CXX_MODULES_LINK_LIBRARIES); |
1953 | | MAKE_PROP(LINK_DIRECTORIES); |
1954 | | MAKE_PROP(LINK_LIBRARIES); |
1955 | | MAKE_PROP(MANUALLY_ADDED_DEPENDENCIES); |
1956 | | MAKE_PROP(NAME); |
1957 | | MAKE_PROP(SOURCES); |
1958 | | MAKE_PROP(SYMBOLIC); |
1959 | | MAKE_PROP(TYPE); |
1960 | | MAKE_PROP(BINARY_DIR); |
1961 | | MAKE_PROP(SOURCE_DIR); |
1962 | | MAKE_PROP(FALSE); |
1963 | | MAKE_PROP(TRUE); |
1964 | | MAKE_PROP(INTERFACE_LINK_LIBRARIES); |
1965 | | MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT); |
1966 | | MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE); |
1967 | | #undef MAKE_PROP |
1968 | | } |
1969 | | |
1970 | | namespace { |
1971 | | |
1972 | | enum class ReadOnlyCondition |
1973 | | { |
1974 | | All, |
1975 | | Imported, |
1976 | | NonImported, |
1977 | | }; |
1978 | | |
1979 | | struct ReadOnlyProperty |
1980 | | { |
1981 | | ReadOnlyProperty(ReadOnlyCondition cond) |
1982 | 0 | : Condition{ cond } |
1983 | 0 | { |
1984 | 0 | } |
1985 | | ReadOnlyProperty(ReadOnlyCondition cond, cmPolicies::PolicyID id) |
1986 | 0 | : Condition{ cond } |
1987 | 0 | , Policy{ id } |
1988 | 0 | { |
1989 | 0 | } |
1990 | | |
1991 | | ReadOnlyCondition Condition; |
1992 | | cm::optional<cmPolicies::PolicyID> Policy; |
1993 | | |
1994 | | std::string message(std::string const& prop, cmTarget* target) const |
1995 | 0 | { |
1996 | 0 | std::string msg; |
1997 | 0 | if (this->Condition == ReadOnlyCondition::All) { |
1998 | 0 | msg = " property is read-only for target(\""; |
1999 | 0 | } else if (this->Condition == ReadOnlyCondition::Imported) { |
2000 | 0 | msg = " property can't be set on imported targets(\""; |
2001 | 0 | } else if (this->Condition == ReadOnlyCondition::NonImported) { |
2002 | 0 | msg = " property can't be set on non-imported targets(\""; |
2003 | 0 | } |
2004 | 0 | return cmStrCat(prop, msg, target->GetName(), "\")\n"); |
2005 | 0 | } |
2006 | | |
2007 | | bool isReadOnly(std::string const& prop, cmMakefile* context, |
2008 | | cmTarget* target) const |
2009 | 0 | { |
2010 | 0 | auto importedTarget = target->IsImported(); |
2011 | 0 | bool matchingCondition = true; |
2012 | 0 | if ((!importedTarget && this->Condition == ReadOnlyCondition::Imported) || |
2013 | 0 | (importedTarget && |
2014 | 0 | this->Condition == ReadOnlyCondition::NonImported)) { |
2015 | 0 | matchingCondition = false; |
2016 | 0 | } |
2017 | 0 | if (!matchingCondition) { |
2018 | | // Not read-only in this scenario |
2019 | 0 | return false; |
2020 | 0 | } |
2021 | | |
2022 | 0 | bool readOnly = true; |
2023 | 0 | if (!this->Policy) { |
2024 | | // No policy associated, so is always read-only |
2025 | 0 | context->IssueMessage(MessageType::FATAL_ERROR, |
2026 | 0 | this->message(prop, target)); |
2027 | 0 | } else { |
2028 | 0 | switch (target->GetPolicyStatus(*this->Policy)) { |
2029 | 0 | case cmPolicies::WARN: |
2030 | 0 | context->IssueMessage( |
2031 | 0 | MessageType::AUTHOR_WARNING, |
2032 | 0 | cmPolicies::GetPolicyWarning(cmPolicies::CMP0160) + "\n" + |
2033 | 0 | this->message(prop, target)); |
2034 | 0 | CM_FALLTHROUGH; |
2035 | 0 | case cmPolicies::OLD: |
2036 | 0 | readOnly = false; |
2037 | 0 | break; |
2038 | 0 | case cmPolicies::NEW: |
2039 | 0 | context->IssueMessage(MessageType::FATAL_ERROR, |
2040 | 0 | this->message(prop, target)); |
2041 | 0 | break; |
2042 | 0 | } |
2043 | 0 | } |
2044 | 0 | return readOnly; |
2045 | 0 | } |
2046 | | }; |
2047 | | |
2048 | | bool IsSettableProperty(cmMakefile* context, cmTarget* target, |
2049 | | std::string const& prop) |
2050 | 0 | { |
2051 | 0 | using ROC = ReadOnlyCondition; |
2052 | 0 | static std::unordered_map<std::string, ReadOnlyProperty> const readOnlyProps{ |
2053 | 0 | { "EXPORT_NAME", { ROC::Imported } }, |
2054 | 0 | { "HEADER_SETS", { ROC::All } }, |
2055 | 0 | { "IMPORTED_GLOBAL", { ROC::NonImported } }, |
2056 | 0 | { "INTERFACE_HEADER_SETS", { ROC::All } }, |
2057 | 0 | { "MANUALLY_ADDED_DEPENDENCIES", { ROC::All } }, |
2058 | 0 | { "NAME", { ROC::All } }, |
2059 | 0 | { "SOURCES", { ROC::Imported } }, |
2060 | 0 | { "SYMBOLIC", { ROC::All } }, |
2061 | 0 | { "TYPE", { ROC::All } }, |
2062 | 0 | { "ALIAS_GLOBAL", { ROC::All, cmPolicies::CMP0160 } }, |
2063 | 0 | { "BINARY_DIR", { ROC::All, cmPolicies::CMP0160 } }, |
2064 | 0 | { "CXX_MODULE_SETS", { ROC::All, cmPolicies::CMP0160 } }, |
2065 | 0 | { "IMPORTED", { ROC::All, cmPolicies::CMP0160 } }, |
2066 | 0 | { "INTERFACE_CXX_MODULE_SETS", { ROC::All, cmPolicies::CMP0160 } }, |
2067 | 0 | { "LOCATION", { ROC::All, cmPolicies::CMP0160 } }, |
2068 | 0 | { "LOCATION_CONFIG", { ROC::All, cmPolicies::CMP0160 } }, |
2069 | 0 | { "SOURCE_DIR", { ROC::All, cmPolicies::CMP0160 } } |
2070 | 0 | }; |
2071 | |
|
2072 | 0 | auto it = readOnlyProps.find(prop); |
2073 | |
|
2074 | 0 | if (it != readOnlyProps.end()) { |
2075 | 0 | return !(it->second.isReadOnly(prop, context, target)); |
2076 | 0 | } |
2077 | 0 | return true; |
2078 | 0 | } |
2079 | | } |
2080 | | |
2081 | | void cmTarget::SetSymbolic(bool const value) |
2082 | 0 | { |
2083 | 0 | this->impl->IsSymbolic = value; |
2084 | 0 | } |
2085 | | |
2086 | | void cmTarget::SetProperty(std::string const& prop, cmValue value) |
2087 | 0 | { |
2088 | 0 | if (!IsSettableProperty(this->impl->Makefile, this, prop)) { |
2089 | 0 | return; |
2090 | 0 | } |
2091 | | |
2092 | 0 | UsageRequirementProperty* usageRequirements[] = { |
2093 | 0 | &this->impl->IncludeDirectories, |
2094 | 0 | &this->impl->CompileOptions, |
2095 | 0 | &this->impl->CompileFeatures, |
2096 | 0 | &this->impl->CompileDefinitions, |
2097 | 0 | &this->impl->PrecompileHeaders, |
2098 | 0 | &this->impl->Sources, |
2099 | 0 | &this->impl->LinkOptions, |
2100 | 0 | &this->impl->LinkDirectories, |
2101 | 0 | &this->impl->LinkLibraries, |
2102 | 0 | &this->impl->InterfaceLinkLibraries, |
2103 | 0 | &this->impl->InterfaceLinkLibrariesDirect, |
2104 | 0 | &this->impl->InterfaceLinkLibrariesDirectExclude, |
2105 | 0 | &this->impl->ImportedCxxModulesIncludeDirectories, |
2106 | 0 | &this->impl->ImportedCxxModulesCompileDefinitions, |
2107 | 0 | &this->impl->ImportedCxxModulesCompileFeatures, |
2108 | 0 | &this->impl->ImportedCxxModulesCompileOptions, |
2109 | 0 | &this->impl->ImportedCxxModulesLinkLibraries, |
2110 | 0 | }; |
2111 | |
|
2112 | 0 | for (auto* usageRequirement : usageRequirements) { |
2113 | 0 | if (usageRequirement->Write(this->impl.get(), {}, prop, value, |
2114 | 0 | UsageRequirementProperty::Action::Set)) { |
2115 | 0 | return; |
2116 | 0 | } |
2117 | 0 | } |
2118 | | |
2119 | 0 | FileSetType* fileSetTypes[] = { |
2120 | 0 | &this->impl->HeadersFileSets, |
2121 | 0 | &this->impl->CxxModulesFileSets, |
2122 | 0 | }; |
2123 | |
|
2124 | 0 | for (auto* fileSetType : fileSetTypes) { |
2125 | 0 | if (fileSetType->WriteProperties(this, this->impl.get(), prop, value, |
2126 | 0 | FileSetType::Action::Set)) { |
2127 | 0 | return; |
2128 | 0 | } |
2129 | 0 | } |
2130 | | |
2131 | 0 | if (prop == propIMPORTED_GLOBAL) { |
2132 | 0 | if (!value.IsOn()) { |
2133 | 0 | std::ostringstream e; |
2134 | 0 | e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\"" |
2135 | 0 | << this->impl->Name << "\")\n"; |
2136 | 0 | this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); |
2137 | 0 | return; |
2138 | 0 | } |
2139 | | /* no need to change anything if value does not change */ |
2140 | 0 | if (!this->IsImportedGloballyVisible()) { |
2141 | 0 | this->impl->TargetVisibility = Visibility::ImportedGlobally; |
2142 | 0 | this->GetGlobalGenerator()->IndexTarget(this); |
2143 | 0 | } |
2144 | 0 | } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") && |
2145 | 0 | !this->impl->CheckImportedLibName( |
2146 | 0 | prop, |
2147 | 0 | value ? value |
2148 | 0 | : std::string{})) { // NOLINT(bugprone-branch-clone) |
2149 | | /* error was reported by check method */ |
2150 | 0 | } else if (prop == propCUDA_CUBIN_COMPILATION || |
2151 | 0 | prop == propCUDA_FATBIN_COMPILATION || |
2152 | 0 | prop == propCUDA_OPTIX_COMPILATION || |
2153 | 0 | prop == propCUDA_PTX_COMPILATION) { |
2154 | 0 | auto const& compiler = |
2155 | 0 | this->impl->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID"); |
2156 | 0 | auto const& compilerVersion = |
2157 | 0 | this->impl->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_VERSION"); |
2158 | 0 | if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { |
2159 | 0 | auto e = |
2160 | 0 | cmStrCat(prop, " property can only be applied to OBJECT targets(", |
2161 | 0 | this->impl->Name, ")\n"); |
2162 | 0 | this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); |
2163 | 0 | return; |
2164 | 0 | } |
2165 | 0 | bool const flag_found = |
2166 | 0 | (prop == propCUDA_PTX_COMPILATION && |
2167 | 0 | this->impl->Makefile->GetDefinition("_CMAKE_CUDA_PTX_FLAG")) || |
2168 | 0 | (prop == propCUDA_CUBIN_COMPILATION && |
2169 | 0 | this->impl->Makefile->GetDefinition("_CMAKE_CUDA_CUBIN_FLAG")) || |
2170 | 0 | (prop == propCUDA_FATBIN_COMPILATION && |
2171 | 0 | this->impl->Makefile->GetDefinition("_CMAKE_CUDA_FATBIN_FLAG")) || |
2172 | 0 | (prop == propCUDA_OPTIX_COMPILATION && |
2173 | 0 | this->impl->Makefile->GetDefinition("_CMAKE_CUDA_OPTIX_FLAG")); |
2174 | 0 | if (flag_found) { |
2175 | 0 | this->impl->Properties.SetProperty(prop, value); |
2176 | 0 | } else { |
2177 | 0 | auto e = cmStrCat(prop, " property is not supported by ", compiler, |
2178 | 0 | " compiler version ", compilerVersion, '.'); |
2179 | 0 | this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); |
2180 | 0 | return; |
2181 | 0 | } |
2182 | 0 | } else if (prop == propC_STANDARD || prop == propCXX_STANDARD || |
2183 | 0 | prop == propCUDA_STANDARD || prop == propHIP_STANDARD || |
2184 | 0 | prop == propOBJC_STANDARD || prop == propOBJCXX_STANDARD) { |
2185 | 0 | if (value) { |
2186 | 0 | this->impl->LanguageStandardProperties[prop] = |
2187 | 0 | BTs<std::string>(value, this->impl->Makefile->GetBacktrace()); |
2188 | 0 | } else { |
2189 | 0 | this->impl->LanguageStandardProperties.erase(prop); |
2190 | 0 | } |
2191 | 0 | } else { |
2192 | 0 | this->impl->Properties.SetProperty(prop, value); |
2193 | 0 | } |
2194 | 0 | } |
2195 | | |
2196 | | void cmTarget::AppendProperty(std::string const& prop, |
2197 | | std::string const& value, |
2198 | | cm::optional<cmListFileBacktrace> const& bt, |
2199 | | bool asString) |
2200 | 0 | { |
2201 | 0 | if (!IsSettableProperty(this->impl->Makefile, this, prop)) { |
2202 | 0 | return; |
2203 | 0 | } |
2204 | 0 | if (prop == "IMPORTED_GLOBAL") { |
2205 | 0 | this->impl->Makefile->IssueMessage( |
2206 | 0 | MessageType::FATAL_ERROR, |
2207 | 0 | cmStrCat("IMPORTED_GLOBAL property can't be appended, only set on " |
2208 | 0 | "imported targets (\"", |
2209 | 0 | this->impl->Name, "\")\n")); |
2210 | 0 | } |
2211 | |
|
2212 | 0 | UsageRequirementProperty* usageRequirements[] = { |
2213 | 0 | &this->impl->IncludeDirectories, |
2214 | 0 | &this->impl->CompileOptions, |
2215 | 0 | &this->impl->CompileFeatures, |
2216 | 0 | &this->impl->CompileDefinitions, |
2217 | 0 | &this->impl->PrecompileHeaders, |
2218 | 0 | &this->impl->Sources, |
2219 | 0 | &this->impl->LinkOptions, |
2220 | 0 | &this->impl->LinkDirectories, |
2221 | 0 | &this->impl->LinkLibraries, |
2222 | 0 | &this->impl->InterfaceLinkLibraries, |
2223 | 0 | &this->impl->InterfaceLinkLibrariesDirect, |
2224 | 0 | &this->impl->InterfaceLinkLibrariesDirectExclude, |
2225 | 0 | &this->impl->ImportedCxxModulesIncludeDirectories, |
2226 | 0 | &this->impl->ImportedCxxModulesCompileDefinitions, |
2227 | 0 | &this->impl->ImportedCxxModulesCompileFeatures, |
2228 | 0 | &this->impl->ImportedCxxModulesCompileOptions, |
2229 | 0 | &this->impl->ImportedCxxModulesLinkLibraries, |
2230 | 0 | }; |
2231 | |
|
2232 | 0 | for (auto* usageRequirement : usageRequirements) { |
2233 | 0 | if (usageRequirement->Write(this->impl.get(), bt, prop, cmValue(value), |
2234 | 0 | UsageRequirementProperty::Action::Append)) { |
2235 | 0 | return; |
2236 | 0 | } |
2237 | 0 | } |
2238 | | |
2239 | 0 | FileSetType* fileSetTypes[] = { |
2240 | 0 | &this->impl->HeadersFileSets, |
2241 | 0 | &this->impl->CxxModulesFileSets, |
2242 | 0 | }; |
2243 | |
|
2244 | 0 | for (auto* fileSetType : fileSetTypes) { |
2245 | 0 | if (fileSetType->WriteProperties(this, this->impl.get(), prop, value, |
2246 | 0 | FileSetType::Action::Append)) { |
2247 | 0 | return; |
2248 | 0 | } |
2249 | 0 | } |
2250 | | |
2251 | 0 | if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) { |
2252 | 0 | this->impl->Makefile->IssueMessage( |
2253 | 0 | MessageType::FATAL_ERROR, prop + " property may not be APPENDed."); |
2254 | 0 | } else if (prop == "C_STANDARD" || prop == "CXX_STANDARD" || |
2255 | 0 | prop == "CUDA_STANDARD" || prop == "HIP_STANDARD" || |
2256 | 0 | prop == "OBJC_STANDARD" || prop == "OBJCXX_STANDARD") { |
2257 | 0 | this->impl->Makefile->IssueMessage( |
2258 | 0 | MessageType::FATAL_ERROR, prop + " property may not be appended."); |
2259 | 0 | } else { |
2260 | 0 | this->impl->Properties.AppendProperty(prop, value, asString); |
2261 | 0 | } |
2262 | 0 | } |
2263 | | |
2264 | | template <typename ValueType> |
2265 | | void cmTargetInternals::AddDirectoryToFileSet(cmTarget* self, |
2266 | | std::string const& fileSetName, |
2267 | | ValueType value, |
2268 | | cm::string_view fileSetType, |
2269 | | cm::string_view description, |
2270 | | FileSetType::Action action) |
2271 | 0 | { |
2272 | 0 | auto* fileSet = self->GetFileSet(fileSetName); |
2273 | 0 | if (!fileSet) { |
2274 | 0 | this->Makefile->IssueMessage( |
2275 | 0 | MessageType::FATAL_ERROR, |
2276 | 0 | cmStrCat(description, "has not yet been created.")); |
2277 | 0 | return; |
2278 | 0 | } |
2279 | 0 | if (fileSet->GetType() != fileSetType) { |
2280 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
2281 | 0 | cmStrCat("File set \"", fileSetName, |
2282 | 0 | "\" is not of type \"", fileSetType, |
2283 | 0 | "\".")); |
2284 | 0 | return; |
2285 | 0 | } |
2286 | 0 | if (action == FileSetType::Action::Set) { |
2287 | 0 | fileSet->ClearDirectoryEntries(); |
2288 | 0 | } |
2289 | 0 | if (cmNonempty(value)) { |
2290 | 0 | fileSet->AddDirectoryEntry( |
2291 | 0 | BT<std::string>(value, this->Makefile->GetBacktrace())); |
2292 | 0 | } |
2293 | 0 | } Unexecuted instantiation: cmTarget.cxx:void cmTargetInternals::AddDirectoryToFileSet<cmValue>(cmTarget*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmValue, std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, (anonymous namespace)::FileSetType::Action) Unexecuted instantiation: cmTarget.cxx:void cmTargetInternals::AddDirectoryToFileSet<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(cmTarget*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, (anonymous namespace)::FileSetType::Action) |
2294 | | |
2295 | | template <typename ValueType> |
2296 | | void cmTargetInternals::AddPathToFileSet(cmTarget* self, |
2297 | | std::string const& fileSetName, |
2298 | | ValueType value, |
2299 | | cm::string_view fileSetType, |
2300 | | cm::string_view description, |
2301 | | FileSetType::Action action) |
2302 | 0 | { |
2303 | 0 | auto* fileSet = self->GetFileSet(fileSetName); |
2304 | 0 | if (!fileSet) { |
2305 | 0 | this->Makefile->IssueMessage( |
2306 | 0 | MessageType::FATAL_ERROR, |
2307 | 0 | cmStrCat(description, "has not yet been created.")); |
2308 | 0 | return; |
2309 | 0 | } |
2310 | 0 | if (fileSet->GetType() != fileSetType) { |
2311 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
2312 | 0 | cmStrCat("File set \"", fileSetName, |
2313 | 0 | "\" is not of type \"", fileSetType, |
2314 | 0 | "\".")); |
2315 | 0 | return; |
2316 | 0 | } |
2317 | 0 | if (action == FileSetType::Action::Set) { |
2318 | 0 | fileSet->ClearFileEntries(); |
2319 | 0 | } |
2320 | 0 | if (cmNonempty(value)) { |
2321 | 0 | fileSet->AddFileEntry( |
2322 | 0 | BT<std::string>(value, this->Makefile->GetBacktrace())); |
2323 | 0 | } |
2324 | 0 | } Unexecuted instantiation: cmTarget.cxx:void cmTargetInternals::AddPathToFileSet<cmValue>(cmTarget*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmValue, std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, (anonymous namespace)::FileSetType::Action) Unexecuted instantiation: cmTarget.cxx:void cmTargetInternals::AddPathToFileSet<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(cmTarget*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, (anonymous namespace)::FileSetType::Action) |
2325 | | |
2326 | | cmValue cmTargetInternals::GetFileSetDirectories( |
2327 | | cmTarget const* self, std::string const& fileSetName, |
2328 | | cm::string_view fileSetType) const |
2329 | 0 | { |
2330 | 0 | auto const* fileSet = self->GetFileSet(fileSetName); |
2331 | 0 | if (!fileSet) { |
2332 | 0 | return nullptr; |
2333 | 0 | } |
2334 | 0 | if (fileSet->GetType() != fileSetType) { |
2335 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
2336 | 0 | cmStrCat("File set \"", fileSetName, |
2337 | 0 | "\" is not of type \"", fileSetType, |
2338 | 0 | "\".")); |
2339 | 0 | return nullptr; |
2340 | 0 | } |
2341 | 0 | static std::string output; |
2342 | 0 | output = cmList::to_string(fileSet->GetDirectoryEntries()); |
2343 | 0 | return cmValue(output); |
2344 | 0 | } |
2345 | | |
2346 | | cmValue cmTargetInternals::GetFileSetPaths(cmTarget const* self, |
2347 | | std::string const& fileSetName, |
2348 | | cm::string_view fileSetType) const |
2349 | 0 | { |
2350 | 0 | auto const* fileSet = self->GetFileSet(fileSetName); |
2351 | 0 | if (!fileSet) { |
2352 | 0 | return nullptr; |
2353 | 0 | } |
2354 | 0 | if (fileSet->GetType() != fileSetType) { |
2355 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
2356 | 0 | cmStrCat("File set \"", fileSetName, |
2357 | 0 | "\" is not of type \"", fileSetType, |
2358 | 0 | "\".")); |
2359 | 0 | return nullptr; |
2360 | 0 | } |
2361 | 0 | static std::string output; |
2362 | 0 | output = cmList::to_string(fileSet->GetFileEntries()); |
2363 | 0 | return cmValue(output); |
2364 | 0 | } |
2365 | | |
2366 | | void cmTarget::AppendBuildInterfaceIncludes() |
2367 | 0 | { |
2368 | 0 | if (this->GetType() != cmStateEnums::SHARED_LIBRARY && |
2369 | 0 | this->GetType() != cmStateEnums::STATIC_LIBRARY && |
2370 | 0 | this->GetType() != cmStateEnums::MODULE_LIBRARY && |
2371 | 0 | this->GetType() != cmStateEnums::INTERFACE_LIBRARY && |
2372 | 0 | !this->IsExecutableWithExports()) { |
2373 | 0 | return; |
2374 | 0 | } |
2375 | 0 | if (this->impl->BuildInterfaceIncludesAppended) { |
2376 | 0 | return; |
2377 | 0 | } |
2378 | 0 | this->impl->BuildInterfaceIncludesAppended = true; |
2379 | |
|
2380 | 0 | if (this->impl->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { |
2381 | 0 | std::string dirs = this->impl->Makefile->GetCurrentBinaryDirectory(); |
2382 | 0 | if (!dirs.empty()) { |
2383 | 0 | dirs += ';'; |
2384 | 0 | } |
2385 | 0 | dirs += this->impl->Makefile->GetCurrentSourceDirectory(); |
2386 | 0 | if (!dirs.empty()) { |
2387 | 0 | this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", |
2388 | 0 | ("$<BUILD_INTERFACE:" + dirs + ">")); |
2389 | 0 | } |
2390 | 0 | } |
2391 | 0 | } |
2392 | | |
2393 | | namespace { |
2394 | | bool CheckLinkLibraryPattern(UsageRequirementProperty const& usage, |
2395 | | cmake* context) |
2396 | 0 | { |
2397 | | // Look for <LINK_LIBRARY:> and </LINK_LIBRARY:> internal tags |
2398 | 0 | static cmsys::RegularExpression linkPattern( |
2399 | 0 | "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)"); |
2400 | |
|
2401 | 0 | bool isValid = true; |
2402 | |
|
2403 | 0 | for (auto const& item : usage.Entries) { |
2404 | 0 | if (!linkPattern.find(item.Value)) { |
2405 | 0 | continue; |
2406 | 0 | } |
2407 | | |
2408 | 0 | isValid = false; |
2409 | | |
2410 | | // Report an error. |
2411 | 0 | context->IssueMessage( |
2412 | 0 | MessageType::FATAL_ERROR, |
2413 | 0 | cmStrCat( |
2414 | 0 | "Property ", usage.Name, " contains the invalid item \"", |
2415 | 0 | linkPattern.match(2), "\". The ", usage.Name, |
2416 | 0 | " property may contain the generator-expression \"$<LINK_", |
2417 | 0 | linkPattern.match(3), |
2418 | 0 | ":...>\" which may be used to specify how the libraries are linked."), |
2419 | 0 | item.Backtrace); |
2420 | 0 | } |
2421 | |
|
2422 | 0 | return isValid; |
2423 | 0 | } |
2424 | | } |
2425 | | |
2426 | | void cmTarget::FinalizeTargetConfiguration(cmBTStringRange compileDefinitions) |
2427 | 0 | { |
2428 | 0 | if (this->GetType() == cmStateEnums::GLOBAL_TARGET) { |
2429 | 0 | return; |
2430 | 0 | } |
2431 | | |
2432 | 0 | if (!CheckLinkLibraryPattern(this->impl->LinkLibraries, |
2433 | 0 | this->GetMakefile()->GetCMakeInstance()) || |
2434 | 0 | !CheckLinkLibraryPattern(this->impl->InterfaceLinkLibraries, |
2435 | 0 | this->GetMakefile()->GetCMakeInstance()) || |
2436 | 0 | !CheckLinkLibraryPattern(this->impl->InterfaceLinkLibrariesDirect, |
2437 | 0 | this->GetMakefile()->GetCMakeInstance())) { |
2438 | 0 | return; |
2439 | 0 | } |
2440 | | |
2441 | 0 | this->AppendBuildInterfaceIncludes(); |
2442 | |
|
2443 | 0 | if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { |
2444 | 0 | return; |
2445 | 0 | } |
2446 | | |
2447 | 0 | for (auto const& def : compileDefinitions) { |
2448 | 0 | this->InsertCompileDefinition(def); |
2449 | 0 | } |
2450 | 0 | } |
2451 | | |
2452 | | void cmTarget::InsertInclude(BT<std::string> const& entry, bool before) |
2453 | 0 | { |
2454 | 0 | this->impl->IncludeDirectories.WriteDirect( |
2455 | 0 | entry, |
2456 | 0 | before ? UsageRequirementProperty::Action::Prepend |
2457 | 0 | : UsageRequirementProperty::Action::Append); |
2458 | 0 | } |
2459 | | |
2460 | | void cmTarget::InsertCompileOption(BT<std::string> const& entry, bool before) |
2461 | 0 | { |
2462 | 0 | this->impl->CompileOptions.WriteDirect( |
2463 | 0 | entry, |
2464 | 0 | before ? UsageRequirementProperty::Action::Prepend |
2465 | 0 | : UsageRequirementProperty::Action::Append); |
2466 | 0 | } |
2467 | | |
2468 | | void cmTarget::InsertCompileDefinition(BT<std::string> const& entry) |
2469 | 0 | { |
2470 | 0 | this->impl->CompileDefinitions.WriteDirect( |
2471 | 0 | entry, UsageRequirementProperty::Action::Append); |
2472 | 0 | } |
2473 | | |
2474 | | void cmTarget::InsertLinkOption(BT<std::string> const& entry, bool before) |
2475 | 0 | { |
2476 | 0 | this->impl->LinkOptions.WriteDirect( |
2477 | 0 | entry, |
2478 | 0 | before ? UsageRequirementProperty::Action::Prepend |
2479 | 0 | : UsageRequirementProperty::Action::Append); |
2480 | 0 | } |
2481 | | |
2482 | | void cmTarget::InsertLinkDirectory(BT<std::string> const& entry, bool before) |
2483 | 0 | { |
2484 | 0 | this->impl->LinkDirectories.WriteDirect( |
2485 | 0 | entry, |
2486 | 0 | before ? UsageRequirementProperty::Action::Prepend |
2487 | 0 | : UsageRequirementProperty::Action::Append); |
2488 | 0 | } |
2489 | | |
2490 | | void cmTarget::InsertPrecompileHeader(BT<std::string> const& entry) |
2491 | 0 | { |
2492 | 0 | this->impl->PrecompileHeaders.WriteDirect( |
2493 | 0 | entry, UsageRequirementProperty::Action::Append); |
2494 | 0 | } |
2495 | | |
2496 | | namespace { |
2497 | | void CheckLINK_INTERFACE_LIBRARIES(std::string const& prop, |
2498 | | std::string const& value, |
2499 | | cmMakefile* context, bool imported) |
2500 | 0 | { |
2501 | | // Support imported and non-imported versions of the property. |
2502 | 0 | char const* base = (imported ? "IMPORTED_LINK_INTERFACE_LIBRARIES" |
2503 | 0 | : "LINK_INTERFACE_LIBRARIES"); |
2504 | | |
2505 | | // Look for link-type keywords in the value. |
2506 | 0 | static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)"); |
2507 | 0 | if (keys.find(value)) { |
2508 | | // Report an error. |
2509 | 0 | std::ostringstream e; |
2510 | 0 | e << "Property " << prop << " may not contain link-type keyword \"" |
2511 | 0 | << keys.match(2) << "\". " |
2512 | 0 | << "The " << base << " property has a per-configuration " |
2513 | 0 | << "version called " << base << "_<CONFIG> which may be " |
2514 | 0 | << "used to specify per-configuration rules."; |
2515 | 0 | if (!imported) { |
2516 | 0 | e << " " |
2517 | 0 | << "Alternatively, an IMPORTED library may be created, configured " |
2518 | 0 | << "with a per-configuration location, and then named in the " |
2519 | 0 | << "property value. " |
2520 | 0 | << "See the add_library command's IMPORTED mode for details." |
2521 | 0 | << "\n" |
2522 | 0 | << "If you have a list of libraries that already contains the " |
2523 | 0 | << "keyword, use the target_link_libraries command with its " |
2524 | 0 | << "LINK_INTERFACE_LIBRARIES mode to set the property. " |
2525 | 0 | << "The command automatically recognizes link-type keywords and sets " |
2526 | 0 | << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " |
2527 | 0 | << "properties accordingly."; |
2528 | 0 | } |
2529 | 0 | context->IssueMessage(MessageType::FATAL_ERROR, e.str()); |
2530 | 0 | } |
2531 | 0 | } |
2532 | | |
2533 | | void CheckINTERFACE_LINK_LIBRARIES(std::string const& value, |
2534 | | cmMakefile* context) |
2535 | 0 | { |
2536 | | // Look for link-type keywords in the value. |
2537 | 0 | static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)"); |
2538 | 0 | if (keys.find(value)) { |
2539 | | // Report an error. |
2540 | 0 | std::ostringstream e; |
2541 | |
|
2542 | 0 | e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type " |
2543 | 0 | "keyword \"" |
2544 | 0 | << keys.match(2) |
2545 | 0 | << "\". The INTERFACE_LINK_LIBRARIES " |
2546 | 0 | "property may contain configuration-sensitive generator-expressions " |
2547 | 0 | "which may be used to specify per-configuration rules."; |
2548 | |
|
2549 | 0 | context->IssueMessage(MessageType::FATAL_ERROR, e.str()); |
2550 | 0 | } |
2551 | 0 | } |
2552 | | |
2553 | | void CheckIMPORTED_GLOBAL(cmTarget const* target, cmMakefile* context) |
2554 | 0 | { |
2555 | 0 | auto const& targets = context->GetOwnedImportedTargets(); |
2556 | 0 | auto it = |
2557 | 0 | std::find_if(targets.begin(), targets.end(), |
2558 | 0 | [&](std::unique_ptr<cmTarget> const& importTarget) -> bool { |
2559 | 0 | return target == importTarget.get(); |
2560 | 0 | }); |
2561 | 0 | if (it == targets.end()) { |
2562 | 0 | std::ostringstream e; |
2563 | 0 | e << "Attempt to promote imported target \"" << target->GetName() |
2564 | 0 | << "\" to global scope (by setting IMPORTED_GLOBAL) " |
2565 | 0 | "which is not built in this directory."; |
2566 | 0 | context->IssueMessage(MessageType::FATAL_ERROR, e.str()); |
2567 | 0 | } |
2568 | 0 | } |
2569 | | } |
2570 | | |
2571 | | void cmTarget::CheckProperty(std::string const& prop, |
2572 | | cmMakefile* context) const |
2573 | 0 | { |
2574 | | // Certain properties need checking. |
2575 | 0 | if (cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) { |
2576 | 0 | if (cmValue value = this->GetProperty(prop)) { |
2577 | 0 | CheckLINK_INTERFACE_LIBRARIES(prop, *value, context, false); |
2578 | 0 | } |
2579 | 0 | } else if (cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) { |
2580 | 0 | if (cmValue value = this->GetProperty(prop)) { |
2581 | 0 | CheckLINK_INTERFACE_LIBRARIES(prop, *value, context, true); |
2582 | 0 | } |
2583 | 0 | } else if (prop == "INTERFACE_LINK_LIBRARIES") { |
2584 | 0 | if (cmValue value = this->GetProperty(prop)) { |
2585 | 0 | CheckINTERFACE_LINK_LIBRARIES(*value, context); |
2586 | 0 | } |
2587 | 0 | } else if (prop == "IMPORTED_GLOBAL") { |
2588 | 0 | if (this->IsImported()) { |
2589 | 0 | CheckIMPORTED_GLOBAL(this, context); |
2590 | 0 | } |
2591 | 0 | } |
2592 | 0 | } |
2593 | | |
2594 | | cmValue cmTarget::GetComputedProperty(std::string const& prop, |
2595 | | cmMakefile& mf) const |
2596 | 0 | { |
2597 | 0 | return cmTargetPropertyComputer::GetProperty(this, prop, mf); |
2598 | 0 | } |
2599 | | |
2600 | | cmValue cmTarget::GetProperty(std::string const& prop) const |
2601 | 0 | { |
2602 | 0 | static std::unordered_set<std::string> const specialProps{ |
2603 | 0 | propC_STANDARD, |
2604 | 0 | propCXX_STANDARD, |
2605 | 0 | propCUDA_STANDARD, |
2606 | 0 | propHIP_STANDARD, |
2607 | 0 | propOBJC_STANDARD, |
2608 | 0 | propOBJCXX_STANDARD, |
2609 | 0 | propLINK_LIBRARIES, |
2610 | 0 | propTYPE, |
2611 | 0 | propINCLUDE_DIRECTORIES, |
2612 | 0 | propCOMPILE_FEATURES, |
2613 | 0 | propCOMPILE_OPTIONS, |
2614 | 0 | propCOMPILE_DEFINITIONS, |
2615 | 0 | propPRECOMPILE_HEADERS, |
2616 | 0 | propLINK_OPTIONS, |
2617 | 0 | propLINK_DIRECTORIES, |
2618 | 0 | propIMPORTED, |
2619 | 0 | propIMPORTED_GLOBAL, |
2620 | 0 | propMANUALLY_ADDED_DEPENDENCIES, |
2621 | 0 | propNAME, |
2622 | 0 | propBINARY_DIR, |
2623 | 0 | propSOURCE_DIR, |
2624 | 0 | propSOURCES, |
2625 | 0 | propSYMBOLIC, |
2626 | 0 | propINTERFACE_LINK_LIBRARIES, |
2627 | 0 | propINTERFACE_LINK_LIBRARIES_DIRECT, |
2628 | 0 | propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE, |
2629 | 0 | propIMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES, |
2630 | 0 | propIMPORTED_CXX_MODULES_COMPILE_DEFINITIONS, |
2631 | 0 | propIMPORTED_CXX_MODULES_COMPILE_FEATURES, |
2632 | 0 | propIMPORTED_CXX_MODULES_COMPILE_OPTIONS, |
2633 | 0 | propIMPORTED_CXX_MODULES_LINK_LIBRARIES, |
2634 | 0 | }; |
2635 | 0 | if (specialProps.count(prop)) { |
2636 | 0 | if (prop == propC_STANDARD || prop == propCXX_STANDARD || |
2637 | 0 | prop == propCUDA_STANDARD || prop == propHIP_STANDARD || |
2638 | 0 | prop == propOBJC_STANDARD || prop == propOBJCXX_STANDARD) { |
2639 | 0 | auto propertyIter = this->impl->LanguageStandardProperties.find(prop); |
2640 | 0 | if (propertyIter == this->impl->LanguageStandardProperties.end()) { |
2641 | 0 | return nullptr; |
2642 | 0 | } |
2643 | 0 | return cmValue(propertyIter->second.Value); |
2644 | 0 | } |
2645 | | |
2646 | 0 | if (prop == propSYMBOLIC) { |
2647 | 0 | return this->IsSymbolic() ? cmValue(propTRUE) : cmValue(propFALSE); |
2648 | 0 | } |
2649 | | |
2650 | 0 | UsageRequirementProperty const* usageRequirements[] = { |
2651 | 0 | &this->impl->IncludeDirectories, |
2652 | 0 | &this->impl->CompileOptions, |
2653 | 0 | &this->impl->CompileFeatures, |
2654 | 0 | &this->impl->CompileDefinitions, |
2655 | 0 | &this->impl->PrecompileHeaders, |
2656 | 0 | &this->impl->Sources, |
2657 | 0 | &this->impl->LinkOptions, |
2658 | 0 | &this->impl->LinkDirectories, |
2659 | 0 | &this->impl->LinkLibraries, |
2660 | 0 | &this->impl->InterfaceLinkLibraries, |
2661 | 0 | &this->impl->InterfaceLinkLibrariesDirect, |
2662 | 0 | &this->impl->InterfaceLinkLibrariesDirectExclude, |
2663 | 0 | &this->impl->ImportedCxxModulesIncludeDirectories, |
2664 | 0 | &this->impl->ImportedCxxModulesCompileDefinitions, |
2665 | 0 | &this->impl->ImportedCxxModulesCompileFeatures, |
2666 | 0 | &this->impl->ImportedCxxModulesCompileOptions, |
2667 | 0 | &this->impl->ImportedCxxModulesLinkLibraries, |
2668 | 0 | }; |
2669 | |
|
2670 | 0 | for (auto const* usageRequirement : usageRequirements) { |
2671 | 0 | auto value = usageRequirement->Read(prop); |
2672 | 0 | if (value.first) { |
2673 | 0 | return value.second; |
2674 | 0 | } |
2675 | 0 | } |
2676 | | |
2677 | | // the type property returns what type the target is |
2678 | 0 | if (prop == propTYPE) { |
2679 | 0 | return cmValue(cmState::GetTargetTypeName(this->GetType())); |
2680 | 0 | } |
2681 | 0 | if (prop == propMANUALLY_ADDED_DEPENDENCIES) { |
2682 | 0 | if (this->impl->Utilities.empty()) { |
2683 | 0 | return nullptr; |
2684 | 0 | } |
2685 | | |
2686 | 0 | static std::string output; |
2687 | 0 | static std::vector<std::string> utilities; |
2688 | 0 | utilities.resize(this->impl->Utilities.size()); |
2689 | 0 | std::transform( |
2690 | 0 | this->impl->Utilities.cbegin(), this->impl->Utilities.cend(), |
2691 | 0 | utilities.begin(), |
2692 | 0 | [](const BT<std::pair<std::string, bool>>& item) -> std::string { |
2693 | 0 | return item.Value.first; |
2694 | 0 | }); |
2695 | 0 | output = cmList::to_string(utilities); |
2696 | 0 | return cmValue(output); |
2697 | 0 | } |
2698 | 0 | if (prop == propIMPORTED) { |
2699 | 0 | return this->IsImported() ? cmValue(propTRUE) : cmValue(propFALSE); |
2700 | 0 | } |
2701 | 0 | if (prop == propIMPORTED_GLOBAL) { |
2702 | 0 | return this->IsImportedGloballyVisible() ? cmValue(propTRUE) |
2703 | 0 | : cmValue(propFALSE); |
2704 | 0 | } |
2705 | 0 | if (prop == propNAME) { |
2706 | 0 | return cmValue(this->GetName()); |
2707 | 0 | } |
2708 | 0 | if (prop == propBINARY_DIR) { |
2709 | 0 | return cmValue(this->impl->Makefile->GetStateSnapshot() |
2710 | 0 | .GetDirectory() |
2711 | 0 | .GetCurrentBinary()); |
2712 | 0 | } |
2713 | 0 | if (prop == propSOURCE_DIR) { |
2714 | 0 | return cmValue(this->impl->Makefile->GetStateSnapshot() |
2715 | 0 | .GetDirectory() |
2716 | 0 | .GetCurrentSource()); |
2717 | 0 | } |
2718 | 0 | } |
2719 | | |
2720 | | // Check fileset properties. |
2721 | 0 | { |
2722 | 0 | FileSetType* fileSetTypes[] = { |
2723 | 0 | &this->impl->HeadersFileSets, |
2724 | 0 | &this->impl->CxxModulesFileSets, |
2725 | 0 | }; |
2726 | |
|
2727 | 0 | for (auto* fileSetType : fileSetTypes) { |
2728 | 0 | auto value = fileSetType->ReadProperties(this, this->impl.get(), prop); |
2729 | 0 | if (value.first) { |
2730 | 0 | return value.second; |
2731 | 0 | } |
2732 | 0 | } |
2733 | 0 | } |
2734 | | |
2735 | 0 | cmValue retVal = this->impl->Properties.GetPropertyValue(prop); |
2736 | 0 | if (!retVal) { |
2737 | 0 | bool const chain = this->impl->Makefile->GetState()->IsPropertyChained( |
2738 | 0 | prop, cmProperty::TARGET); |
2739 | 0 | if (chain) { |
2740 | 0 | return this->impl->Makefile->GetStateSnapshot() |
2741 | 0 | .GetDirectory() |
2742 | 0 | .GetProperty(prop, chain); |
2743 | 0 | } |
2744 | 0 | return nullptr; |
2745 | 0 | } |
2746 | 0 | return retVal; |
2747 | 0 | } |
2748 | | |
2749 | | std::string const& cmTarget::GetSafeProperty(std::string const& prop) const |
2750 | 0 | { |
2751 | 0 | cmValue ret = this->GetProperty(prop); |
2752 | 0 | if (ret) { |
2753 | 0 | return *ret; |
2754 | 0 | } |
2755 | | |
2756 | 0 | static std::string const s_empty; |
2757 | 0 | return s_empty; |
2758 | 0 | } |
2759 | | |
2760 | | bool cmTarget::GetPropertyAsBool(std::string const& prop) const |
2761 | 0 | { |
2762 | 0 | return this->GetProperty(prop).IsOn(); |
2763 | 0 | } |
2764 | | |
2765 | | cmPropertyMap const& cmTarget::GetProperties() const |
2766 | 0 | { |
2767 | 0 | return this->impl->Properties; |
2768 | 0 | } |
2769 | | |
2770 | | bool cmTarget::IsDLLPlatform() const |
2771 | 0 | { |
2772 | 0 | return this->impl->IsDLLPlatform; |
2773 | 0 | } |
2774 | | |
2775 | | bool cmTarget::IsAIX() const |
2776 | 0 | { |
2777 | 0 | return this->impl->IsAIX; |
2778 | 0 | } |
2779 | | bool cmTarget::IsApple() const |
2780 | 0 | { |
2781 | 0 | return this->impl->IsApple; |
2782 | 0 | } |
2783 | | |
2784 | | bool cmTarget::IsSymbolic() const |
2785 | 0 | { |
2786 | 0 | return this->impl->IsSymbolic; |
2787 | 0 | } |
2788 | | |
2789 | | bool cmTarget::IsNormal() const |
2790 | 0 | { |
2791 | 0 | switch (this->impl->TargetVisibility) { |
2792 | 0 | case Visibility::Normal: |
2793 | 0 | return true; |
2794 | 0 | case Visibility::Generated: |
2795 | 0 | case Visibility::Imported: |
2796 | 0 | case Visibility::ImportedGlobally: |
2797 | 0 | case Visibility::Foreign: |
2798 | 0 | return false; |
2799 | 0 | } |
2800 | 0 | assert(false && "unknown visibility (IsNormal)"); |
2801 | 0 | return false; |
2802 | 0 | } |
2803 | | |
2804 | | bool cmTarget::IsSynthetic() const |
2805 | 0 | { |
2806 | 0 | switch (this->impl->TargetVisibility) { |
2807 | 0 | case Visibility::Generated: |
2808 | 0 | return true; |
2809 | 0 | case Visibility::Normal: |
2810 | 0 | case Visibility::Imported: |
2811 | 0 | case Visibility::ImportedGlobally: |
2812 | 0 | case Visibility::Foreign: |
2813 | 0 | return false; |
2814 | 0 | } |
2815 | 0 | assert(false && "unknown visibility (IsSynthetic)"); |
2816 | 0 | return false; |
2817 | 0 | } |
2818 | | |
2819 | | bool cmTargetInternals::IsImported() const |
2820 | 0 | { |
2821 | 0 | switch (this->TargetVisibility) { |
2822 | 0 | case cmTarget::Visibility::Imported: |
2823 | 0 | case cmTarget::Visibility::ImportedGlobally: |
2824 | 0 | case cmTarget::Visibility::Foreign: |
2825 | 0 | return true; |
2826 | 0 | case cmTarget::Visibility::Normal: |
2827 | 0 | case cmTarget::Visibility::Generated: |
2828 | 0 | return false; |
2829 | 0 | } |
2830 | 0 | assert(false && "unknown visibility (IsImported)"); |
2831 | 0 | return false; |
2832 | 0 | } |
2833 | | |
2834 | | bool cmTarget::IsImported() const |
2835 | 0 | { |
2836 | 0 | return this->impl->IsImported(); |
2837 | 0 | } |
2838 | | |
2839 | | bool cmTarget::IsImportedGloballyVisible() const |
2840 | 0 | { |
2841 | 0 | switch (this->impl->TargetVisibility) { |
2842 | 0 | case Visibility::ImportedGlobally: |
2843 | 0 | return true; |
2844 | 0 | case Visibility::Normal: |
2845 | 0 | case Visibility::Generated: |
2846 | 0 | case Visibility::Imported: |
2847 | 0 | case Visibility::Foreign: |
2848 | 0 | return false; |
2849 | 0 | } |
2850 | 0 | assert(false && "unknown visibility (IsImportedGloballyVisible)"); |
2851 | 0 | return false; |
2852 | 0 | } |
2853 | | |
2854 | | bool cmTarget::IsForeign() const |
2855 | 0 | { |
2856 | 0 | switch (this->impl->TargetVisibility) { |
2857 | 0 | case Visibility::Foreign: |
2858 | 0 | return true; |
2859 | 0 | case Visibility::Normal: |
2860 | 0 | case Visibility::Generated: |
2861 | 0 | case Visibility::Imported: |
2862 | 0 | case Visibility::ImportedGlobally: |
2863 | 0 | return false; |
2864 | 0 | } |
2865 | 0 | assert(false && "unknown visibility (isForeign)"); |
2866 | 0 | return false; |
2867 | 0 | } |
2868 | | |
2869 | | bool cmTarget::IsPerConfig() const |
2870 | 0 | { |
2871 | 0 | return this->impl->PerConfig; |
2872 | 0 | } |
2873 | | |
2874 | | bool cmTarget::IsRuntimeBinary() const |
2875 | 0 | { |
2876 | 0 | switch (this->GetType()) { |
2877 | 0 | case cmStateEnums::EXECUTABLE: |
2878 | 0 | case cmStateEnums::SHARED_LIBRARY: |
2879 | 0 | case cmStateEnums::MODULE_LIBRARY: |
2880 | 0 | return true; |
2881 | 0 | case cmStateEnums::OBJECT_LIBRARY: |
2882 | 0 | case cmStateEnums::STATIC_LIBRARY: |
2883 | 0 | case cmStateEnums::UTILITY: |
2884 | 0 | case cmStateEnums::INTERFACE_LIBRARY: |
2885 | 0 | case cmStateEnums::GLOBAL_TARGET: |
2886 | 0 | case cmStateEnums::UNKNOWN_LIBRARY: |
2887 | 0 | break; |
2888 | 0 | } |
2889 | 0 | return false; |
2890 | 0 | } |
2891 | | |
2892 | | bool cmTarget::CanCompileSources() const |
2893 | 0 | { |
2894 | 0 | if (this->IsImported()) { |
2895 | 0 | return false; |
2896 | 0 | } |
2897 | 0 | if (this->IsSynthetic()) { |
2898 | 0 | return true; |
2899 | 0 | } |
2900 | 0 | switch (this->GetType()) { |
2901 | 0 | case cmStateEnums::EXECUTABLE: |
2902 | 0 | case cmStateEnums::STATIC_LIBRARY: |
2903 | 0 | case cmStateEnums::SHARED_LIBRARY: |
2904 | 0 | case cmStateEnums::MODULE_LIBRARY: |
2905 | 0 | case cmStateEnums::OBJECT_LIBRARY: |
2906 | 0 | return true; |
2907 | 0 | case cmStateEnums::UTILITY: |
2908 | 0 | case cmStateEnums::INTERFACE_LIBRARY: |
2909 | 0 | case cmStateEnums::GLOBAL_TARGET: |
2910 | 0 | case cmStateEnums::UNKNOWN_LIBRARY: |
2911 | 0 | break; |
2912 | 0 | } |
2913 | 0 | return false; |
2914 | 0 | } |
2915 | | |
2916 | | void cmTarget::SetIsForTryCompile() |
2917 | 0 | { |
2918 | 0 | this->impl->IsForTryCompile = true; |
2919 | 0 | } |
2920 | | |
2921 | | bool cmTarget::IsForTryCompile() const |
2922 | 0 | { |
2923 | 0 | return this->impl->IsForTryCompile; |
2924 | 0 | } |
2925 | | |
2926 | | char const* cmTarget::GetSuffixVariableInternal( |
2927 | | cmStateEnums::ArtifactType artifact) const |
2928 | 0 | { |
2929 | 0 | switch (this->GetType()) { |
2930 | 0 | case cmStateEnums::STATIC_LIBRARY: |
2931 | 0 | return "CMAKE_STATIC_LIBRARY_SUFFIX"; |
2932 | 0 | case cmStateEnums::SHARED_LIBRARY: |
2933 | 0 | switch (artifact) { |
2934 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2935 | 0 | return this->IsArchivedAIXSharedLibrary() |
2936 | 0 | ? "CMAKE_SHARED_LIBRARY_ARCHIVE_SUFFIX" |
2937 | 0 | : "CMAKE_SHARED_LIBRARY_SUFFIX"; |
2938 | 0 | case cmStateEnums::ImportLibraryArtifact: |
2939 | 0 | return this->IsApple() ? "CMAKE_APPLE_IMPORT_FILE_SUFFIX" |
2940 | 0 | : "CMAKE_IMPORT_LIBRARY_SUFFIX"; |
2941 | 0 | } |
2942 | 0 | break; |
2943 | 0 | case cmStateEnums::MODULE_LIBRARY: |
2944 | 0 | switch (artifact) { |
2945 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2946 | 0 | return "CMAKE_SHARED_MODULE_SUFFIX"; |
2947 | 0 | case cmStateEnums::ImportLibraryArtifact: |
2948 | 0 | return "CMAKE_IMPORT_LIBRARY_SUFFIX"; |
2949 | 0 | } |
2950 | 0 | break; |
2951 | 0 | case cmStateEnums::EXECUTABLE: |
2952 | 0 | switch (artifact) { |
2953 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2954 | | // Android GUI application packages store the native |
2955 | | // binary as a shared library. |
2956 | 0 | return (this->IsAndroidGuiExecutable() |
2957 | 0 | ? "CMAKE_SHARED_LIBRARY_SUFFIX" |
2958 | 0 | : "CMAKE_EXECUTABLE_SUFFIX"); |
2959 | 0 | case cmStateEnums::ImportLibraryArtifact: |
2960 | 0 | return (this->impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_SUFFIX" |
2961 | 0 | : "CMAKE_IMPORT_LIBRARY_SUFFIX"); |
2962 | 0 | } |
2963 | 0 | break; |
2964 | 0 | default: |
2965 | 0 | break; |
2966 | 0 | } |
2967 | 0 | return ""; |
2968 | 0 | } |
2969 | | |
2970 | | char const* cmTarget::GetPrefixVariableInternal( |
2971 | | cmStateEnums::ArtifactType artifact) const |
2972 | 0 | { |
2973 | 0 | switch (this->GetType()) { |
2974 | 0 | case cmStateEnums::STATIC_LIBRARY: |
2975 | 0 | return "CMAKE_STATIC_LIBRARY_PREFIX"; |
2976 | 0 | case cmStateEnums::SHARED_LIBRARY: |
2977 | 0 | switch (artifact) { |
2978 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2979 | 0 | return "CMAKE_SHARED_LIBRARY_PREFIX"; |
2980 | 0 | case cmStateEnums::ImportLibraryArtifact: |
2981 | 0 | return this->IsApple() ? "CMAKE_APPLE_IMPORT_FILE_PREFIX" |
2982 | 0 | : "CMAKE_IMPORT_LIBRARY_PREFIX"; |
2983 | 0 | } |
2984 | 0 | break; |
2985 | 0 | case cmStateEnums::MODULE_LIBRARY: |
2986 | 0 | switch (artifact) { |
2987 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2988 | 0 | return "CMAKE_SHARED_MODULE_PREFIX"; |
2989 | 0 | case cmStateEnums::ImportLibraryArtifact: |
2990 | 0 | return "CMAKE_IMPORT_LIBRARY_PREFIX"; |
2991 | 0 | } |
2992 | 0 | break; |
2993 | 0 | case cmStateEnums::EXECUTABLE: |
2994 | 0 | switch (artifact) { |
2995 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
2996 | | // Android GUI application packages store the native |
2997 | | // binary as a shared library. |
2998 | 0 | return (this->IsAndroidGuiExecutable() |
2999 | 0 | ? "CMAKE_SHARED_LIBRARY_PREFIX" |
3000 | 0 | : ""); |
3001 | 0 | case cmStateEnums::ImportLibraryArtifact: |
3002 | 0 | return (this->impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_PREFIX" |
3003 | 0 | : "CMAKE_IMPORT_LIBRARY_PREFIX"); |
3004 | 0 | } |
3005 | 0 | break; |
3006 | 0 | default: |
3007 | 0 | break; |
3008 | 0 | } |
3009 | 0 | return ""; |
3010 | 0 | } |
3011 | | |
3012 | | std::string cmTarget::ImportedGetFullPath( |
3013 | | std::string const& config, cmStateEnums::ArtifactType artifact, |
3014 | | ImportArtifactMissingOk missingOk) const |
3015 | 0 | { |
3016 | 0 | assert(this->IsImported()); |
3017 | | |
3018 | | // Lookup/compute/cache the import information for this |
3019 | | // configuration. |
3020 | 0 | std::string desired_config = config; |
3021 | 0 | if (config.empty()) { |
3022 | 0 | desired_config = "NOCONFIG"; |
3023 | 0 | } |
3024 | |
|
3025 | 0 | std::string result; |
3026 | |
|
3027 | 0 | cmValue loc = nullptr; |
3028 | 0 | cmValue imp = nullptr; |
3029 | 0 | std::string suffix; |
3030 | |
|
3031 | 0 | if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && |
3032 | 0 | this->GetMappedConfig(desired_config, loc, imp, suffix)) { |
3033 | 0 | switch (artifact) { |
3034 | 0 | case cmStateEnums::RuntimeBinaryArtifact: |
3035 | 0 | if (loc) { |
3036 | 0 | result = *loc; |
3037 | 0 | } else if (imp) { |
3038 | 0 | result = *imp; |
3039 | 0 | } else { |
3040 | 0 | std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix); |
3041 | 0 | if (cmValue config_location = this->GetProperty(impProp)) { |
3042 | 0 | result = *config_location; |
3043 | 0 | } else if (cmValue location = |
3044 | 0 | this->GetProperty("IMPORTED_LOCATION")) { |
3045 | 0 | result = *location; |
3046 | 0 | } |
3047 | 0 | if (result.empty() && |
3048 | 0 | (this->GetType() == cmStateEnums::SHARED_LIBRARY || |
3049 | 0 | this->IsExecutableWithExports())) { |
3050 | 0 | impProp = cmStrCat("IMPORTED_IMPLIB", suffix); |
3051 | 0 | if (cmValue config_implib = this->GetProperty(impProp)) { |
3052 | 0 | result = *config_implib; |
3053 | 0 | } else if (cmValue implib = this->GetProperty("IMPORTED_IMPLIB")) { |
3054 | 0 | result = *implib; |
3055 | 0 | } |
3056 | 0 | } |
3057 | 0 | } |
3058 | 0 | if (this->IsApple() && |
3059 | 0 | (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY || |
3060 | 0 | this->impl->TargetType == cmStateEnums::STATIC_LIBRARY || |
3061 | 0 | this->impl->TargetType == cmStateEnums::UNKNOWN_LIBRARY) && |
3062 | 0 | cmSystemTools::IsPathToXcFramework(result)) { |
3063 | 0 | auto plist = cmParseXcFrameworkPlist(result, *this->impl->Makefile, |
3064 | 0 | this->impl->Backtrace); |
3065 | 0 | if (!plist) { |
3066 | 0 | return ""; |
3067 | 0 | } |
3068 | 0 | auto const* library = plist->SelectSuitableLibrary( |
3069 | 0 | *this->impl->Makefile, this->impl->Backtrace); |
3070 | 0 | if (library) { |
3071 | 0 | result = cmStrCat(result, '/', library->LibraryIdentifier, '/', |
3072 | 0 | library->LibraryPath); |
3073 | 0 | } else { |
3074 | 0 | return ""; |
3075 | 0 | } |
3076 | 0 | } |
3077 | 0 | break; |
3078 | | |
3079 | 0 | case cmStateEnums::ImportLibraryArtifact: |
3080 | 0 | if (imp) { |
3081 | 0 | result = *imp; |
3082 | 0 | } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || |
3083 | 0 | this->IsExecutableWithExports()) { |
3084 | 0 | std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix); |
3085 | 0 | if (cmValue config_implib = this->GetProperty(impProp)) { |
3086 | 0 | result = *config_implib; |
3087 | 0 | } else if (cmValue implib = this->GetProperty("IMPORTED_IMPLIB")) { |
3088 | 0 | result = *implib; |
3089 | 0 | } |
3090 | 0 | } |
3091 | 0 | break; |
3092 | 0 | } |
3093 | 0 | } |
3094 | | |
3095 | 0 | if (result.empty() && missingOk != ImportArtifactMissingOk::Yes) { |
3096 | 0 | if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { |
3097 | 0 | auto message = [&]() -> std::string { |
3098 | 0 | std::string unset; |
3099 | 0 | std::string configuration; |
3100 | |
|
3101 | 0 | if (this->GetType() == cmStateEnums::SHARED_LIBRARY && |
3102 | 0 | artifact == cmStateEnums::RuntimeBinaryArtifact) { |
3103 | 0 | unset = "IMPORTED_LOCATION or IMPORTED_IMPLIB"; |
3104 | 0 | } else if (artifact == cmStateEnums::RuntimeBinaryArtifact) { |
3105 | 0 | unset = "IMPORTED_LOCATION"; |
3106 | 0 | } else if (artifact == cmStateEnums::ImportLibraryArtifact) { |
3107 | 0 | unset = "IMPORTED_IMPLIB"; |
3108 | 0 | } |
3109 | |
|
3110 | 0 | if (!config.empty()) { |
3111 | 0 | configuration = cmStrCat(" configuration \"", config, '"'); |
3112 | 0 | } |
3113 | |
|
3114 | 0 | return cmStrCat(unset, " not set for imported target \"", |
3115 | 0 | this->GetName(), '"', configuration, '.'); |
3116 | 0 | }; |
3117 | |
|
3118 | 0 | switch (this->GetPolicyStatus(cmPolicies::CMP0111)) { |
3119 | 0 | case cmPolicies::WARN: |
3120 | 0 | this->impl->Makefile->IssueMessage( |
3121 | 0 | MessageType::AUTHOR_WARNING, |
3122 | 0 | cmPolicies::GetPolicyWarning(cmPolicies::CMP0111) + "\n" + |
3123 | 0 | message()); |
3124 | 0 | CM_FALLTHROUGH; |
3125 | 0 | case cmPolicies::OLD: |
3126 | 0 | break; |
3127 | 0 | default: |
3128 | 0 | this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
3129 | 0 | message()); |
3130 | 0 | } |
3131 | 0 | } |
3132 | | |
3133 | 0 | result = cmStrCat(this->GetName(), "-NOTFOUND"); |
3134 | 0 | } |
3135 | 0 | return result; |
3136 | 0 | } |
3137 | | |
3138 | | cmFileSet const* cmTarget::GetFileSet(std::string const& name) const |
3139 | 0 | { |
3140 | 0 | auto it = this->impl->FileSets.find(name); |
3141 | 0 | return it == this->impl->FileSets.end() ? nullptr : &it->second; |
3142 | 0 | } |
3143 | | |
3144 | | cmFileSet* cmTarget::GetFileSet(std::string const& name) |
3145 | 0 | { |
3146 | 0 | auto it = this->impl->FileSets.find(name); |
3147 | 0 | return it == this->impl->FileSets.end() ? nullptr : &it->second; |
3148 | 0 | } |
3149 | | |
3150 | | std::pair<cmFileSet*, bool> cmTarget::GetOrCreateFileSet( |
3151 | | std::string const& name, std::string const& type, cmFileSetVisibility vis) |
3152 | 0 | { |
3153 | 0 | auto result = this->impl->FileSets.emplace( |
3154 | 0 | name, cmFileSet(this->GetMakefile(), name, type, vis)); |
3155 | 0 | if (result.second) { |
3156 | 0 | auto bt = this->impl->Makefile->GetBacktrace(); |
3157 | 0 | if (type == this->impl->HeadersFileSets.TypeName) { |
3158 | 0 | this->impl->HeadersFileSets.AddFileSet(name, vis, std::move(bt)); |
3159 | 0 | } else if (type == this->impl->CxxModulesFileSets.TypeName) { |
3160 | 0 | this->impl->CxxModulesFileSets.AddFileSet(name, vis, std::move(bt)); |
3161 | 0 | } |
3162 | 0 | } |
3163 | 0 | return std::make_pair(&result.first->second, result.second); |
3164 | 0 | } |
3165 | | |
3166 | | std::string cmTarget::GetFileSetsPropertyName(std::string const& type) |
3167 | 0 | { |
3168 | 0 | if (type == "HEADERS") { |
3169 | 0 | return "HEADER_SETS"; |
3170 | 0 | } |
3171 | 0 | if (type == "CXX_MODULES") { |
3172 | 0 | return "CXX_MODULE_SETS"; |
3173 | 0 | } |
3174 | 0 | return ""; |
3175 | 0 | } |
3176 | | |
3177 | | std::string cmTarget::GetInterfaceFileSetsPropertyName(std::string const& type) |
3178 | 0 | { |
3179 | 0 | if (type == "HEADERS") { |
3180 | 0 | return "INTERFACE_HEADER_SETS"; |
3181 | 0 | } |
3182 | 0 | if (type == "CXX_MODULES") { |
3183 | 0 | return "INTERFACE_CXX_MODULE_SETS"; |
3184 | 0 | } |
3185 | 0 | return ""; |
3186 | 0 | } |
3187 | | |
3188 | | std::vector<std::string> cmTarget::GetAllFileSetNames() const |
3189 | 0 | { |
3190 | 0 | std::vector<std::string> result; |
3191 | |
|
3192 | 0 | for (auto const& it : this->impl->FileSets) { |
3193 | 0 | result.push_back(it.first); |
3194 | 0 | } |
3195 | |
|
3196 | 0 | return result; |
3197 | 0 | } |
3198 | | |
3199 | | std::vector<std::string> cmTarget::GetAllInterfaceFileSets() const |
3200 | 0 | { |
3201 | 0 | std::vector<std::string> result; |
3202 | 0 | auto inserter = std::back_inserter(result); |
3203 | |
|
3204 | 0 | auto appendEntries = [=](std::vector<BT<std::string>> const& entries) { |
3205 | 0 | for (auto const& entry : entries) { |
3206 | 0 | cmList expanded{ entry.Value }; |
3207 | 0 | std::copy(expanded.begin(), expanded.end(), inserter); |
3208 | 0 | } |
3209 | 0 | }; |
3210 | |
|
3211 | 0 | appendEntries(this->impl->HeadersFileSets.InterfaceEntries.Entries); |
3212 | 0 | appendEntries(this->impl->CxxModulesFileSets.InterfaceEntries.Entries); |
3213 | |
|
3214 | 0 | return result; |
3215 | 0 | } |
3216 | | |
3217 | | bool cmTarget::HasFileSets() const |
3218 | 0 | { |
3219 | 0 | return !this->impl->FileSets.empty(); |
3220 | 0 | } |
3221 | | |
3222 | | bool cmTargetInternals::CheckImportedLibName(std::string const& prop, |
3223 | | std::string const& value) const |
3224 | 0 | { |
3225 | 0 | if (this->TargetType != cmStateEnums::INTERFACE_LIBRARY || |
3226 | 0 | !this->IsImported()) { |
3227 | 0 | this->Makefile->IssueMessage( |
3228 | 0 | MessageType::FATAL_ERROR, |
3229 | 0 | prop + |
3230 | 0 | " property may be set only on imported INTERFACE library targets."); |
3231 | 0 | return false; |
3232 | 0 | } |
3233 | 0 | if (!value.empty()) { |
3234 | 0 | if (value[0] == '-') { |
3235 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
3236 | 0 | prop + " property value\n " + value + |
3237 | 0 | "\nmay not start with '-'."); |
3238 | 0 | return false; |
3239 | 0 | } |
3240 | 0 | std::string::size_type bad = value.find_first_of(":/\\;"); |
3241 | 0 | if (bad != std::string::npos) { |
3242 | 0 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, |
3243 | 0 | prop + " property value\n " + value + |
3244 | 0 | "\nmay not contain '" + |
3245 | 0 | value.substr(bad, 1) + "'."); |
3246 | 0 | return false; |
3247 | 0 | } |
3248 | 0 | } |
3249 | 0 | return true; |
3250 | 0 | } |
3251 | | |
3252 | | bool cmTarget::GetMappedConfig(std::string const& desiredConfig, cmValue& loc, |
3253 | | cmValue& imp, std::string& suffix) const |
3254 | 0 | { |
3255 | 0 | switch (this->GetPolicyStatusCMP0200()) { |
3256 | 0 | case cmPolicies::WARN: |
3257 | 0 | if (this->GetMakefile()->PolicyOptionalWarningEnabled( |
3258 | 0 | "CMAKE_POLICY_WARNING_CMP0200")) { |
3259 | 0 | break; |
3260 | 0 | } |
3261 | 0 | CM_FALLTHROUGH; |
3262 | 0 | case cmPolicies::OLD: |
3263 | 0 | return this->GetMappedConfigOld(desiredConfig, loc, imp, suffix); |
3264 | 0 | case cmPolicies::NEW: |
3265 | 0 | return this->GetMappedConfigNew(desiredConfig, loc, imp, suffix); |
3266 | 0 | } |
3267 | | |
3268 | 0 | cmValue newLoc; |
3269 | 0 | cmValue newImp; |
3270 | 0 | std::string newSuffix; |
3271 | |
|
3272 | 0 | bool const newResult = |
3273 | 0 | this->GetMappedConfigNew(desiredConfig, newLoc, newImp, newSuffix); |
3274 | |
|
3275 | 0 | auto configFromSuffix = [](cm::string_view s) -> cm::string_view { |
3276 | 0 | return s.empty() ? "(none)"_s : s.substr(1); |
3277 | 0 | }; |
3278 | |
|
3279 | 0 | if (!this->GetMappedConfigOld(desiredConfig, loc, imp, suffix)) { |
3280 | 0 | if (newResult) { |
3281 | | // NEW policy found a configuration, OLD did not. |
3282 | 0 | cm::string_view newConfig = configFromSuffix(newSuffix); |
3283 | 0 | std::string const err = cmStrCat( |
3284 | 0 | cmPolicies::GetPolicyWarning(cmPolicies::CMP0200), |
3285 | 0 | "\nConfiguration selection for imported target \"", this->GetName(), |
3286 | 0 | "\" failed, but would select configuration \"", newConfig, |
3287 | 0 | "\" under the NEW policy.\n"); |
3288 | 0 | this->GetMakefile()->IssueMessage(MessageType::AUTHOR_WARNING, err); |
3289 | 0 | } |
3290 | |
|
3291 | 0 | return false; |
3292 | 0 | } |
3293 | | |
3294 | 0 | cm::string_view oldConfig = configFromSuffix(suffix); |
3295 | 0 | if (!newResult) { |
3296 | | // NEW policy did not find a configuration, OLD did. |
3297 | 0 | std::string const err = |
3298 | 0 | cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0200), |
3299 | 0 | "\nConfiguration selection for imported target \"", |
3300 | 0 | this->GetName(), "\" selected configuration \"", oldConfig, |
3301 | 0 | "\", but would fail under the NEW policy.\n"); |
3302 | 0 | this->GetMakefile()->IssueMessage(MessageType::AUTHOR_WARNING, err); |
3303 | 0 | } else if (suffix != newSuffix) { |
3304 | | // OLD and NEW policies found different configurations. |
3305 | 0 | cm::string_view newConfig = configFromSuffix(newSuffix); |
3306 | 0 | std::string const err = |
3307 | 0 | cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0200), |
3308 | 0 | "\nConfiguration selection for imported target \"", |
3309 | 0 | this->GetName(), "\" selected configuration \"", oldConfig, |
3310 | 0 | "\", but would select configuration \"", newConfig, |
3311 | 0 | "\" under the NEW policy.\n"); |
3312 | 0 | this->GetMakefile()->IssueMessage(MessageType::AUTHOR_WARNING, err); |
3313 | 0 | } |
3314 | |
|
3315 | 0 | return true; |
3316 | 0 | } |
3317 | | |
3318 | | bool cmTarget::GetMappedConfigOld(std::string const& desired_config, |
3319 | | cmValue& loc, cmValue& imp, |
3320 | | std::string& suffix) const |
3321 | 0 | { |
3322 | 0 | std::string config_upper; |
3323 | 0 | if (!desired_config.empty()) { |
3324 | 0 | config_upper = cmSystemTools::UpperCase(desired_config); |
3325 | 0 | } |
3326 | |
|
3327 | 0 | std::string locPropBase; |
3328 | 0 | if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { |
3329 | 0 | locPropBase = "IMPORTED_LIBNAME"; |
3330 | 0 | } else if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) { |
3331 | 0 | locPropBase = "IMPORTED_OBJECTS"; |
3332 | 0 | } else { |
3333 | 0 | locPropBase = "IMPORTED_LOCATION"; |
3334 | 0 | } |
3335 | | |
3336 | | // Track the configuration-specific property suffix. |
3337 | 0 | suffix = cmStrCat('_', config_upper); |
3338 | |
|
3339 | 0 | cmList mappedConfigs; |
3340 | 0 | { |
3341 | 0 | std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", config_upper); |
3342 | 0 | if (cmValue mapValue = this->GetProperty(mapProp)) { |
3343 | 0 | mappedConfigs.assign(*mapValue, cmList::EmptyElements::Yes); |
3344 | 0 | } |
3345 | 0 | } |
3346 | | |
3347 | | // If we needed to find one of the mapped configurations but did not |
3348 | | // There may be only IMPORTED_IMPLIB for a shared library or an executable |
3349 | | // with exports. |
3350 | 0 | bool allowImp = (this->GetType() == cmStateEnums::SHARED_LIBRARY || |
3351 | 0 | this->IsExecutableWithExports()) || |
3352 | 0 | (this->IsAIX() && this->IsExecutableWithExports()) || |
3353 | 0 | (this->GetMakefile()->PlatformSupportsAppleTextStubs() && |
3354 | 0 | this->IsSharedLibraryWithExports()); |
3355 | | |
3356 | | // If a mapping was found, check its configurations. |
3357 | 0 | for (auto mci = mappedConfigs.begin(); |
3358 | 0 | !loc && !imp && mci != mappedConfigs.end(); ++mci) { |
3359 | | // Look for this configuration. |
3360 | 0 | if (mci->empty()) { |
3361 | | // An empty string in the mapping has a special meaning: |
3362 | | // look up the config-less properties. |
3363 | 0 | loc = this->GetProperty(locPropBase); |
3364 | 0 | if (allowImp) { |
3365 | 0 | imp = this->GetProperty("IMPORTED_IMPLIB"); |
3366 | 0 | } |
3367 | | // If it was found, set the suffix. |
3368 | 0 | if (loc || imp) { |
3369 | 0 | suffix.clear(); |
3370 | 0 | } |
3371 | 0 | } else { |
3372 | 0 | std::string mcUpper = cmSystemTools::UpperCase(*mci); |
3373 | 0 | std::string locProp = cmStrCat(locPropBase, '_', mcUpper); |
3374 | 0 | loc = this->GetProperty(locProp); |
3375 | 0 | if (allowImp) { |
3376 | 0 | std::string impProp = cmStrCat("IMPORTED_IMPLIB_", mcUpper); |
3377 | 0 | imp = this->GetProperty(impProp); |
3378 | 0 | } |
3379 | | |
3380 | | // If it was found, use it for all properties below. |
3381 | 0 | if (loc || imp) { |
3382 | 0 | suffix = cmStrCat('_', mcUpper); |
3383 | 0 | } |
3384 | 0 | } |
3385 | 0 | } |
3386 | | |
3387 | | // If we needed to find one of the mapped configurations but did not |
3388 | | // then the target location is not found. The project does not want |
3389 | | // any other configuration. |
3390 | 0 | if (!mappedConfigs.empty() && !loc && !imp) { |
3391 | | // Interface libraries are always available because their |
3392 | | // library name is optional so it is okay to leave loc empty. |
3393 | 0 | return this->GetType() == cmStateEnums::INTERFACE_LIBRARY; |
3394 | 0 | } |
3395 | | |
3396 | | // If we have not yet found it then there are no mapped |
3397 | | // configurations. Look for an exact-match. |
3398 | 0 | if (!loc && !imp) { |
3399 | 0 | std::string locProp = cmStrCat(locPropBase, suffix); |
3400 | 0 | loc = this->GetProperty(locProp); |
3401 | 0 | if (allowImp) { |
3402 | 0 | std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix); |
3403 | 0 | imp = this->GetProperty(impProp); |
3404 | 0 | } |
3405 | 0 | } |
3406 | | |
3407 | | // If we have not yet found it then there are no mapped |
3408 | | // configurations and no exact match. |
3409 | 0 | if (!loc && !imp) { |
3410 | | // The suffix computed above is not useful. |
3411 | 0 | suffix.clear(); |
3412 | | |
3413 | | // Look for a configuration-less location. This may be set by |
3414 | | // manually-written code. |
3415 | 0 | loc = this->GetProperty(locPropBase); |
3416 | 0 | if (allowImp) { |
3417 | 0 | imp = this->GetProperty("IMPORTED_IMPLIB"); |
3418 | 0 | } |
3419 | 0 | } |
3420 | | |
3421 | | // If we have not yet found it then the project is willing to try |
3422 | | // any available configuration. |
3423 | 0 | if (!loc && !imp) { |
3424 | 0 | cmList availableConfigs; |
3425 | 0 | if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { |
3426 | 0 | availableConfigs.assign(*iconfigs); |
3427 | 0 | } |
3428 | 0 | for (auto it = availableConfigs.begin(); |
3429 | 0 | !loc && !imp && it != availableConfigs.end(); ++it) { |
3430 | 0 | suffix = cmStrCat('_', cmSystemTools::UpperCase(*it)); |
3431 | 0 | std::string locProp = cmStrCat(locPropBase, suffix); |
3432 | 0 | loc = this->GetProperty(locProp); |
3433 | 0 | if (allowImp) { |
3434 | 0 | std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix); |
3435 | 0 | imp = this->GetProperty(impProp); |
3436 | 0 | } |
3437 | 0 | } |
3438 | 0 | } |
3439 | | // If we have not yet found it then the target location is not available. |
3440 | 0 | if (!loc && !imp) { |
3441 | | // Interface libraries are always available because their |
3442 | | // library name is optional so it is okay to leave loc empty. |
3443 | 0 | return this->GetType() == cmStateEnums::INTERFACE_LIBRARY; |
3444 | 0 | } |
3445 | | |
3446 | 0 | return true; |
3447 | 0 | } |
3448 | | |
3449 | | cmValue cmTarget::GetLocation(std::string const& base, |
3450 | | std::string const& suffix) const |
3451 | 0 | { |
3452 | 0 | cmValue value = this->GetProperty(cmStrCat(base, suffix)); |
3453 | 0 | if (value || suffix.empty()) { |
3454 | 0 | return value; |
3455 | 0 | } |
3456 | 0 | return this->GetProperty(base); |
3457 | 0 | } |
3458 | | |
3459 | | bool cmTarget::GetLocation(std::string const& config, cmValue& loc, |
3460 | | cmValue& imp, std::string& suffix) const |
3461 | 0 | { |
3462 | 0 | suffix = (config.empty() ? std::string{} : cmStrCat('_', config)); |
3463 | | |
3464 | | // There may be only IMPORTED_IMPLIB for a shared library or an executable |
3465 | | // with exports. |
3466 | 0 | bool const allowImp = (this->GetType() == cmStateEnums::SHARED_LIBRARY || |
3467 | 0 | this->IsExecutableWithExports()) || |
3468 | 0 | (this->IsAIX() && this->IsExecutableWithExports()) || |
3469 | 0 | (this->GetMakefile()->PlatformSupportsAppleTextStubs() && |
3470 | 0 | this->IsSharedLibraryWithExports()); |
3471 | |
|
3472 | 0 | if (allowImp) { |
3473 | 0 | imp = this->GetLocation("IMPORTED_IMPLIB", suffix); |
3474 | 0 | } |
3475 | |
|
3476 | 0 | switch (this->GetType()) { |
3477 | 0 | case cmStateEnums::INTERFACE_LIBRARY: |
3478 | 0 | loc = this->GetLocation("IMPORTED_LIBNAME", suffix); |
3479 | 0 | break; |
3480 | 0 | case cmStateEnums::OBJECT_LIBRARY: |
3481 | 0 | loc = this->GetLocation("IMPORTED_OBJECTS", suffix); |
3482 | 0 | break; |
3483 | 0 | default: |
3484 | 0 | loc = this->GetLocation("IMPORTED_LOCATION", suffix); |
3485 | 0 | break; |
3486 | 0 | } |
3487 | | |
3488 | 0 | return loc || imp || (this->GetType() == cmStateEnums::INTERFACE_LIBRARY); |
3489 | 0 | } |
3490 | | |
3491 | | bool cmTarget::GetMappedConfigNew(std::string desiredConfig, cmValue& loc, |
3492 | | cmValue& imp, std::string& suffix) const |
3493 | 0 | { |
3494 | 0 | desiredConfig = cmSystemTools::UpperCase(desiredConfig); |
3495 | | |
3496 | | // Get configuration mapping, if present. |
3497 | 0 | cmList mappedConfigs; |
3498 | 0 | if (!desiredConfig.empty()) { |
3499 | 0 | std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", desiredConfig); |
3500 | 0 | if (cmValue mapValue = this->GetProperty(mapProp)) { |
3501 | 0 | mappedConfigs.assign(cmSystemTools::UpperCase(*mapValue), |
3502 | 0 | cmList::EmptyElements::Yes); |
3503 | 0 | } |
3504 | 0 | } |
3505 | | |
3506 | | // Get imported configurations, if specified. |
3507 | 0 | if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { |
3508 | 0 | cmList const availableConfigs{ cmSystemTools::UpperCase(*iconfigs) }; |
3509 | |
|
3510 | 0 | if (!mappedConfigs.empty()) { |
3511 | 0 | for (auto const& c : mappedConfigs) { |
3512 | 0 | if (cm::contains(availableConfigs, c)) { |
3513 | 0 | this->GetLocation(c, loc, imp, suffix); |
3514 | 0 | return true; |
3515 | 0 | } |
3516 | 0 | } |
3517 | | |
3518 | | // If a configuration mapping was specified, but no matching |
3519 | | // configuration was found, we don't want to try anything else. |
3520 | 0 | return false; |
3521 | 0 | } |
3522 | | |
3523 | | // There is no mapping; try the requested configuration first. |
3524 | 0 | if (cm::contains(availableConfigs, desiredConfig)) { |
3525 | 0 | this->GetLocation(desiredConfig, loc, imp, suffix); |
3526 | 0 | return true; |
3527 | 0 | } |
3528 | | |
3529 | | // If there is no mapping and the requested configuration is not one of |
3530 | | // the available configurations, just take the first available |
3531 | | // configuration. |
3532 | 0 | this->GetLocation(availableConfigs[0], loc, imp, suffix); |
3533 | 0 | return true; |
3534 | 0 | } |
3535 | | |
3536 | 0 | if (!mappedConfigs.empty()) { |
3537 | 0 | for (auto const& c : mappedConfigs) { |
3538 | 0 | if (this->GetLocation(c, loc, imp, suffix)) { |
3539 | 0 | return true; |
3540 | 0 | } |
3541 | 0 | } |
3542 | | |
3543 | | // If a configuration mapping was specified, but no matching |
3544 | | // configuration was found, we don't want to try anything else. |
3545 | 0 | return false; |
3546 | 0 | } |
3547 | | |
3548 | | // There is no mapping and no explicit list of configurations; the only |
3549 | | // configuration left to try is the requested configuration. |
3550 | 0 | if (this->GetLocation(desiredConfig, loc, imp, suffix)) { |
3551 | 0 | return true; |
3552 | 0 | } |
3553 | | |
3554 | 0 | return false; |
3555 | 0 | } |