summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAsit Dhal <dhal.asitk@gmail.com>2020-10-24 16:34:50 (GMT)
committerAsit Dhal <dhal.asitk@gmail.com>2020-10-24 19:13:25 (GMT)
commit1a3d125de8b06a57cde26f12426601f422e5c755 (patch)
tree6bba9b0dae39053eefaa8a2dc49bbb01863f0cfa /Source
parenta8e9208f700dd37c2cee744f612741f5e9a3d9a1 (diff)
downloadCMake-1a3d125de8b06a57cde26f12426601f422e5c755.zip
CMake-1a3d125de8b06a57cde26f12426601f422e5c755.tar.gz
CMake-1a3d125de8b06a57cde26f12426601f422e5c755.tar.bz2
target_sources: Support custom targets
Fixes: #21034
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTargetPropCommandBase.cxx34
1 files changed, 25 insertions, 9 deletions
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 9e30136..b050a58 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -45,15 +45,26 @@ bool cmTargetPropCommandBase::HandleArguments(
this->HandleMissingTarget(args[0]);
return false;
}
- if ((this->Target->GetType() != cmStateEnums::EXECUTABLE) &&
- (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::UNKNOWN_LIBRARY)) {
- this->SetError("called with non-compilable target type");
- return false;
+ const bool isRegularTarget =
+ (this->Target->GetType() == cmStateEnums::EXECUTABLE) ||
+ (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY) ||
+ (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY) ||
+ (this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) ||
+ (this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
+ (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) ||
+ (this->Target->GetType() == cmStateEnums::UNKNOWN_LIBRARY);
+ const bool isCustomTarget = this->Target->GetType() == cmStateEnums::UTILITY;
+
+ if (prop == "SOURCES") {
+ if (!isRegularTarget && !isCustomTarget) {
+ this->SetError("called with non-compilable target type");
+ return false;
+ }
+ } else {
+ if (!isRegularTarget) {
+ this->SetError("called with non-compilable target type");
+ return false;
+ }
}
bool system = false;
@@ -131,6 +142,11 @@ bool cmTargetPropCommandBase::ProcessContentArgs(
this->SetError("may only set INTERFACE properties on IMPORTED targets");
return false;
}
+ if (this->Target->GetType() == cmStateEnums::UTILITY &&
+ scope != "PRIVATE") {
+ this->SetError("may only set PRIVATE properties on custom targets");
+ return false;
+ }
}
return this->PopulateTargetProperies(scope, content, prepend, system);
}