mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_compile_definitions\):
|
||||
target_compile_definitions may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_compile_features\):
|
||||
target_compile_features may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_compile_options\):
|
||||
target_compile_options may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_include_directories\):
|
||||
target_include_directories may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_link_directories\):
|
||||
target_link_directories may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_link_options\):
|
||||
target_link_options may only set INTERFACE properties on INTERFACE targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Error at empty_keyword_args.cmake:2 \(target_sources\):
|
||||
target_sources may only set INTERFACE properties on INTERFACE targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:5 \(include\)
|
||||
Reference in New Issue
Block a user