CMP0022: Warn about a given target at most once
Since cmTarget::ComputeLinkInterface is called separately for each "head" target that links a target, the warning we produce when CMP0022 is not set could be repeated. Add explicit logic to allow the warning to appear at most once. Multiple copies of the warning for the same target are almost always identical and therefore redundant. In the rare case that two copies of the warning are different, the second can appear in a future run after the first is fixed.
This commit is contained in:
parent
23d21b78e1
commit
0a561a0347
|
@ -83,10 +83,12 @@ class cmTargetInternals
|
||||||
public:
|
public:
|
||||||
cmTargetInternals()
|
cmTargetInternals()
|
||||||
{
|
{
|
||||||
|
this->PolicyWarnedCMP0022 = false;
|
||||||
this->SourceFileFlagsConstructed = false;
|
this->SourceFileFlagsConstructed = false;
|
||||||
}
|
}
|
||||||
cmTargetInternals(cmTargetInternals const& r)
|
cmTargetInternals(cmTargetInternals const& r)
|
||||||
{
|
{
|
||||||
|
this->PolicyWarnedCMP0022 = false;
|
||||||
this->SourceFileFlagsConstructed = false;
|
this->SourceFileFlagsConstructed = false;
|
||||||
// Only some of these entries are part of the object state.
|
// Only some of these entries are part of the object state.
|
||||||
// Others not copied here are result caches.
|
// Others not copied here are result caches.
|
||||||
|
@ -109,6 +111,7 @@ public:
|
||||||
typedef std::map<TargetConfigPair, OptionalLinkInterface>
|
typedef std::map<TargetConfigPair, OptionalLinkInterface>
|
||||||
LinkInterfaceMapType;
|
LinkInterfaceMapType;
|
||||||
LinkInterfaceMapType LinkInterfaceMap;
|
LinkInterfaceMapType LinkInterfaceMap;
|
||||||
|
bool PolicyWarnedCMP0022;
|
||||||
|
|
||||||
typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType;
|
typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType;
|
||||||
OutputInfoMapType OutputInfoMap;
|
OutputInfoMapType OutputInfoMap;
|
||||||
|
@ -6433,7 +6436,8 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicitLibraries && this->PolicyStatusCMP0022 == cmPolicies::WARN)
|
if(explicitLibraries && this->PolicyStatusCMP0022 == cmPolicies::WARN &&
|
||||||
|
!this->Internal->PolicyWarnedCMP0022)
|
||||||
{
|
{
|
||||||
// Compare the explicitly set old link interface properties to the
|
// Compare the explicitly set old link interface properties to the
|
||||||
// preferred new link interface property one and warn if different.
|
// preferred new link interface property one and warn if different.
|
||||||
|
@ -6455,6 +6459,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
linkIfaceProp << ":\n"
|
linkIfaceProp << ":\n"
|
||||||
" " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
|
" " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
|
||||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
||||||
|
this->Internal->PolicyWarnedCMP0022 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6544,7 +6549,8 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
iface.Languages = impl->Languages;
|
iface.Languages = impl->Languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->PolicyStatusCMP0022 == cmPolicies::WARN)
|
if(this->PolicyStatusCMP0022 == cmPolicies::WARN &&
|
||||||
|
!this->Internal->PolicyWarnedCMP0022)
|
||||||
{
|
{
|
||||||
// Compare the link implementation fallback link interface to the
|
// Compare the link implementation fallback link interface to the
|
||||||
// preferred new link interface property and warn if different.
|
// preferred new link interface property and warn if different.
|
||||||
|
@ -6603,6 +6609,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
"Link implementation:\n"
|
"Link implementation:\n"
|
||||||
" " << oldLibraries << "\n";
|
" " << oldLibraries << "\n";
|
||||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
||||||
|
this->Internal->PolicyWarnedCMP0022 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
^$
|
|
@ -0,0 +1,7 @@
|
||||||
|
enable_language(CXX)
|
||||||
|
|
||||||
|
add_library(testLib empty_vs6_1.cpp)
|
||||||
|
add_executable(testExe empty_vs6_2.cpp)
|
||||||
|
target_link_libraries(testExe testLib)
|
||||||
|
|
||||||
|
export(TARGETS testExe FILE "${CMAKE_CURRENT_BINARY_DIR}/cmp0022NOWARN-exe.cmake")
|
|
@ -1,4 +1,4 @@
|
||||||
CMake Warning \(dev\) in CMakeLists.txt:
|
^CMake Warning \(dev\) in CMakeLists.txt:
|
||||||
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
|
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
|
||||||
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
|
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
|
||||||
cmake_policy command to set the policy and suppress this warning.
|
cmake_policy command to set the policy and suppress this warning.
|
||||||
|
|
|
@ -9,3 +9,8 @@ set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat)
|
||||||
|
|
||||||
add_library(user empty.cpp)
|
add_library(user empty.cpp)
|
||||||
target_link_libraries(user bar)
|
target_link_libraries(user bar)
|
||||||
|
|
||||||
|
# Use "bar" again with a different "head" target to check
|
||||||
|
# that the warning does not appear again.
|
||||||
|
add_library(user2 empty_vs6_3.cpp)
|
||||||
|
target_link_libraries(user2 bar)
|
||||||
|
|
|
@ -4,6 +4,7 @@ run_cmake(CMP0022-WARN)
|
||||||
run_cmake(CMP0022-WARN-tll)
|
run_cmake(CMP0022-WARN-tll)
|
||||||
run_cmake(CMP0022-WARN-static)
|
run_cmake(CMP0022-WARN-static)
|
||||||
run_cmake(CMP0022-WARN-empty-old)
|
run_cmake(CMP0022-WARN-empty-old)
|
||||||
|
run_cmake(CMP0022-NOWARN-exe)
|
||||||
run_cmake(CMP0022-NOWARN-shared)
|
run_cmake(CMP0022-NOWARN-shared)
|
||||||
run_cmake(CMP0022-NOWARN-static)
|
run_cmake(CMP0022-NOWARN-static)
|
||||||
run_cmake(CMP0022-NOWARN-static-link_libraries)
|
run_cmake(CMP0022-NOWARN-static-link_libraries)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "empty.cpp"
|
Loading…
Reference in New Issue