Merge topic 'unk_imported_location'

359c500a24 cmTarget: Raise error if imported target location is not set

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5113
This commit is contained in:
Brad King
2020-08-25 14:30:06 +00:00
committed by Kitware Robot
26 changed files with 143 additions and 12 deletions

View File

@@ -326,7 +326,11 @@ class cmMakefile;
19, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0110, \
"add_test() supports arbitrary characters in test names.", 3, 19, 0, \
cmPolicies::WARN)
cmPolicies::WARN) \
SELECT(POLICY, CMP0111, \
"An imported target with a missing location fails during " \
"generation.", \
3, 19, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \

View File

@@ -2039,6 +2039,37 @@ std::string cmTarget::ImportedGetFullPath(
}
if (result.empty()) {
auto message = [&]() -> std::string {
std::string unset;
std::string configuration;
if (artifact == cmStateEnums::RuntimeBinaryArtifact) {
unset = "IMPORTED_LOCATION";
} else if (artifact == cmStateEnums::ImportLibraryArtifact) {
unset = "IMPORTED_IMPLIB";
}
if (!config.empty()) {
configuration = cmStrCat(" configuration \"", config, "\"");
}
return cmStrCat(unset, " not set for imported target \"",
this->GetName(), "\"", configuration, ".");
};
switch (this->GetPolicyStatus(cmPolicies::CMP0111)) {
case cmPolicies::WARN:
impl->Makefile->IssueMessage(
MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0111) + "\n" +
message());
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
default:
impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, message());
}
result = cmStrCat(this->GetName(), "-NOTFOUND");
}
return result;