diff options
author | Raul Tambre <raul@tambre.ee> | 2020-08-08 10:17:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-08-21 12:38:39 (GMT) |
commit | 359c500a2466ffc2507b81c0089bce18fd5debbb (patch) | |
tree | e8eba9aa91e55b068a9b92989813a3db131befd5 /Source/cmTarget.cxx | |
parent | 692bc2de9475d14a2f40b94d88ea91db2df5311c (diff) | |
download | CMake-359c500a2466ffc2507b81c0089bce18fd5debbb.zip CMake-359c500a2466ffc2507b81c0089bce18fd5debbb.tar.gz CMake-359c500a2466ffc2507b81c0089bce18fd5debbb.tar.bz2 |
cmTarget: Raise error if imported target location is not set
Previously we would synthesize <TARGET_NAME>-NOTFOUND as the location. This
would then end up on the link line and cause build failures.
Policy CMP0110 is added to control this behaviour.
Fixes #19080, #19943.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60416a3..bea9001 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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; |