summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetPropCommandBase.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2018-10-22 20:48:28 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2018-10-26 16:09:41 (GMT)
commit4babc9058a996e9cccd183eb25eda5faedd04591 (patch)
tree36ad3d5ff4e92a5f91972ae3572a84ed0883675e /Source/cmTargetPropCommandBase.cxx
parent45a49ae58abe835bc3ad446b054fa07035c33d60 (diff)
downloadCMake-4babc9058a996e9cccd183eb25eda5faedd04591.zip
CMake-4babc9058a996e9cccd183eb25eda5faedd04591.tar.gz
CMake-4babc9058a996e9cccd183eb25eda5faedd04591.tar.bz2
cmTargetPropCommandBase: check keywords after parsing
The following was disallowed: add_library(iface INTERFACE) target_link_libraries(iface PUBLIC) just due to the mention of the `PUBLIC` keyword. Instead, only error if there are actually `PUBLIC` dependencies specified (and analogously for other restrictions). Update tests to expect this new behavior.
Diffstat (limited to 'Source/cmTargetPropCommandBase.cxx')
-rw-r--r--Source/cmTargetPropCommandBase.cxx20
1 files changed, 11 insertions, 9 deletions
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 48348f3..1b8ee81 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -84,15 +84,6 @@ bool cmTargetPropCommandBase::ProcessContentArgs(
this->SetError("called with invalid arguments");
return false;
}
- if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
- scope != "INTERFACE") {
- this->SetError("may only set INTERFACE properties on INTERFACE targets");
- return false;
- }
- if (this->Target->IsImported() && scope != "INTERFACE") {
- this->SetError("may only set INTERFACE properties on IMPORTED targets");
- return false;
- }
++argIndex;
@@ -105,6 +96,17 @@ bool cmTargetPropCommandBase::ProcessContentArgs(
}
content.push_back(args[i]);
}
+ if (!content.empty()) {
+ if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
+ scope != "INTERFACE") {
+ this->SetError("may only set INTERFACE properties on INTERFACE targets");
+ return false;
+ }
+ if (this->Target->IsImported() && scope != "INTERFACE") {
+ this->SetError("may only set INTERFACE properties on IMPORTED targets");
+ return false;
+ }
+ }
return this->PopulateTargetProperies(scope, content, prepend, system);
}