/src/CMake/Source/cmTargetPropertyHelper.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 "cmTargetPropertyHelper.h" |
4 | | |
5 | | #include "cmGlobalGenerator.h" |
6 | | #include "cmMakefile.h" |
7 | | #include "cmTarget.h" |
8 | | #include "cmValue.h" |
9 | | |
10 | | cmGetTargetPropertyResult cmGetTargetProperty(std::string const& targetName, |
11 | | std::string const& propertyName, |
12 | | cmMakefile& mf, |
13 | | cmValue& propertyValue) |
14 | 0 | { |
15 | 0 | cmTarget* target = mf.FindTargetToUse(targetName); |
16 | 0 | if (!target) { |
17 | 0 | return cmGetTargetPropertyResult::TargetNotFound; |
18 | 0 | } |
19 | 0 | return cmGetTargetProperty(targetName, target, propertyName, mf, |
20 | 0 | propertyValue); |
21 | 0 | } |
22 | | |
23 | | cmGetTargetPropertyResult cmGetTargetProperty(std::string const& targetName, |
24 | | cmTarget const* target, |
25 | | std::string const& propertyName, |
26 | | cmMakefile& mf, |
27 | | cmValue& propertyValue) |
28 | 0 | { |
29 | 0 | if (propertyName == "ALIASED_TARGET" || propertyName == "ALIAS_GLOBAL") { |
30 | 0 | if (mf.IsAlias(targetName)) { |
31 | 0 | if (propertyName == "ALIASED_TARGET") { |
32 | 0 | propertyValue = cmValue(target->GetName()); |
33 | 0 | } else { |
34 | 0 | static std::string const sTrue = "TRUE"; |
35 | 0 | static std::string const sFalse = "FALSE"; |
36 | 0 | propertyValue = cmValue( |
37 | 0 | mf.GetGlobalGenerator()->IsAlias(targetName) ? sTrue : sFalse); |
38 | 0 | } |
39 | 0 | } else { |
40 | 0 | propertyValue = cmValue(nullptr); |
41 | 0 | } |
42 | 0 | return cmGetTargetPropertyResult::Success; |
43 | 0 | } |
44 | | |
45 | 0 | propertyValue = target->GetComputedProperty(propertyName, mf); |
46 | 0 | if (!propertyValue) { |
47 | 0 | propertyValue = target->GetProperty(propertyName); |
48 | 0 | } |
49 | 0 | return cmGetTargetPropertyResult::Success; |
50 | 0 | } |