cmTarget: Do not enforce CMP0111 on imported INTERFACE libraries
Fix logic added by commit 359c500a24
(cmTarget: Raise error if imported
target location is not set, 2020-08-08, v3.19.0-rc1~273^2) to exclude
INTERFACE libraries from the policy. They have no location.
Fixes: #21470
This commit is contained in:
parent
43c95df8fb
commit
f06f4b517c
@ -2045,35 +2045,37 @@ std::string cmTarget::ImportedGetFullPath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result.empty()) {
|
if (result.empty()) {
|
||||||
auto message = [&]() -> std::string {
|
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
|
||||||
std::string unset;
|
auto message = [&]() -> std::string {
|
||||||
std::string configuration;
|
std::string unset;
|
||||||
|
std::string configuration;
|
||||||
|
|
||||||
if (artifact == cmStateEnums::RuntimeBinaryArtifact) {
|
if (artifact == cmStateEnums::RuntimeBinaryArtifact) {
|
||||||
unset = "IMPORTED_LOCATION";
|
unset = "IMPORTED_LOCATION";
|
||||||
} else if (artifact == cmStateEnums::ImportLibraryArtifact) {
|
} else if (artifact == cmStateEnums::ImportLibraryArtifact) {
|
||||||
unset = "IMPORTED_IMPLIB";
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
result = cmStrCat(this->GetName(), "-NOTFOUND");
|
||||||
|
@ -4,6 +4,7 @@ set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder")
|
|||||||
add_library(unknown_lib UNKNOWN IMPORTED)
|
add_library(unknown_lib UNKNOWN IMPORTED)
|
||||||
add_library(static_lib STATIC IMPORTED)
|
add_library(static_lib STATIC IMPORTED)
|
||||||
add_library(shared_lib SHARED IMPORTED)
|
add_library(shared_lib SHARED IMPORTED)
|
||||||
|
add_library(interface_lib INTERFACE IMPORTED)
|
||||||
|
|
||||||
add_executable(executable main.cpp)
|
add_library(module MODULE module.cpp)
|
||||||
target_link_libraries(executable unknown_lib static_lib shared_lib)
|
target_link_libraries(module unknown_lib static_lib shared_lib interface_lib)
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
4
Tests/RunCMake/CMP0111/module.cpp
Normal file
4
Tests/RunCMake/CMP0111/module.cpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
int module()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user