summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-07-21 17:22:26 (GMT)
committerBrad King <brad.king@kitware.com>2020-07-23 17:31:45 (GMT)
commit2f0790df5046bfc99383317eb7d24cd4030200be (patch)
tree60362de080828e4b1b4fcd849b2d3e07ac157a42 /Source/cmTarget.cxx
parent422d9a0ab21ff430e5fd012cf965dd92068d185f (diff)
downloadCMake-2f0790df5046bfc99383317eb7d24cd4030200be.zip
CMake-2f0790df5046bfc99383317eb7d24cd4030200be.tar.gz
CMake-2f0790df5046bfc99383317eb7d24cd4030200be.tar.bz2
Factor out generator checks for filtering on non-compiling targets
Add a `cmGeneratorTarget::CanCompileSources` helper method to tell generators whether a target might compile anything.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx31
1 files changed, 24 insertions, 7 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 083095b..70bffa6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -272,8 +272,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
};
// Setup default property values.
- if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
- this->GetType() != cmStateEnums::UTILITY) {
+ if (this->CanCompileSources()) {
initProp("ANDROID_API");
initProp("ANDROID_API_MIN");
initProp("ANDROID_ARCH");
@@ -505,6 +504,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
impl->TargetType == cmStateEnums::MODULE_LIBRARY) {
this->SetProperty("POSITION_INDEPENDENT_CODE", "True");
+ } else if (this->CanCompileSources()) {
+ initProp("POSITION_INDEPENDENT_CODE");
}
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
impl->TargetType == cmStateEnums::EXECUTABLE) {
@@ -512,11 +513,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("WINDOWS_EXPORT_ALL_SYMBOLS");
}
- if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
- this->GetType() != cmStateEnums::UTILITY) {
- initProp("POSITION_INDEPENDENT_CODE");
- }
-
// Record current policies for later use.
impl->Makefile->RecordPolicies(impl->PolicyMap);
@@ -1910,6 +1906,27 @@ bool cmTarget::IsPerConfig() const
return impl->PerConfig;
}
+bool cmTarget::CanCompileSources() const
+{
+ if (this->IsImported()) {
+ return false;
+ }
+ switch (this->GetType()) {
+ case cmStateEnums::EXECUTABLE:
+ case cmStateEnums::STATIC_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ return true;
+ case cmStateEnums::UTILITY:
+ case cmStateEnums::INTERFACE_LIBRARY:
+ case cmStateEnums::GLOBAL_TARGET:
+ case cmStateEnums::UNKNOWN_LIBRARY:
+ break;
+ }
+ return false;
+}
+
const char* cmTarget::GetSuffixVariableInternal(
cmStateEnums::ArtifactType artifact) const
{