Merge topic 'issue-21034'

1a3d125de8 target_sources: Support custom targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5421
This commit is contained in:
Brad King
2020-10-27 11:09:25 +00:00
committed by Kitware Robot
16 changed files with 80 additions and 11 deletions
+25 -9
View File
@@ -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);
}