/src/CMake/Source/cmGeneratorTarget.h
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 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <cstddef> |
8 | | #include <functional> |
9 | | #include <map> |
10 | | #include <memory> |
11 | | #include <set> |
12 | | #include <string> |
13 | | #include <unordered_map> |
14 | | #include <unordered_set> |
15 | | #include <utility> |
16 | | #include <vector> |
17 | | |
18 | | #include <cm/optional> |
19 | | #include <cm/string_view> |
20 | | |
21 | | #include "cmAlgorithms.h" |
22 | | #include "cmCxxModuleUsageEffects.h" |
23 | | #include "cmLinkItem.h" |
24 | | #include "cmList.h" |
25 | | #include "cmListFileCache.h" |
26 | | #include "cmObjectLocation.h" |
27 | | #include "cmPolicies.h" |
28 | | #include "cmSourceFile.h" |
29 | | #include "cmStandardLevel.h" |
30 | | #include "cmStateTypes.h" |
31 | | #include "cmTargetPropertyEntry.h" |
32 | | #include "cmTargetTypes.h" |
33 | | #include "cmValue.h" |
34 | | |
35 | | namespace cm { |
36 | | namespace GenEx { |
37 | | struct Context; |
38 | | struct Evaluation; |
39 | | } |
40 | | } |
41 | | |
42 | | enum class cmBuildStep; |
43 | | class cmComputeLinkInformation; |
44 | | class cmCustomCommand; |
45 | | class cmGeneratorFileSets; |
46 | | class cmGeneratorFileSet; |
47 | | class cmGlobalGenerator; |
48 | | class cmLocalGenerator; |
49 | | class cmMakefile; |
50 | | class cmTarget; |
51 | | |
52 | | struct cmGeneratorExpressionDAGChecker; |
53 | | |
54 | | class cmGeneratorTarget |
55 | | { |
56 | | public: |
57 | | using TargetPropertyEntry = cm::TargetPropertyEntry; |
58 | | |
59 | | cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); |
60 | | ~cmGeneratorTarget(); |
61 | | |
62 | | cmGeneratorTarget(cmGeneratorTarget const&) = delete; |
63 | | cmGeneratorTarget& operator=(cmGeneratorTarget const&) = delete; |
64 | | |
65 | | cmLocalGenerator* GetLocalGenerator() const; |
66 | | |
67 | | cmGlobalGenerator* GetGlobalGenerator() const; |
68 | | |
69 | | bool IsInBuildSystem() const; |
70 | | bool IsNormal() const; |
71 | | bool IsRuntimeBinary() const; |
72 | | bool IsSynthetic() const; |
73 | | bool IsImported() const; |
74 | | bool IsImportedGloballyVisible() const; |
75 | | bool IsForeign() const; |
76 | | bool IsSymbolic() const; |
77 | | bool CanCompileSources() const; |
78 | | bool HasKnownRuntimeArtifactLocation(std::string const& config) const; |
79 | | std::string const& GetLocation(std::string const& config) const; |
80 | | |
81 | | /** Get the full path to the target's main artifact, if known. */ |
82 | | cm::optional<std::string> MaybeGetLocation(std::string const& config) const; |
83 | | |
84 | | std::vector<cmCustomCommand> const& GetPreBuildCommands() const; |
85 | | std::vector<cmCustomCommand> const& GetPreLinkCommands() const; |
86 | | std::vector<cmCustomCommand> const& GetPostBuildCommands() const; |
87 | | |
88 | | void AppendCustomCommandSideEffects( |
89 | | std::set<cmGeneratorTarget const*>& sideEffects) const; |
90 | | void AppendLanguageSideEffects( |
91 | | std::map<std::string, std::set<cmGeneratorTarget const*>>& sideEffects) |
92 | | const; |
93 | | |
94 | | #define DECLARE_TARGET_POLICY(POLICY) \ |
95 | | cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const \ |
96 | 121k | { \ |
97 | 121k | return this->PolicyMap.Get(cmPolicies::POLICY); \ |
98 | 121k | } Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0003() const cmGeneratorTarget::GetPolicyStatusCMP0004() const Line | Count | Source | 96 | 2 | { \ | 97 | 2 | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 2 | } |
Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0008() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0020() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0021() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0022() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0027() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0037() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0038() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0041() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0042() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0046() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0052() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0060() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0063() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0065() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0068() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0069() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0073() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0076() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0081() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0083() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0095() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0099() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0104() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0105() const cmGeneratorTarget::GetPolicyStatusCMP0108() const Line | Count | Source | 96 | 110k | { \ | 97 | 110k | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 110k | } |
cmGeneratorTarget::GetPolicyStatusCMP0112() const Line | Count | Source | 96 | 1.37k | { \ | 97 | 1.37k | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 1.37k | } |
Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0113() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0119() const cmGeneratorTarget::GetPolicyStatusCMP0131() const Line | Count | Source | 96 | 6.31k | { \ | 97 | 6.31k | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 6.31k | } |
Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0142() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0154() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0155() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0156() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0157() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0160() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0162() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0179() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0181() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0182() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0195() const cmGeneratorTarget::GetPolicyStatusCMP0199() const Line | Count | Source | 96 | 8 | { \ | 97 | 8 | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 8 | } |
Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0200() const cmGeneratorTarget::GetPolicyStatusCMP0202() const Line | Count | Source | 96 | 3.26k | { \ | 97 | 3.26k | return this->PolicyMap.Get(cmPolicies::POLICY); \ | 98 | 3.26k | } |
Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0203() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0204() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0209() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0210() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0211() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0214() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0215() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0216() const Unexecuted instantiation: cmGeneratorTarget::GetPolicyStatusCMP0226() const |
99 | | |
100 | | CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) |
101 | | |
102 | | #undef DECLARE_TARGET_POLICY |
103 | | |
104 | | /** Get the location of the target in the build tree with a placeholder |
105 | | referencing the configuration in the native build system. This |
106 | | location is suitable for use as the LOCATION target property. */ |
107 | | std::string const& GetLocationForBuild() const; |
108 | | |
109 | | cmComputeLinkInformation* GetLinkInformation( |
110 | | std::string const& config) const; |
111 | | |
112 | | // Perform validation checks on memoized link structures. |
113 | | // Call this after generation is complete. |
114 | | void CheckLinkLibraries() const; |
115 | | |
116 | | class CheckLinkLibrariesSuppressionRAII |
117 | | { |
118 | | public: |
119 | | CheckLinkLibrariesSuppressionRAII(); |
120 | | ~CheckLinkLibrariesSuppressionRAII(); |
121 | | }; |
122 | | |
123 | | cm::TargetType GetType() const; |
124 | | std::string const& GetName() const; |
125 | | std::string GetFamilyName() const; |
126 | | std::string GetExportName() const; |
127 | | std::string GetFilesystemExportName() const; |
128 | | |
129 | | std::vector<std::string> GetPropertyKeys() const; |
130 | | //! Might return a nullptr if the property is not set or invalid |
131 | | cmValue GetProperty(std::string const& prop) const; |
132 | | //! Always returns a valid pointer |
133 | | std::string const& GetSafeProperty(std::string const& prop) const; |
134 | | bool GetPropertyAsBool(std::string const& prop) const; |
135 | | void GetSourceFiles(std::vector<cmSourceFile*>& files, |
136 | | std::string const& config) const; |
137 | | std::vector<BT<cmSourceFile*>> GetSourceFiles( |
138 | | std::string const& config) const; |
139 | | std::string GetSourceFileLanguage(cmSourceFile const* source, |
140 | | std::string const& config) const; |
141 | | |
142 | | /** Source file kinds (classifications). |
143 | | Generators use this to decide how to treat a source file. */ |
144 | | enum SourceKind |
145 | | { |
146 | | SourceKindAppManifest, |
147 | | SourceKindCertificate, |
148 | | SourceKindCustomCommand, |
149 | | SourceKindExternalObject, |
150 | | SourceKindCxxModuleSource, |
151 | | SourceKindRustMainCrateRoot, |
152 | | SourceKindExtra, |
153 | | SourceKindHeader, |
154 | | SourceKindIDL, |
155 | | SourceKindManifest, |
156 | | SourceKindModuleDefinition, |
157 | | SourceKindObjectSource, |
158 | | SourceKindResx, |
159 | | SourceKindXaml, |
160 | | SourceKindUnityBatched |
161 | | }; |
162 | | |
163 | | /** A source file paired with a kind (classification). */ |
164 | | struct SourceAndKind |
165 | | { |
166 | | BT<cmSourceFile*> Source; |
167 | | SourceKind Kind; |
168 | | }; |
169 | | |
170 | | /** All sources needed for a configuration with kinds assigned. */ |
171 | | struct KindedSources |
172 | | { |
173 | | std::vector<SourceAndKind> Sources; |
174 | | bool Initialized = false; |
175 | | }; |
176 | | |
177 | | /** Get all sources needed for a configuration with kinds assigned. */ |
178 | | KindedSources const& GetKindedSources(std::string const& config) const; |
179 | | |
180 | | struct AllConfigSource |
181 | | { |
182 | | cmSourceFile* Source; |
183 | | cmGeneratorTarget::SourceKind Kind; |
184 | | std::vector<size_t> Configs; |
185 | | }; |
186 | | |
187 | | /** Get all sources needed for all configurations with kinds and |
188 | | per-source configurations assigned. */ |
189 | | std::vector<AllConfigSource> const& GetAllConfigSources() const; |
190 | | |
191 | | /** Get all sources needed for all configurations with given kind. */ |
192 | | std::vector<AllConfigSource> GetAllConfigSources(SourceKind kind) const; |
193 | | |
194 | | /** Get all languages used to compile sources in any configuration. |
195 | | This excludes the languages of objects from object libraries. */ |
196 | | std::set<std::string> GetAllConfigCompileLanguages() const; |
197 | | |
198 | | void GetObjectSources(std::vector<cmSourceFile const*>&, |
199 | | std::string const& config) const; |
200 | | std::string const& GetObjectName(cmSourceFile const* file) const; |
201 | | char const* GetCustomObjectExtension() const; |
202 | | |
203 | | bool HasExplicitObjectName(cmSourceFile const* file) const; |
204 | | void AddExplicitObjectName(cmSourceFile const* sf); |
205 | | |
206 | | BTs<std::string> const* GetLanguageStandardProperty( |
207 | | std::string const& lang, std::string const& config) const; |
208 | | |
209 | | cmValue GetLanguageStandard(std::string const& lang, |
210 | | std::string const& config) const; |
211 | | |
212 | | cmValue GetLanguageExtensions(std::string const& lang) const; |
213 | | |
214 | | bool GetLanguageStandardRequired(std::string const& lang) const; |
215 | | |
216 | | enum class SYCLExtensionMode |
217 | | { |
218 | | Append, |
219 | | Replace |
220 | | }; |
221 | | |
222 | | SYCLExtensionMode GetSYCLExtensionMode() const; |
223 | | bool IsSYCLAppendMode(std::string const& lang) const; |
224 | | void GetModuleDefinitionSources(std::vector<cmSourceFile const*>&, |
225 | | std::string const& config) const; |
226 | | void GetExternalObjects(std::vector<cmSourceFile const*>&, |
227 | | std::string const& config) const; |
228 | | void GetHeaderSources(std::vector<cmSourceFile const*>&, |
229 | | std::string const& config) const; |
230 | | void GetCxxModuleSources(std::vector<cmSourceFile const*>&, |
231 | | std::string const& config) const; |
232 | | void GetExtraSources(std::vector<cmSourceFile const*>&, |
233 | | std::string const& config) const; |
234 | | void GetCustomCommands(std::vector<cmSourceFile const*>&, |
235 | | std::string const& config) const; |
236 | | void GetManifests(std::vector<cmSourceFile const*>&, |
237 | | std::string const& config) const; |
238 | | |
239 | | void GetRustMainCrateRoot(std::vector<cmSourceFile const*>&, |
240 | | std::string const& config) const; |
241 | | |
242 | | cmSourceFile const* GetRustMainCrateRoot(std::string const& config) const; |
243 | | |
244 | | std::set<cmLinkItem> const& GetUtilityItems() const; |
245 | | |
246 | | void ComputeObjectMapping() const; |
247 | | |
248 | | cmValue GetFeature(std::string const& feature, |
249 | | std::string const& config) const; |
250 | | |
251 | | std::string GetLinkerTypeProperty(std::string const& lang, |
252 | | std::string const& config) const; |
253 | | |
254 | | char const* GetLinkPIEProperty(std::string const& config) const; |
255 | | |
256 | | bool IsIPOEnabled(std::string const& lang, std::string const& config) const; |
257 | | |
258 | | bool IsLinkInterfaceDependentBoolProperty(std::string const& p, |
259 | | std::string const& config) const; |
260 | | bool IsLinkInterfaceDependentStringProperty(std::string const& p, |
261 | | std::string const& config) const; |
262 | | bool IsLinkInterfaceDependentNumberMinProperty( |
263 | | std::string const& p, std::string const& config) const; |
264 | | bool IsLinkInterfaceDependentNumberMaxProperty( |
265 | | std::string const& p, std::string const& config) const; |
266 | | |
267 | | bool GetLinkInterfaceDependentBoolProperty(std::string const& p, |
268 | | std::string const& config) const; |
269 | | |
270 | | char const* GetLinkInterfaceDependentStringProperty( |
271 | | std::string const& p, std::string const& config) const; |
272 | | char const* GetLinkInterfaceDependentNumberMinProperty( |
273 | | std::string const& p, std::string const& config) const; |
274 | | char const* GetLinkInterfaceDependentNumberMaxProperty( |
275 | | std::string const& p, std::string const& config) const; |
276 | | |
277 | | class DeviceLinkSetter |
278 | | { |
279 | | public: |
280 | | DeviceLinkSetter(cmGeneratorTarget& target) |
281 | 0 | : Target(target) |
282 | 0 | { |
283 | 0 | this->PreviousState = target.SetDeviceLink(true); |
284 | 0 | } |
285 | 0 | ~DeviceLinkSetter() { this->Target.SetDeviceLink(this->PreviousState); } |
286 | | |
287 | | private: |
288 | | cmGeneratorTarget& Target; |
289 | | bool PreviousState; |
290 | | }; |
291 | | |
292 | | bool SetDeviceLink(bool deviceLink); |
293 | 0 | bool IsDeviceLink() const { return this->DeviceLink; } |
294 | | |
295 | | cmLinkInterface const* GetLinkInterface( |
296 | | std::string const& config, cmGeneratorTarget const* headTarget) const; |
297 | | |
298 | | enum class UseTo |
299 | | { |
300 | | Compile, // Usage requirements for compiling. Excludes $<LINK_ONLY>. |
301 | | Link, // Usage requirements for linking. Includes $<LINK_ONLY>. |
302 | | }; |
303 | | |
304 | | cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries( |
305 | | std::string const& config, cmGeneratorTarget const* headTarget, |
306 | | UseTo usage) const; |
307 | | |
308 | | void ComputeLinkInterfaceLibraries(std::string const& config, |
309 | | cmOptionalLinkInterface& iface, |
310 | | cmGeneratorTarget const* head, |
311 | | UseTo usage) const; |
312 | | |
313 | | /** Get the library name for an imported interface library. */ |
314 | | std::string GetImportedLibName(std::string const& config) const; |
315 | | |
316 | | /** Get the full path to the target according to the settings in its |
317 | | makefile and the configuration type. */ |
318 | | std::string GetFullPath( |
319 | | std::string const& config, |
320 | | cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact, |
321 | | bool realname = false) const; |
322 | | std::string NormalGetFullPath(std::string const& config, |
323 | | cmStateEnums::ArtifactType artifact, |
324 | | bool realname) const; |
325 | | std::string NormalGetRealName(std::string const& config, |
326 | | cmStateEnums::ArtifactType artifact = |
327 | | cmStateEnums::RuntimeBinaryArtifact) const; |
328 | | |
329 | | /** Get the names of an object library's object files underneath |
330 | | its object file directory for the build. */ |
331 | | void GetTargetObjectNames(std::string const& config, |
332 | | std::vector<std::string>& objects) const; |
333 | | void GetTargetObjectNames(std::string const& config, |
334 | | std::function<bool(cmSourceFile const&)> filter, |
335 | | std::vector<std::string>& objects) const; |
336 | | /** Get the build and install locations of objects for a given context. */ |
337 | | void GetTargetObjectLocations( |
338 | | std::string const& config, |
339 | | std::function<void(cmObjectLocation const&, cmObjectLocation const&)> cb) |
340 | | const; |
341 | | void GetTargetObjectLocations( |
342 | | std::string const& config, std::function<bool(cmSourceFile const&)> filter, |
343 | | std::function<void(cmObjectLocation const&, cmObjectLocation const&)> cb) |
344 | | const; |
345 | | |
346 | | /** What hierarchy level should the reported directory contain */ |
347 | | enum BundleDirectoryLevel |
348 | | { |
349 | | BundleDirLevel, |
350 | | ContentLevel, |
351 | | FullLevel |
352 | | }; |
353 | | |
354 | | /** @return the Mac App directory without the base */ |
355 | | std::string GetAppBundleDirectory(std::string const& config, |
356 | | BundleDirectoryLevel level) const; |
357 | | |
358 | | /** Return whether this target is marked as deprecated by the |
359 | | maintainer */ |
360 | | bool IsDeprecated() const; |
361 | | |
362 | | /** Returns the deprecation message provided by the maintainer */ |
363 | | std::string GetDeprecation() const; |
364 | | |
365 | | /** Return whether this target is an executable Bundle, a framework |
366 | | or CFBundle on Apple. */ |
367 | | bool IsBundleOnApple() const; |
368 | | |
369 | | /** Return whether this target is a Win32 executable */ |
370 | | bool IsWin32Executable(std::string const& config) const; |
371 | | |
372 | | /** Get the full name of the target according to the settings in its |
373 | | makefile. */ |
374 | | std::string GetFullName(std::string const& config, |
375 | | cmStateEnums::ArtifactType artifact = |
376 | | cmStateEnums::RuntimeBinaryArtifact) const; |
377 | | |
378 | | /** @return the Mac framework directory without the base. */ |
379 | | std::string GetFrameworkDirectory(std::string const& config, |
380 | | BundleDirectoryLevel level) const; |
381 | | |
382 | | /** Return the framework version string. Undefined if |
383 | | IsFrameworkOnApple returns false. */ |
384 | | std::string GetFrameworkVersion() const; |
385 | | |
386 | | /** @return the Mac CFBundle directory without the base */ |
387 | | std::string GetCFBundleDirectory(std::string const& config, |
388 | | BundleDirectoryLevel level) const; |
389 | | |
390 | | /** Return the install name directory for the target in the |
391 | | * build tree. For example: "\@rpath/", "\@loader_path/", |
392 | | * or "/full/path/to/library". */ |
393 | | std::string GetInstallNameDirForBuildTree(std::string const& config) const; |
394 | | |
395 | | /** Return the install name directory for the target in the |
396 | | * install tree. For example: "\@rpath/" or "\@loader_path/". */ |
397 | | std::string GetInstallNameDirForInstallTree( |
398 | | std::string const& config, std::string const& installPrefix) const; |
399 | | |
400 | | cmListFileBacktrace GetBacktrace() const; |
401 | | |
402 | | std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const; |
403 | | |
404 | | bool LinkLanguagePropagatesToDependents() const |
405 | 4.00k | { |
406 | 4.00k | return this->GetType() == cm::TargetType::STATIC_LIBRARY; |
407 | 4.00k | } |
408 | | |
409 | | /** Get the macro to define when building sources in this target. |
410 | | If no macro should be defined null is returned. */ |
411 | | std::string const* GetExportMacro() const; |
412 | | |
413 | | /** Get the list of preprocessor definitions, that should be defined |
414 | | when building sources in this target. |
415 | | If no macro should be defined the empty list is returned. */ |
416 | | cmList const& GetSharedLibraryCompileDefs(std::string const& config) const; |
417 | | |
418 | | /** Get the soname of the target. Allowed only for a shared library. */ |
419 | | std::string GetSOName(std::string const& config, |
420 | | cmStateEnums::ArtifactType artifact = |
421 | | cmStateEnums::RuntimeBinaryArtifact) const; |
422 | | |
423 | | struct NameComponents |
424 | | { |
425 | | std::string prefix; |
426 | | std::string base; |
427 | | std::string suffix; |
428 | | }; |
429 | | NameComponents const& GetFullNameComponents( |
430 | | std::string const& config, |
431 | | cmStateEnums::ArtifactType artifact = |
432 | | cmStateEnums::RuntimeBinaryArtifact) const; |
433 | | |
434 | | /** Append to @a base the bundle directory hierarchy up to a certain @a level |
435 | | * and return it. */ |
436 | | std::string BuildBundleDirectory(std::string const& base, |
437 | | std::string const& config, |
438 | | BundleDirectoryLevel level) const; |
439 | | |
440 | | /** @return the mac content directory for this target. */ |
441 | | std::string GetMacContentDirectory( |
442 | | std::string const& config, cmStateEnums::ArtifactType artifact) const; |
443 | | |
444 | | /** @return folder prefix for IDEs. */ |
445 | | std::string GetEffectiveFolderName() const; |
446 | | |
447 | | cmTarget* Target; |
448 | | cmMakefile* Makefile; |
449 | | cmLocalGenerator* LocalGenerator; |
450 | | cmGlobalGenerator const* GlobalGenerator; |
451 | | |
452 | | std::string targetLabelsString; |
453 | | |
454 | | struct ModuleDefinitionInfo |
455 | | { |
456 | | std::string DefFile; |
457 | | bool DefFileGenerated; |
458 | | bool WindowsExportAllSymbols; |
459 | | std::vector<cmSourceFile const*> Sources; |
460 | | }; |
461 | | ModuleDefinitionInfo const* GetModuleDefinitionInfo( |
462 | | std::string const& config) const; |
463 | | |
464 | | /** Return whether or not we are targeting AIX. */ |
465 | | bool IsAIX() const; |
466 | | /** Return whether or not we are targeting Apple. */ |
467 | | bool IsApple() const; |
468 | | |
469 | | /** Return whether or not the target is for a DLL platform. */ |
470 | | bool IsDLLPlatform() const; |
471 | | |
472 | | /** @return whether this target have a well defined output file name. */ |
473 | | bool HaveWellDefinedOutputFiles() const; |
474 | | |
475 | | /** Link information from the transitive closure of the link |
476 | | implementation and the interfaces of its dependencies. */ |
477 | | struct LinkClosure |
478 | | { |
479 | | // The preferred linker language. |
480 | | std::string LinkerLanguage; |
481 | | |
482 | | // Languages whose runtime libraries must be linked. |
483 | | std::vector<std::string> Languages; |
484 | | }; |
485 | | |
486 | | LinkClosure const* GetLinkClosure(std::string const& config) const; |
487 | | |
488 | | cmLinkImplementation const* GetLinkImplementation(std::string const& config, |
489 | | UseTo usage) const; |
490 | | |
491 | | void ComputeLinkImplementationLanguages( |
492 | | std::string const& config, cmOptionalLinkImplementation& impl) const; |
493 | | |
494 | | cmLinkImplementationLibraries const* GetLinkImplementationLibraries( |
495 | | std::string const& config, UseTo usage) const; |
496 | | |
497 | | void ComputeLinkImplementationLibraries(std::string const& config, |
498 | | cmOptionalLinkImplementation& impl, |
499 | | UseTo usage) const; |
500 | | |
501 | | struct TargetOrString |
502 | | { |
503 | | std::string String; |
504 | | cmGeneratorTarget* Target = nullptr; |
505 | | }; |
506 | | TargetOrString ResolveTargetReference(std::string const& name) const; |
507 | | TargetOrString ResolveTargetReference(std::string const& name, |
508 | | cmLocalGenerator const* lg) const; |
509 | | |
510 | | cmLinkItem ResolveLinkItem( |
511 | | BT<std::string> const& name, |
512 | | std::string const& linkFeature = cmLinkItem::DEFAULT) const; |
513 | | cmLinkItem ResolveLinkItem( |
514 | | BT<std::string> const& name, cmLocalGenerator const* lg, |
515 | | std::string const& linkFeature = cmLinkItem::DEFAULT) const; |
516 | | |
517 | | bool HasPackageReferences() const; |
518 | | std::vector<std::string> GetPackageReferences() const; |
519 | | |
520 | | // Compute the set of languages compiled by the target. This is |
521 | | // computed every time it is called because the languages can change |
522 | | // when source file properties are changed and we do not have enough |
523 | | // information to forward these property changes to the targets |
524 | | // until we have per-target object file properties. |
525 | | void GetLanguages(std::set<std::string>& languages, |
526 | | std::string const& config) const; |
527 | | bool IsLanguageUsed(std::string const& language, |
528 | | std::string const& config) const; |
529 | | |
530 | | // Get the set of targets directly referenced via `TARGET_OBJECTS` in the |
531 | | // source list for a configuration. |
532 | | std::set<cmGeneratorTarget const*> GetSourceObjectLibraries( |
533 | | std::string const& config) const; |
534 | | |
535 | | bool IsCSharpOnly() const; |
536 | | |
537 | | bool IsDotNetSdkTarget() const; |
538 | | |
539 | | void GetObjectLibrariesInSources( |
540 | | std::vector<BT<cmGeneratorTarget*>>& objlibs) const; |
541 | | |
542 | | std::string GetFullNameImported(std::string const& config, |
543 | | cmStateEnums::ArtifactType artifact) const; |
544 | | |
545 | | /** Get source files common to all configurations and diagnose cases |
546 | | with per-config sources. Excludes sources added by a TARGET_OBJECTS |
547 | | generator expression. Do not use outside the Xcode generator. */ |
548 | | bool GetConfigCommonSourceFilesForXcode( |
549 | | std::vector<cmSourceFile*>& files) const; |
550 | | |
551 | | bool HaveBuildTreeRPATH(std::string const& config) const; |
552 | | |
553 | | /** Full path with trailing slash to the top-level directory |
554 | | holding object files for this target. Includes the build |
555 | | time config name placeholder if needed for the generator. */ |
556 | | std::string ObjectDirectory; |
557 | | |
558 | | /** Full path with trailing slash to the top-level directory |
559 | | holding object files for the given configuration. */ |
560 | | std::string GetObjectDirectory(std::string const& config) const; |
561 | | |
562 | | std::vector<std::string> GetAppleArchs(std::string const& config, |
563 | | cm::optional<std::string> lang) const; |
564 | | |
565 | | // The classification of the flag. |
566 | | enum class FlagClassification |
567 | | { |
568 | | // The flag is for the execution of the tool (e.g., the compiler itself, |
569 | | // any launchers, etc.). |
570 | | ExecutionFlag, |
571 | | // The flag is "baseline" and should be apply to TUs which may interact |
572 | | // with this compilation (e.g., imported modules). |
573 | | BaselineFlag, |
574 | | // The flag is "private" and doesn't need to apply to interacting TUs. |
575 | | PrivateFlag, |
576 | | // Flags for the TU itself (e.g., output paths, dependency scanning, etc.). |
577 | | LocationFlag, |
578 | | }; |
579 | | enum class FlagKind |
580 | | { |
581 | | // Not a flag (executable or other entries). |
582 | | NotAFlag, |
583 | | // Flags for support of the build system. |
584 | | BuildSystem, |
585 | | // A compilation flag. |
586 | | Compile, |
587 | | // An include flag. |
588 | | Include, |
589 | | // A compile definition. |
590 | | Definition, |
591 | | }; |
592 | | struct ClassifiedFlag |
593 | | { |
594 | | ClassifiedFlag(FlagClassification cls, FlagKind kind, std::string flag) |
595 | 0 | : Classification(cls) |
596 | 0 | , Kind(kind) |
597 | 0 | , Flag(std::move(flag)) |
598 | 0 | { |
599 | 0 | } |
600 | | |
601 | | FlagClassification Classification; |
602 | | FlagKind Kind; |
603 | | std::string Flag; |
604 | | }; |
605 | | using ClassifiedFlags = std::vector<ClassifiedFlag>; |
606 | | ClassifiedFlags GetClassifiedFlagsForSource(cmSourceFile const* sf, |
607 | | std::string const& config); |
608 | | struct SourceVariables |
609 | | { |
610 | | std::string TargetPDB; |
611 | | std::string TargetCompilePDB; |
612 | | std::string ObjectDir; |
613 | | std::string TargetSupportDir; |
614 | | std::string ObjectFileDir; |
615 | | std::string DependencyFile; |
616 | | std::string DependencyTarget; |
617 | | |
618 | | // Dependency flags (if used) |
619 | | std::string DependencyFlags; |
620 | | }; |
621 | | SourceVariables GetSourceVariables(cmSourceFile const* sf, |
622 | | std::string const& config); |
623 | | |
624 | | void AddExplicitLanguageFlags(std::string& flags, cmSourceFile const& sf, |
625 | | std::string const& config) const; |
626 | | |
627 | | void AddCUDAArchitectureFlags(cmBuildStep compileOrLink, |
628 | | std::string const& config, |
629 | | std::string& flags) const; |
630 | | void AddCUDAArchitectureFlagsImpl(cmBuildStep compileOrLink, |
631 | | std::string const& config, |
632 | | std::string const& lang, std::string arch, |
633 | | std::string& flags) const; |
634 | | void AddCUDAToolkitFlags(std::string& flags) const; |
635 | | |
636 | | void AddHIPArchitectureFlags(cmBuildStep compileOrLink, |
637 | | std::string const& config, |
638 | | std::string& flags) const; |
639 | | void AddSYCLDeviceTargetFlags(cmBuildStep compileOrLink, |
640 | | std::string const& config, |
641 | | std::string& flags) const; |
642 | | |
643 | | void AddISPCTargetFlags(std::string& flags) const; |
644 | | |
645 | | void AddRustTargetFlags(std::string& flags) const; |
646 | | |
647 | | void AddSwiftTargetFlags(std::string& flags) const; |
648 | | |
649 | | std::string GetFeatureSpecificLinkRuleVariable( |
650 | | std::string const& var, std::string const& lang, |
651 | | std::string const& config) const; |
652 | | |
653 | | /** Return the rule variable used to create this type of target. */ |
654 | | std::string GetCreateRuleVariable(std::string const& lang, |
655 | | std::string const& config) const; |
656 | | |
657 | | std::string GetClangTidyExportFixesDirectory(std::string const& lang) const; |
658 | | |
659 | | /** Return the Swift package name for this target. */ |
660 | | std::string GetSwiftPackageName() const; |
661 | | |
662 | | /** Return the swift module name for this target. */ |
663 | | std::string GetSwiftModuleName() const; |
664 | | |
665 | | /** Return the path of the `.swiftmodule` for this target in |
666 | | the given configuration. */ |
667 | | std::string GetSwiftModulePath(std::string const& config) const; |
668 | | |
669 | | /** Return the directory containing Swift module interface |
670 | | descriptions for this target (including its `.swiftmodule`, |
671 | | `.abi.json`, and `.swiftdoc`) in the given configuration. */ |
672 | | std::string GetSwiftModuleDirectory(std::string const& config) const; |
673 | | |
674 | | private: |
675 | | /** Return the given property of this target if it exists; otherwise |
676 | | return defaultValue. */ |
677 | | std::string GetPropertyOrDefault(std::string const& property, |
678 | | std::string defaultValue) const; |
679 | | |
680 | | /** Return the name of the `.swiftmodule` file for this target. */ |
681 | | std::string GetSwiftModuleFileName() const; |
682 | | |
683 | | using ConfigAndLanguage = std::pair<std::string, std::string>; |
684 | | using ConfigAndLanguageToBTStrings = |
685 | | std::map<ConfigAndLanguage, std::vector<BT<std::string>>>; |
686 | | mutable ConfigAndLanguageToBTStrings IncludeDirectoriesCache; |
687 | | mutable ConfigAndLanguageToBTStrings CompileOptionsCache; |
688 | | mutable ConfigAndLanguageToBTStrings CompileDefinitionsCache; |
689 | | mutable ConfigAndLanguageToBTStrings CompileWrappersCache; |
690 | | mutable ConfigAndLanguageToBTStrings PrecompileHeadersCache; |
691 | | mutable ConfigAndLanguageToBTStrings LinkOptionsCache; |
692 | | mutable ConfigAndLanguageToBTStrings LinkDirectoriesCache; |
693 | | mutable ConfigAndLanguageToBTStrings LinkWrappersCache; |
694 | | |
695 | | public: |
696 | | /** Get the wrapper entries for this target. */ |
697 | | std::vector<BT<std::string>> GetCompileWrappers( |
698 | | std::string const& config, std::string const& lang) const; |
699 | | std::vector<BT<std::string>> GetLinkWrappers(std::string const& config, |
700 | | std::string const& lang) const; |
701 | | |
702 | | /** Get the include directories for this target. */ |
703 | | std::vector<BT<std::string>> GetIncludeDirectories( |
704 | | std::string const& config, std::string const& lang) const; |
705 | | |
706 | | void GetCompileOptions(std::vector<std::string>& result, |
707 | | std::string const& config, |
708 | | std::string const& language) const; |
709 | | std::vector<BT<std::string>> GetCompileOptions( |
710 | | std::string const& config, std::string const& language) const; |
711 | | |
712 | | void GetCompileFeatures(std::vector<std::string>& features, |
713 | | std::string const& config) const; |
714 | | std::vector<BT<std::string>> GetCompileFeatures( |
715 | | std::string const& config) const; |
716 | | |
717 | | void GetCompileDefinitions(std::vector<std::string>& result, |
718 | | std::string const& config, |
719 | | std::string const& language) const; |
720 | | std::vector<BT<std::string>> GetCompileDefinitions( |
721 | | std::string const& config, std::string const& language) const; |
722 | | |
723 | | void GetLinkOptions(std::vector<std::string>& result, |
724 | | std::string const& config, |
725 | | std::string const& language) const; |
726 | | std::vector<BT<std::string>> GetLinkOptions( |
727 | | std::string const& config, std::string const& language) const; |
728 | | |
729 | | std::vector<BT<std::string>>& ResolveLinkerWrapper( |
730 | | std::vector<BT<std::string>>& result, std::string const& language, |
731 | | bool joinItems = false) const; |
732 | | |
733 | | void GetStaticLibraryLinkOptions(std::vector<std::string>& result, |
734 | | std::string const& config, |
735 | | std::string const& language) const; |
736 | | std::vector<BT<std::string>> GetStaticLibraryLinkOptions( |
737 | | std::string const& config, std::string const& language) const; |
738 | | |
739 | | std::vector<BT<std::string>>& ResolveArchiverWrapper( |
740 | | std::vector<BT<std::string>>& result, std::string const& language, |
741 | | bool joinItems = false) const; |
742 | | |
743 | | void GetLinkDirectories(std::vector<std::string>& result, |
744 | | std::string const& config, |
745 | | std::string const& language) const; |
746 | | std::vector<BT<std::string>> GetLinkDirectories( |
747 | | std::string const& config, std::string const& language) const; |
748 | | |
749 | | void GetLinkDepends(std::vector<std::string>& result, |
750 | | std::string const& config, |
751 | | std::string const& language) const; |
752 | | std::vector<BT<std::string>> GetLinkDepends( |
753 | | std::string const& config, std::string const& language) const; |
754 | | |
755 | | std::vector<BT<std::string>> GetPrecompileHeaders( |
756 | | std::string const& config, std::string const& language) const; |
757 | | |
758 | 0 | void MarkAsPchReused() { this->PchReused = true; } |
759 | | cmGeneratorTarget const* GetPchReuseTarget() const; |
760 | | cmGeneratorTarget* GetPchReuseTarget(); |
761 | | std::vector<std::string> GetPchArchs(std::string const& config, |
762 | | std::string const& lang) const; |
763 | | std::string GetPchHeader(std::string const& config, |
764 | | std::string const& language, |
765 | | std::string const& arch = std::string()) const; |
766 | | std::string GetPchSource(std::string const& config, |
767 | | std::string const& language, |
768 | | std::string const& arch = std::string()) const; |
769 | | std::string GetPchFileObject(std::string const& config, |
770 | | std::string const& language, |
771 | | std::string const& arch = std::string()); |
772 | | std::string GetPchFile(std::string const& config, |
773 | | std::string const& language, |
774 | | std::string const& arch = std::string()); |
775 | | std::string GetPchCreateCompileOptions( |
776 | | std::string const& config, std::string const& language, |
777 | | std::string const& arch = std::string()); |
778 | | std::string GetPchUseCompileOptions(std::string const& config, |
779 | | std::string const& language, |
780 | | std::string const& arch = std::string()); |
781 | | |
782 | | void AddSourceFileToUnityBatch(std::string const& sourceFilename); |
783 | | bool IsSourceFilePartOfUnityBatch(std::string const& sourceFilename) const; |
784 | | |
785 | | bool IsSystemIncludeDirectory(std::string const& dir, |
786 | | std::string const& config, |
787 | | std::string const& language) const; |
788 | | |
789 | | void AddSystemIncludeCacheKey(std::string const& key, |
790 | | std::string const& config, |
791 | | std::string const& language) const; |
792 | | |
793 | | /** Add the target output files to the global generator manifest. */ |
794 | | void ComputeTargetManifest(std::string const& config) const; |
795 | | |
796 | | bool ComputeCompileFeatures(std::string const& config); |
797 | | |
798 | | using LanguagePair = std::pair<std::string, std::string>; |
799 | | bool ComputeCompileFeatures(std::string const& config, |
800 | | std::set<LanguagePair> const& languagePairs); |
801 | | |
802 | | /** |
803 | | * Trace through the source files in this target and add al source files |
804 | | * that they depend on, used by all generators |
805 | | */ |
806 | | void TraceDependencies(); |
807 | | |
808 | | /** Get the directory in which this target will be built. If the |
809 | | configuration name is given then the generator will add its |
810 | | subdirectory for that configuration. Otherwise just the canonical |
811 | | output directory is given. */ |
812 | | std::string GetDirectory(std::string const& config, |
813 | | cmStateEnums::ArtifactType artifact = |
814 | | cmStateEnums::RuntimeBinaryArtifact) const; |
815 | | |
816 | | /** Get the directory in which to place the target compiler .pdb file. |
817 | | If the configuration name is given then the generator will add its |
818 | | subdirectory for that configuration. Otherwise just the canonical |
819 | | compiler pdb output directory is given. */ |
820 | | std::string GetCompilePDBDirectory(std::string const& config) const; |
821 | | |
822 | | /** Get sources that must be built before the given source. */ |
823 | | std::vector<cmSourceFile*> const* GetSourceDepends( |
824 | | cmSourceFile const* sf) const; |
825 | | |
826 | | /** Return whether this target uses the default value for its output |
827 | | directory. */ |
828 | | bool UsesDefaultOutputDir(std::string const& config, |
829 | | cmStateEnums::ArtifactType artifact) const; |
830 | | |
831 | | // Cache target output paths for each configuration. |
832 | | struct OutputInfo |
833 | | { |
834 | | std::string OutDir; |
835 | | std::string ImpDir; |
836 | | std::string PdbDir; |
837 | | bool empty() const |
838 | 2.31k | { |
839 | 2.31k | return this->OutDir.empty() && this->ImpDir.empty() && |
840 | 0 | this->PdbDir.empty(); |
841 | 2.31k | } |
842 | | }; |
843 | | |
844 | | OutputInfo const* GetOutputInfo(std::string const& config) const; |
845 | | |
846 | | // Get the target PDB base name. |
847 | | std::string GetPDBOutputName(std::string const& config) const; |
848 | | |
849 | | /** Get the name of the pdb file for the target. */ |
850 | | std::string GetPDBName(std::string const& config) const; |
851 | | |
852 | | /** Whether this library has soname enabled and platform supports it. */ |
853 | | bool HasSOName(std::string const& config) const; |
854 | | |
855 | | struct CompileInfo |
856 | | { |
857 | | std::string CompilePdbDir; |
858 | | }; |
859 | | |
860 | | CompileInfo const* GetCompileInfo(std::string const& config) const; |
861 | | |
862 | | using CompileInfoMapType = std::map<std::string, CompileInfo>; |
863 | | mutable CompileInfoMapType CompileInfoMap; |
864 | | |
865 | | bool IsNullImpliedByLinkLibraries(std::string const& p) const; |
866 | | |
867 | | /** Get the name of the compiler pdb file for the target. */ |
868 | | std::string GetCompilePDBName(std::string const& config) const; |
869 | | |
870 | | /** Get the path for the MSVC /Fd option for this target. */ |
871 | | std::string GetCompilePDBPath(std::string const& config) const; |
872 | | |
873 | | // Get the target base name. |
874 | | std::string GetOutputName(std::string const& config, |
875 | | cmStateEnums::ArtifactType artifact) const; |
876 | | |
877 | | /** Get target file prefix */ |
878 | | std::string GetFilePrefix(std::string const& config, |
879 | | cmStateEnums::ArtifactType artifact = |
880 | | cmStateEnums::RuntimeBinaryArtifact) const; |
881 | | /** Get target file prefix */ |
882 | | std::string GetFileSuffix(std::string const& config, |
883 | | cmStateEnums::ArtifactType artifact = |
884 | | cmStateEnums::RuntimeBinaryArtifact) const; |
885 | | |
886 | | /** Get target file postfix */ |
887 | | std::string GetFilePostfix(std::string const& config) const; |
888 | | |
889 | | /** Get framework multi-config-specific postfix */ |
890 | | std::string GetFrameworkMultiConfigPostfix(std::string const& config) const; |
891 | | |
892 | | /** Clears cached meta data for local and external source files. |
893 | | * The meta data will be recomputed on demand. |
894 | | */ |
895 | | void ClearSourcesCache(); |
896 | | |
897 | | /** |
898 | | * Clears cached evaluations of INTERFACE_LINK_LIBRARIES. |
899 | | * They will be recomputed on demand. |
900 | | */ |
901 | | void ClearLinkInterfaceCache(); |
902 | | |
903 | | cmSourceFile* AddSource(std::string const& src, bool before = false); |
904 | | void AddTracedSources(std::vector<std::string> const& srcs); |
905 | | |
906 | | /** |
907 | | * Adds an entry to the INCLUDE_DIRECTORIES list. |
908 | | * If before is true the entry is pushed at the front. |
909 | | */ |
910 | | void AddIncludeDirectory(std::string const& src, bool before = false); |
911 | | |
912 | | /** |
913 | | * Flags for a given source file as used in this target. Typically assigned |
914 | | * via SET_TARGET_PROPERTIES when the property is a list of source files. |
915 | | */ |
916 | | enum SourceFileType |
917 | | { |
918 | | SourceFileTypeNormal, |
919 | | SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property |
920 | | SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property |
921 | | SourceFileTypeResource, // is in "RESOURCE" target property *or* |
922 | | // has MACOSX_PACKAGE_LOCATION=="Resources" |
923 | | SourceFileTypeDeepResource, // MACOSX_PACKAGE_LOCATION starts with |
924 | | // "Resources/" |
925 | | SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources[/]" |
926 | | }; |
927 | | struct SourceFileFlags |
928 | | { |
929 | | SourceFileType Type = SourceFileTypeNormal; |
930 | | char const* MacFolder = nullptr; // location inside Mac content folders |
931 | | }; |
932 | | void GetAutoUicOptions(std::vector<std::string>& result, |
933 | | std::string const& config) const; |
934 | | |
935 | | struct Names |
936 | | { |
937 | | std::string Base; |
938 | | std::string Output; |
939 | | std::string Real; |
940 | | std::string ImportOutput; |
941 | | std::string ImportReal; |
942 | | std::string ImportLibrary; |
943 | | std::string PDB; |
944 | | std::string SharedObject; |
945 | | }; |
946 | | |
947 | | /** Get the names of the executable needed to generate a build rule |
948 | | that takes into account executable version numbers. This should |
949 | | be called only on an executable target. */ |
950 | | Names GetExecutableNames(std::string const& config) const; |
951 | | |
952 | | /** Get the names of the library needed to generate a build rule |
953 | | that takes into account shared library version numbers. This |
954 | | should be called only on a library target. */ |
955 | | Names GetLibraryNames(std::string const& config) const; |
956 | | |
957 | | /** |
958 | | * Compute whether this target must be relinked before installing. |
959 | | */ |
960 | | bool NeedRelinkBeforeInstall(std::string const& config) const; |
961 | | |
962 | | /** Return true if builtin chrpath will work for this target */ |
963 | | bool IsChrpathUsed(std::string const& config) const; |
964 | | |
965 | | /** Get the directory in which this targets .pdb files will be placed. |
966 | | If the configuration name is given then the generator will add its |
967 | | subdirectory for that configuration. Otherwise just the canonical |
968 | | pdb output directory is given. */ |
969 | | std::string GetPDBDirectory(std::string const& config) const; |
970 | | |
971 | | //! Return the preferred linker language for this target |
972 | | std::string GetLinkerLanguage(std::string const& config) const; |
973 | | //! Return the preferred linker tool for this target |
974 | | std::string GetLinkerTool(std::string const& config) const; |
975 | | std::string GetLinkerTool(std::string const& lang, |
976 | | std::string const& config) const; |
977 | | |
978 | | /** Is the linker known to enforce '--no-allow-shlib-undefined'? */ |
979 | | bool LinkerEnforcesNoAllowShLibUndefined(std::string const& config) const; |
980 | | |
981 | | /** Does this target have a GNU implib to convert to MS format? */ |
982 | | bool HasImplibGNUtoMS(std::string const& config) const; |
983 | | |
984 | | /** Convert the given GNU import library name (.dll.a) to a name with a new |
985 | | extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ |
986 | | bool GetImplibGNUtoMS(std::string const& config, std::string const& gnuName, |
987 | | std::string& out, char const* newExt = nullptr) const; |
988 | | |
989 | | /** Can only ever return true if GetSourceFilePaths() was called before. |
990 | | Otherwise, this is indeterminate and false will be assumed/returned! */ |
991 | | bool HasContextDependentSources() const; |
992 | | |
993 | | bool IsExecutableWithExports() const; |
994 | | |
995 | | /* Return whether this target is a shared library with capability to generate |
996 | | * a file describing symbols exported (for example, .tbd file on Apple). */ |
997 | | bool IsSharedLibraryWithExports() const; |
998 | | |
999 | | /** Return whether or not the target has a DLL import library. */ |
1000 | | bool HasImportLibrary(std::string const& config) const; |
1001 | | |
1002 | | bool GetUseShortObjectNames( |
1003 | | cmStateEnums::IntermediateDirKind kind = |
1004 | | cmStateEnums::IntermediateDirKind::ObjectFiles) const; |
1005 | | cmObjectLocations::UseShortPath GetUseShortObjectNamesForInstall() const; |
1006 | | |
1007 | | /** Get a build-tree directory in which to place target support files. */ |
1008 | | std::string GetSupportDirectory( |
1009 | | cmStateEnums::IntermediateDirKind kind = |
1010 | | cmStateEnums::IntermediateDirKind::ObjectFiles) const; |
1011 | | std::string GetCMFSupportDirectory( |
1012 | | cmStateEnums::IntermediateDirKind kind = |
1013 | | cmStateEnums::IntermediateDirKind::ObjectFiles) const; |
1014 | | |
1015 | | /** Return whether this target may be used to link another target. */ |
1016 | | bool IsLinkable() const; |
1017 | | |
1018 | | /** Return whether the link step generates a dependency file. */ |
1019 | | bool HasLinkDependencyFile(std::string const& config) const; |
1020 | | |
1021 | | /** Return whether this target is a shared library Framework on |
1022 | | Apple. */ |
1023 | | bool IsFrameworkOnApple() const; |
1024 | | |
1025 | | /** Return whether this target is an IMPORTED library target on Apple |
1026 | | with a .framework folder as its location. */ |
1027 | | bool IsImportedFrameworkFolderOnApple(std::string const& config) const; |
1028 | | |
1029 | | /** Return whether this target is an executable Bundle on Apple. */ |
1030 | | bool IsAppBundleOnApple() const; |
1031 | | |
1032 | | /** Return whether this target is an XCTest on Apple. */ |
1033 | | bool IsXCTestOnApple() const; |
1034 | | |
1035 | | /** Return whether this target is a CFBundle (plugin) on Apple. */ |
1036 | | bool IsCFBundleOnApple() const; |
1037 | | |
1038 | | /** Return whether this target is a shared library on AIX. */ |
1039 | | bool IsArchivedAIXSharedLibrary() const; |
1040 | | |
1041 | | /** Assembly types. The order of the values of this enum is relevant |
1042 | | because of smaller/larger comparison operations! */ |
1043 | | enum ManagedType |
1044 | | { |
1045 | | Undefined = 0, // target is no lib or executable |
1046 | | Native, // target compiles to unmanaged binary. |
1047 | | Mixed, // target compiles to mixed (managed and unmanaged) binary. |
1048 | | Managed // target compiles to managed binary. |
1049 | | }; |
1050 | | |
1051 | | /** Return the type of assembly this target compiles to. */ |
1052 | | ManagedType GetManagedType(std::string const& config) const; |
1053 | | |
1054 | | struct SourceFileFlags GetTargetSourceFileFlags( |
1055 | | cmSourceFile const* sf) const; |
1056 | | |
1057 | | void ReportPropertyOrigin(std::string const& p, std::string const& result, |
1058 | | std::string const& report, |
1059 | | std::string const& compatibilityType) const; |
1060 | | |
1061 | | std::string EvaluateInterfaceProperty( |
1062 | | std::string const& prop, cm::GenEx::Evaluation* eval, |
1063 | | cmGeneratorExpressionDAGChecker* dagCheckerParent, UseTo usage) const; |
1064 | | |
1065 | | struct TransitiveProperty |
1066 | | { |
1067 | | #if defined(__SUNPRO_CC) || (defined(__ibmxl__) && defined(__clang__)) |
1068 | | TransitiveProperty(cm::string_view interfaceName, UseTo usage) |
1069 | | : InterfaceName(interfaceName) |
1070 | | , Usage(usage) |
1071 | | { |
1072 | | } |
1073 | | #endif |
1074 | | cm::string_view InterfaceName; |
1075 | | UseTo Usage; |
1076 | | }; |
1077 | | |
1078 | | static std::map<cm::string_view, TransitiveProperty> const |
1079 | | BuiltinTransitiveProperties; |
1080 | | |
1081 | | cm::optional<TransitiveProperty> IsTransitiveProperty( |
1082 | | cm::string_view prop, cm::GenEx::Context const& context, |
1083 | | cmGeneratorExpressionDAGChecker const* dagChecker) const; |
1084 | | |
1085 | | bool HaveInstallTreeRPATH(std::string const& config) const; |
1086 | | |
1087 | | bool GetBuildRPATH(std::string const& config, std::string& rpath) const; |
1088 | | bool GetInstallRPATH(std::string const& config, std::string& rpath) const; |
1089 | | |
1090 | | /** Whether this library has \@rpath and platform supports it. */ |
1091 | | bool HasMacOSXRpathInstallNameDir(std::string const& config) const; |
1092 | | |
1093 | | /** Whether this library defaults to \@rpath. */ |
1094 | | bool MacOSXRpathInstallNameDirDefault() const; |
1095 | | |
1096 | | enum InstallNameType |
1097 | | { |
1098 | | INSTALL_NAME_FOR_BUILD, |
1099 | | INSTALL_NAME_FOR_INSTALL |
1100 | | }; |
1101 | | /** Whether to use INSTALL_NAME_DIR. */ |
1102 | | bool MacOSXUseInstallNameDir() const; |
1103 | | /** Whether to generate an install_name. */ |
1104 | | bool CanGenerateInstallNameDir(InstallNameType t) const; |
1105 | | |
1106 | | /** Test for special case of a third-party shared library that has |
1107 | | no soname at all. */ |
1108 | | bool IsImportedSharedLibWithoutSOName(std::string const& config) const; |
1109 | | |
1110 | | std::string ImportedGetLocation(std::string const& config) const; |
1111 | | |
1112 | | /** Get the target major and minor version numbers interpreted from |
1113 | | the VERSION property. Version 0 is returned if the property is |
1114 | | not set or cannot be parsed. */ |
1115 | | void GetTargetVersion(int& major, int& minor) const; |
1116 | | |
1117 | | /** Get the target major, minor, and patch version numbers |
1118 | | interpreted from the given property. Version 0 |
1119 | | is returned if the property is not set or cannot be parsed. */ |
1120 | | void GetTargetVersion(std::string const& property, int& major, int& minor, |
1121 | | int& patch) const; |
1122 | | |
1123 | | /** Get the target major, minor, and patch version numbers |
1124 | | interpreted from the given property and if empty use the |
1125 | | fallback property. Version 0 is returned if the property is |
1126 | | not set or cannot be parsed. */ |
1127 | | void GetTargetVersionFallback(std::string const& property, |
1128 | | std::string const& fallback_property, |
1129 | | int& major, int& minor, int& patch) const; |
1130 | | |
1131 | | std::string GetRuntimeLinkLibrary(std::string const& lang, |
1132 | | std::string const& config) const; |
1133 | | |
1134 | | std::string GetFortranModuleDirectory(std::string const& working_dir) const; |
1135 | | bool IsFortranBuildingIntrinsicModules() const; |
1136 | | |
1137 | | bool IsLinkLookupScope(std::string const& n, |
1138 | | cmLocalGenerator const*& lg) const; |
1139 | | |
1140 | | cmValue GetSourcesProperty() const; |
1141 | | |
1142 | | void AddISPCGeneratedHeader(std::string const& header, |
1143 | | std::string const& config); |
1144 | | std::vector<std::string> GetGeneratedISPCHeaders( |
1145 | | std::string const& config) const; |
1146 | | |
1147 | | void AddISPCGeneratedObject( |
1148 | | std::vector<std::pair<cmSourceFile const*, std::string>>&& objs, |
1149 | | std::string const& config); |
1150 | | std::vector<std::pair<cmSourceFile const*, std::string>> |
1151 | | GetGeneratedISPCObjects(std::string const& config) const; |
1152 | | |
1153 | | void AddSystemIncludeDirectory(std::string const& inc, |
1154 | | std::string const& lang); |
1155 | | bool AddHeaderSetVerification(); |
1156 | | cm::optional<std::string> GenerateHeaderSetVerificationFile( |
1157 | | cmSourceFile& source, std::string const& dir, |
1158 | | std::string const& verifyTargetName, |
1159 | | cm::optional<cm::optional<std::string>>& defaultLanguage) const; |
1160 | | |
1161 | | cm::optional<std::string> ResolveHeaderLanguage( |
1162 | | cmSourceFile& source, |
1163 | | cm::optional<cm::optional<std::string>>& defaultLanguage) const; |
1164 | | |
1165 | | cm::optional<std::string> GenerateStubForLanguage( |
1166 | | std::string const& language, std::string const& headerFilename, |
1167 | | std::string const& verifyTargetName, cmSourceFile& source) const; |
1168 | | |
1169 | | std::string GetImportedXcFrameworkPath(std::string const& config) const; |
1170 | | |
1171 | | bool ApplyCXXStdTarget(); |
1172 | | bool HasCxxImportModuleErrors() const; |
1173 | | cmCxxModuleUsageEffects const& GetCxxModuleUsageEffects( |
1174 | | std::string const& config) const; |
1175 | | cmGeneratorTarget const* GetTargetForCxxModules( |
1176 | | std::string const& config, cmGeneratorTarget const& bmiConsumer) const; |
1177 | | bool DiscoverSyntheticTargets( |
1178 | | std::string const& config, cmGeneratorTarget const* bmiConsumer = nullptr); |
1179 | | |
1180 | | using SyntheticDepsMap = |
1181 | | std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>>; |
1182 | | SyntheticDepsMap const& GetSyntheticDeps(std::string const& config) const; |
1183 | | |
1184 | | class CustomTransitiveProperty : public TransitiveProperty |
1185 | | { |
1186 | | std::unique_ptr<std::string> InterfaceNameBuf; |
1187 | | CustomTransitiveProperty(std::unique_ptr<std::string> interfaceNameBuf, |
1188 | | UseTo usage); |
1189 | | |
1190 | | public: |
1191 | | CustomTransitiveProperty(std::string interfaceName, UseTo usage); |
1192 | | }; |
1193 | | struct CustomTransitiveProperties |
1194 | | : public std::map<std::string, CustomTransitiveProperty> |
1195 | | { |
1196 | | void Add(cmValue props, UseTo usage); |
1197 | | }; |
1198 | | |
1199 | | enum class PropertyFor |
1200 | | { |
1201 | | Build, |
1202 | | Interface, |
1203 | | }; |
1204 | | |
1205 | | CustomTransitiveProperties const& GetCustomTransitiveProperties( |
1206 | | std::string const& config, PropertyFor propertyFor) const; |
1207 | | |
1208 | | private: |
1209 | | void AddSourceCommon(std::string const& src, bool before = false); |
1210 | | |
1211 | | cmGeneratorTarget const* GetCxxSyntheticTarget( |
1212 | | std::string const& config, cmGeneratorTarget const& bmiConsumer) const; |
1213 | | |
1214 | | std::string CreateFortranModuleDirectory( |
1215 | | std::string const& working_dir) const; |
1216 | | mutable bool FortranModuleDirectoryCreated = false; |
1217 | | mutable std::string FortranModuleDirectory; |
1218 | | |
1219 | | friend class cmTargetTraceDependencies; |
1220 | | struct SourceEntry |
1221 | | { |
1222 | | std::vector<cmSourceFile*> Depends; |
1223 | | }; |
1224 | | using SourceEntriesType = std::map<cmSourceFile const*, SourceEntry>; |
1225 | | SourceEntriesType SourceDepends; |
1226 | | mutable std::set<std::string> VisitedConfigsForObjects; |
1227 | | mutable std::map<cmSourceFile const*, cmObjectLocations> Objects; |
1228 | | std::set<cmSourceFile const*> ExplicitObjectName; |
1229 | | |
1230 | | using TargetPtrToBoolMap = std::unordered_map<cmTarget*, bool>; |
1231 | | mutable std::unordered_map<std::string, TargetPtrToBoolMap> |
1232 | | MacOSXRpathInstallNameDirCache; |
1233 | | bool DetermineHasMacOSXRpathInstallNameDir(std::string const& config) const; |
1234 | | |
1235 | | // "config/language" is the key |
1236 | | mutable std::map<std::string, std::vector<std::string>> SystemIncludesCache; |
1237 | | |
1238 | | mutable std::string ExportMacro; |
1239 | | mutable std::unordered_map<std::string, cmList> SharedLibraryCompileDefs; |
1240 | | |
1241 | | void ConstructSourceFileFlags() const; |
1242 | | mutable bool SourceFileFlagsConstructed = false; |
1243 | | mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; |
1244 | | |
1245 | | mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; |
1246 | | |
1247 | | bool NeedImportLibraryName(std::string const& config) const; |
1248 | | |
1249 | | cmValue GetFilePrefixInternal(std::string const& config, |
1250 | | cmStateEnums::ArtifactType artifact, |
1251 | | std::string const& language = "") const; |
1252 | | cmValue GetFileSuffixInternal(std::string const& config, |
1253 | | cmStateEnums::ArtifactType artifact, |
1254 | | std::string const& language = "") const; |
1255 | | |
1256 | | std::string GetFullNameInternal(std::string const& config, |
1257 | | cmStateEnums::ArtifactType artifact) const; |
1258 | | |
1259 | | using FullNameCache = std::map<std::string, NameComponents>; |
1260 | | |
1261 | | mutable FullNameCache RuntimeBinaryFullNameCache; |
1262 | | mutable FullNameCache ImportLibraryFullNameCache; |
1263 | | |
1264 | | NameComponents const& GetFullNameInternalComponents( |
1265 | | std::string const& config, cmStateEnums::ArtifactType artifact) const; |
1266 | | |
1267 | | mutable std::string LinkerLanguage; |
1268 | | using LinkClosureMapType = std::map<std::string, LinkClosure>; |
1269 | | mutable LinkClosureMapType LinkClosureMap; |
1270 | | bool DeviceLink = false; |
1271 | | |
1272 | | // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. |
1273 | | char const* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const; |
1274 | | |
1275 | | std::string ComputeVersionedName(std::string const& prefix, |
1276 | | std::string const& base, |
1277 | | std::string const& suffix, |
1278 | | std::string const& name, |
1279 | | cmValue version) const; |
1280 | | |
1281 | | mutable std::map<std::string, CustomTransitiveProperties> |
1282 | | CustomTransitiveBuildPropertiesMap; |
1283 | | mutable std::map<std::string, CustomTransitiveProperties> |
1284 | | CustomTransitiveInterfacePropertiesMap; |
1285 | | |
1286 | | struct CompatibleInterfacesBase |
1287 | | { |
1288 | | std::set<std::string> PropsBool; |
1289 | | std::set<std::string> PropsString; |
1290 | | std::set<std::string> PropsNumberMax; |
1291 | | std::set<std::string> PropsNumberMin; |
1292 | | }; |
1293 | | CompatibleInterfacesBase const& GetCompatibleInterfaces( |
1294 | | std::string const& config) const; |
1295 | | |
1296 | | struct CompatibleInterfaces : public CompatibleInterfacesBase |
1297 | | { |
1298 | | bool Done = false; |
1299 | | }; |
1300 | | mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap; |
1301 | | |
1302 | | using cmTargetLinkInformationMap = |
1303 | | std::map<std::string, std::unique_ptr<cmComputeLinkInformation>>; |
1304 | | mutable cmTargetLinkInformationMap LinkInformation; |
1305 | | |
1306 | | void CheckPropertyCompatibility(cmComputeLinkInformation& info, |
1307 | | std::string const& config) const; |
1308 | | |
1309 | | void ComputeLinkClosure(std::string const& config, LinkClosure& lc) const; |
1310 | | bool ComputeLinkClosure(std::string const& config, LinkClosure& lc, |
1311 | | bool secondPass) const; |
1312 | | |
1313 | | struct LinkImplClosure : public std::vector<cmGeneratorTarget const*> |
1314 | | { |
1315 | | bool Done = false; |
1316 | | }; |
1317 | | mutable std::map<std::string, LinkImplClosure> LinkImplClosureForLinkMap; |
1318 | | mutable std::map<std::string, LinkImplClosure> LinkImplClosureForUsageMap; |
1319 | | |
1320 | | using LinkInterfaceMapType = std::map<std::string, cmHeadToLinkInterfaceMap>; |
1321 | | mutable LinkInterfaceMapType LinkInterfaceMap; |
1322 | | mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; |
1323 | | |
1324 | | cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap( |
1325 | | std::string const& config) const; |
1326 | | cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( |
1327 | | std::string const& config) const; |
1328 | | |
1329 | | std::string GetLinkInterfaceDependentStringAsBoolProperty( |
1330 | | std::string const& p, std::string const& config) const; |
1331 | | |
1332 | | friend class cmTargetCollectLinkLanguages; |
1333 | | cmLinkInterface const* GetLinkInterface(std::string const& config, |
1334 | | cmGeneratorTarget const* headTarget, |
1335 | | bool secondPass) const; |
1336 | | void ComputeLinkInterface(std::string const& config, |
1337 | | cmOptionalLinkInterface& iface, |
1338 | | bool secondPass) const; |
1339 | | cmLinkImplementation const* GetLinkImplementation(std::string const& config, |
1340 | | UseTo usage, |
1341 | | bool secondPass) const; |
1342 | | |
1343 | | enum class LinkItemRole |
1344 | | { |
1345 | | Implementation, |
1346 | | Interface, |
1347 | | }; |
1348 | | bool VerifyLinkItemIsTarget(LinkItemRole role, cmLinkItem const& item) const; |
1349 | | bool VerifyLinkItemColons(LinkItemRole role, cmLinkItem const& item) const; |
1350 | | |
1351 | | // Cache import information from properties for each configuration. |
1352 | | struct ImportInfo |
1353 | | { |
1354 | | bool NoSOName = false; |
1355 | | ManagedType Managed = Native; |
1356 | | unsigned int Multiplicity = 0; |
1357 | | std::string Location; |
1358 | | std::string SOName; |
1359 | | std::string ImportLibrary; |
1360 | | std::string LibName; |
1361 | | std::string Languages; |
1362 | | std::string LibrariesProp; |
1363 | | std::vector<BT<std::string>> Libraries; |
1364 | | std::vector<BT<std::string>> LibrariesHeadInclude; |
1365 | | std::vector<BT<std::string>> LibrariesHeadExclude; |
1366 | | std::string SharedDeps; |
1367 | | }; |
1368 | | |
1369 | | using ImportInfoMapType = std::map<std::string, ImportInfo>; |
1370 | | mutable ImportInfoMapType ImportInfoMap; |
1371 | | void ComputeImportInfo(std::string const& desired_config, |
1372 | | ImportInfo& info) const; |
1373 | | ImportInfo const* GetImportInfo(std::string const& config) const; |
1374 | | |
1375 | | /** Strip off leading and trailing whitespace from an item named in |
1376 | | the link dependencies of this target. */ |
1377 | | std::string CheckCMP0004(std::string const& item) const; |
1378 | | |
1379 | | cmLinkInterface const* GetImportLinkInterface(std::string const& config, |
1380 | | cmGeneratorTarget const* head, |
1381 | | UseTo usage, |
1382 | | bool secondPass = false) const; |
1383 | | |
1384 | | using KindedSourcesMapType = std::map<std::string, KindedSources>; |
1385 | | mutable KindedSourcesMapType KindedSourcesMap; |
1386 | | void ComputeKindedSources(KindedSources& files, |
1387 | | std::string const& config) const; |
1388 | | |
1389 | | mutable std::vector<AllConfigSource> AllConfigSources; |
1390 | | void ComputeAllConfigSources() const; |
1391 | | |
1392 | | mutable std::set<std::string> AllConfigCompileLanguages; |
1393 | | void ComputeAllConfigCompileLanguages() const; |
1394 | | |
1395 | | mutable std::unordered_map<std::string, bool> MaybeInterfacePropertyExists; |
1396 | | bool MaybeHaveInterfaceProperty(std::string const& prop, |
1397 | | cm::GenEx::Evaluation* eval, |
1398 | | UseTo usage) const; |
1399 | | |
1400 | | using TargetPropertyEntryVector = |
1401 | | std::vector<std::unique_ptr<TargetPropertyEntry>>; |
1402 | | |
1403 | | TargetPropertyEntryVector IncludeDirectoriesEntries; |
1404 | | TargetPropertyEntryVector CompileOptionsEntries; |
1405 | | TargetPropertyEntryVector CompileFeaturesEntries; |
1406 | | TargetPropertyEntryVector CompileDefinitionsEntries; |
1407 | | TargetPropertyEntryVector CompileWrappersEntries; |
1408 | | TargetPropertyEntryVector LinkOptionsEntries; |
1409 | | TargetPropertyEntryVector LinkDirectoriesEntries; |
1410 | | TargetPropertyEntryVector LinkWrappersEntries; |
1411 | | TargetPropertyEntryVector PrecompileHeadersEntries; |
1412 | | TargetPropertyEntryVector SourceEntries; |
1413 | | mutable std::set<std::string> LinkImplicitNullProperties; |
1414 | | mutable std::map<std::string, std::string> PchHeaders; |
1415 | | mutable std::map<std::string, std::string> PchSources; |
1416 | | mutable std::map<std::string, std::string> PchObjectFiles; |
1417 | | mutable std::map<std::string, std::string> PchFiles; |
1418 | | mutable std::map<std::string, std::string> PchCreateCompileOptions; |
1419 | | mutable std::map<std::string, std::string> PchUseCompileOptions; |
1420 | | |
1421 | | std::unordered_set<std::string> UnityBatchedSourceFiles; |
1422 | | |
1423 | | std::unordered_map<std::string, std::vector<std::string>> |
1424 | | ISPCGeneratedHeaders; |
1425 | | std::unordered_map<std::string, |
1426 | | std::vector<std::pair<cmSourceFile const*, std::string>>> |
1427 | | ISPCGeneratedObjects; |
1428 | | |
1429 | | enum class LinkInterfaceField |
1430 | | { |
1431 | | Libraries, |
1432 | | HeadExclude, |
1433 | | HeadInclude, |
1434 | | }; |
1435 | | void ExpandLinkItems(std::string const& prop, cmBTStringRange entries, |
1436 | | std::string const& config, |
1437 | | cmGeneratorTarget const* headTarget, UseTo usage, |
1438 | | LinkInterfaceField field, cmLinkInterface& iface) const; |
1439 | | |
1440 | | struct LookupLinkItemScope |
1441 | | { |
1442 | | cmLocalGenerator const* LG; |
1443 | | }; |
1444 | | enum class LookupSelf |
1445 | | { |
1446 | | No, |
1447 | | Yes, |
1448 | | }; |
1449 | | cm::optional<cmLinkItem> LookupLinkItem(std::string const& n, |
1450 | | cmListFileBacktrace const& bt, |
1451 | | std::string const& linkFeature, |
1452 | | LookupLinkItemScope* scope, |
1453 | | LookupSelf lookupSelf) const; |
1454 | | |
1455 | | std::vector<BT<std::string>>& ResolvePrefixWrapper( |
1456 | | std::vector<BT<std::string>>& result, cm::string_view prefix, |
1457 | | std::string const& language, bool joinItems) const; |
1458 | | |
1459 | | std::vector<BT<std::string>> GetSourceFilePaths( |
1460 | | std::string const& config) const; |
1461 | | std::vector<BT<cmSourceFile*>> GetSourceFilesWithoutObjectLibraries( |
1462 | | std::string const& config) const; |
1463 | | void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files, |
1464 | | std::string const& config) const; |
1465 | | |
1466 | | using LinkImplMapType = std::map<std::string, cmOptionalLinkImplementation>; |
1467 | | mutable LinkImplMapType LinkImplMap; |
1468 | | mutable LinkImplMapType LinkImplUsageRequirementsOnlyMap; |
1469 | | |
1470 | | bool ComputeOutputDir(std::string const& config, |
1471 | | cmStateEnums::ArtifactType artifact, |
1472 | | std::string& out) const; |
1473 | | |
1474 | | using OutputInfoMapType = std::map<std::string, OutputInfo>; |
1475 | | mutable OutputInfoMapType OutputInfoMap; |
1476 | | |
1477 | | using PdbOutputNameMapType = std::map<std::string, std::string>; |
1478 | | mutable PdbOutputNameMapType PdbOutputNameMap; |
1479 | | |
1480 | | using ModuleDefinitionInfoMapType = |
1481 | | std::map<std::string, ModuleDefinitionInfo>; |
1482 | | mutable ModuleDefinitionInfoMapType ModuleDefinitionInfoMap; |
1483 | | void ComputeModuleDefinitionInfo(std::string const& config, |
1484 | | ModuleDefinitionInfo& info) const; |
1485 | | |
1486 | | using OutputNameKey = std::pair<std::string, cmStateEnums::ArtifactType>; |
1487 | | using OutputNameMapType = std::map<OutputNameKey, std::string>; |
1488 | | mutable OutputNameMapType OutputNameMap; |
1489 | | mutable std::set<cmLinkItem> UtilityItems; |
1490 | | cmPolicies::PolicyMap PolicyMap; |
1491 | | mutable bool PolicyReportedCMP0069 = false; |
1492 | | mutable bool DebugIncludesDone = false; |
1493 | | mutable bool DebugCompileOptionsDone = false; |
1494 | | mutable bool DebugCompileFeaturesDone = false; |
1495 | | mutable bool DebugCompileDefinitionsDone = false; |
1496 | | mutable bool DebugCompileWrappersDone = false; |
1497 | | mutable bool DebugLinkOptionsDone = false; |
1498 | | mutable bool DebugLinkDirectoriesDone = false; |
1499 | | mutable bool DebugPrecompileHeadersDone = false; |
1500 | | mutable bool DebugSourcesDone = false; |
1501 | | mutable bool UtilityItemsDone = false; |
1502 | | mutable bool DebugLinkWrappersDone = false; |
1503 | | enum class Tribool |
1504 | | { |
1505 | | False = 0x0, |
1506 | | True = 0x1, |
1507 | | Indeterminate = 0x2 |
1508 | | }; |
1509 | | mutable Tribool SourcesAreContextDependent = Tribool::Indeterminate; |
1510 | | |
1511 | | bool ComputePDBOutputDir(std::string const& kind, std::string const& config, |
1512 | | std::string& out) const; |
1513 | | |
1514 | | ManagedType CheckManagedType(std::string const& propval) const; |
1515 | | |
1516 | | bool GetRPATH(std::string const& config, std::string const& prop, |
1517 | | std::string& rpath) const; |
1518 | | |
1519 | | std::map<std::string, BTs<std::string>> LanguageStandardMap; |
1520 | | |
1521 | | cm::optional<cmStandardLevel> GetExplicitStandardLevel( |
1522 | | std::string const& lang, std::string const& config) const; |
1523 | | void UpdateExplicitStandardLevel(std::string const& lang, |
1524 | | std::string const& config, |
1525 | | cmStandardLevel level); |
1526 | | std::map<std::string, cmStandardLevel> ExplicitStandardLevel; |
1527 | | |
1528 | | cmValue GetPropertyWithPairedLanguageSupport(std::string const& lang, |
1529 | | char const* suffix) const; |
1530 | | |
1531 | | std::vector<cmLinkItem> ComputeImplicitLanguageTargets( |
1532 | | std::string const& lang, std::string const& config) const; |
1533 | | |
1534 | | void ComputeLinkImplementationRuntimeLibraries( |
1535 | | std::string const& config, cmOptionalLinkImplementation& impl) const; |
1536 | | |
1537 | | void ComputeLinkInterfaceRuntimeLibraries( |
1538 | | std::string const& config, cmOptionalLinkInterface& iface) const; |
1539 | | |
1540 | | // If this method is made public, or call sites are added outside of |
1541 | | // methods computing cached members, add dedicated caching members. |
1542 | | std::vector<cmGeneratorTarget const*> GetLinkInterfaceClosure( |
1543 | | std::string const& config, cmGeneratorTarget const* headTarget, |
1544 | | UseTo usage) const; |
1545 | | |
1546 | | public: |
1547 | | std::vector<cmGeneratorTarget const*> const& GetLinkImplementationClosure( |
1548 | | std::string const& config, UseTo usage) const; |
1549 | | |
1550 | | mutable std::map<std::string, std::string> MaxLanguageStandards; |
1551 | | std::map<std::string, std::string> const& GetMaxLanguageStandards() const |
1552 | 0 | { |
1553 | 0 | return this->MaxLanguageStandards; |
1554 | 0 | } |
1555 | | |
1556 | | struct StrictTargetComparison |
1557 | | { |
1558 | | bool operator()(cmGeneratorTarget const* t1, |
1559 | | cmGeneratorTarget const* t2) const; |
1560 | | }; |
1561 | | |
1562 | | bool HaveFortranSources() const; |
1563 | | bool HaveFortranSources(std::string const& config) const; |
1564 | | |
1565 | | // File sets support queries |
1566 | | |
1567 | | bool HasFileSets() const; |
1568 | | cmGeneratorFileSets const* GetGeneratorFileSets() const |
1569 | 2.67k | { |
1570 | 2.67k | return this->FileSets.get(); |
1571 | 2.67k | } |
1572 | | std::vector<cmGeneratorFileSet const*> const& GetAllFileSets() const; |
1573 | | std::vector<cmGeneratorFileSet const*> const& GetFileSets( |
1574 | | cm::string_view type) const; |
1575 | | std::vector<cmGeneratorFileSet const*> const& GetInterfaceFileSets( |
1576 | | cm::string_view type) const; |
1577 | | cmGeneratorFileSet const* GetFileSet(std::string const& name) const; |
1578 | | cmGeneratorFileSet const* GetFileSetForSource(std::string const& config, |
1579 | | cmSourceFile const* sf) const; |
1580 | | |
1581 | | // C++20 module support queries. |
1582 | | |
1583 | | /** |
1584 | | * Query whether the target expects C++20 module support. |
1585 | | * |
1586 | | * This will inspect the target itself to see if C++20 module |
1587 | | * support is expected to work based on its sources. |
1588 | | */ |
1589 | | bool HaveInterfaceCxx20ModuleSources() const; |
1590 | | bool HaveCxx20ModuleSources() const; |
1591 | | |
1592 | | enum class Cxx20SupportLevel |
1593 | | { |
1594 | | // C++ is not available. |
1595 | | MissingCxx, |
1596 | | // The target does not require at least C++20. |
1597 | | NoCxx20, |
1598 | | // C++20 module scanning rules are not present. |
1599 | | MissingRule, |
1600 | | // C++20 modules are available and working. |
1601 | | Supported, |
1602 | | }; |
1603 | | |
1604 | | /** |
1605 | | * Query whether the target has C++20 module support available (regardless of |
1606 | | * whether it is required or not). |
1607 | | */ |
1608 | | Cxx20SupportLevel HaveCxxModuleSupport(std::string const& config) const; |
1609 | | |
1610 | | // Check C++ module status for the target. |
1611 | | void CheckCxxModuleStatus(std::string const& config) const; |
1612 | | |
1613 | | bool NeedCxxModuleSupport(std::string const& lang, |
1614 | | std::string const& config) const; |
1615 | | bool NeedDyndep(std::string const& lang, std::string const& config) const; |
1616 | | bool NeedDyndepForSource(std::string const& lang, std::string const& config, |
1617 | | cmSourceFile const* sf) const; |
1618 | | enum class CxxModuleSupport |
1619 | | { |
1620 | | Unavailable, |
1621 | | Enabled, |
1622 | | Disabled, |
1623 | | }; |
1624 | | CxxModuleSupport NeedCxxDyndep(std::string const& config) const; |
1625 | | |
1626 | | std::string BuildDatabasePath(std::string const& lang, |
1627 | | std::string const& config) const; |
1628 | | |
1629 | | enum class MsvcCharSet |
1630 | | { |
1631 | | None, |
1632 | | Unicode, |
1633 | | MultiByte, |
1634 | | SingleByte, |
1635 | | }; |
1636 | | |
1637 | | // Detect if the current define selects any known charset entry or not |
1638 | | static MsvcCharSet GetMsvcCharSet(std::string const& singleDefine); |
1639 | | |
1640 | | private: |
1641 | | struct InfoByConfig |
1642 | | { |
1643 | | std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>> |
1644 | | SyntheticDeps; |
1645 | | std::map<cmSourceFile const*, ClassifiedFlags> SourceFlags; |
1646 | | }; |
1647 | | mutable std::map<std::string, cmGeneratorTarget*> SynthCxxTargets; |
1648 | | mutable std::map<std::string, cmCxxModuleUsageEffects> CxxModuleUsageEffects; |
1649 | | mutable std::map<std::string, InfoByConfig> Configs; |
1650 | | std::unique_ptr<cmGeneratorFileSets> FileSets; |
1651 | | bool PchReused = false; |
1652 | | mutable bool ComputingPchReuse = false; |
1653 | | mutable bool PchReuseCycleDetected = false; |
1654 | | }; |