CMP0022: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-11-18 18:30:50 -05:00
parent e31d1c7600
commit 888259c894
41 changed files with 84 additions and 566 deletions

View File

@ -1,6 +1,9 @@
CMP0022
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
:prop_tgt:`INTERFACE_LINK_LIBRARIES` defines the link interface.
CMake 2.8.11 constructed the 'link interface' of a target from
@ -33,7 +36,5 @@ property for in-build targets, and ignore the old properties matching
``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?``.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.12
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
.. include:: STANDARD_ADVICE.txt
.. include:: DEPRECATED.txt
.. |WARNED_OR_DID_NOT_WARN| replace:: warned
.. include:: REMOVED_EPILOGUE.txt

View File

@ -12,13 +12,9 @@
#include "cmGeneratorTarget.h"
#include "cmLinkItem.h"
#include "cmList.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
cmExportAndroidMKGenerator::cmExportAndroidMKGenerator() = default;
@ -52,20 +48,6 @@ void cmExportAndroidMKGenerator::GenerateInterfaceProperties(
(this->Configurations.empty() ? std::string{} : this->Configurations[0]);
GenerateType const type = this->GetGenerateType();
bool const newCMP0022Behavior =
target->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (!newCMP0022Behavior) {
std::ostringstream w;
if (type == BUILD) {
w << "export(TARGETS ... ANDROID_MK) called with policy CMP0022";
} else {
w << "install( EXPORT_ANDROID_MK ...) called with policy CMP0022";
}
w << " set to OLD for target " << target->Target->GetName() << ". "
<< "The export will only work with CMP0022 set to NEW.";
target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
if (!properties.empty()) {
os << "LOCAL_CPP_FEATURES := rtti exceptions\n";
for (auto const& property : properties) {

View File

@ -7,7 +7,6 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@ -34,13 +33,8 @@ bool cmExportBuildAndroidMKGenerator::GenerateMainFile(std::ostream& os)
return false;
}
bool const newCMP0022Behavior =
gte->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) {
this->PopulateInterfaceLinkLibrariesProperty(
gte, cmGeneratorExpression::BuildInterface, properties);
}
this->PopulateInterfaceLinkLibrariesProperty(
gte, cmGeneratorExpression::BuildInterface, properties);
this->GenerateInterfaceProperties(gte, os, properties);
}

View File

@ -24,7 +24,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@ -72,13 +71,8 @@ bool cmExportBuildCMakeConfigGenerator::GenerateMainFile(std::ostream& os)
return false;
}
bool const newCMP0022Behavior =
gte->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) {
this->PopulateInterfaceLinkLibrariesProperty(
gte, cmGeneratorExpression::BuildInterface, properties);
}
this->PopulateInterfaceLinkLibrariesProperty(
gte, cmGeneratorExpression::BuildInterface, properties);
this->GenerateInterfaceProperties(gte, os, properties);

View File

@ -22,7 +22,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@ -130,11 +129,7 @@ void cmExportCMakeConfigGenerator::SetImportLinkInterface(
return;
}
bool const newCMP0022Behavior =
target->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior && !this->ExportOld) {
if (!this->ExportOld) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
e << "Target \"" << target->GetName()

View File

@ -12,7 +12,6 @@
#include "cmGeneratorTarget.h"
#include "cmInstallExportGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@ -58,13 +57,8 @@ bool cmExportInstallAndroidMKGenerator::GenerateMainFile(std::ostream& os)
return false;
}
bool const newCMP0022Behavior =
gt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) {
this->PopulateInterfaceLinkLibrariesProperty(
gt, cmGeneratorExpression::InstallInterface, properties);
}
this->PopulateInterfaceLinkLibrariesProperty(
gt, cmGeneratorExpression::InstallInterface, properties);
this->GenerateInterfaceProperties(gt, os, properties);
}

View File

@ -25,7 +25,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@ -83,15 +82,10 @@ bool cmExportInstallCMakeConfigGenerator::GenerateMainFile(std::ostream& os)
return false;
}
bool const newCMP0022Behavior =
gt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) {
if (this->PopulateInterfaceLinkLibrariesProperty(
gt, cmGeneratorExpression::InstallInterface, properties) &&
!this->ExportOld) {
this->SetRequiredCMakeVersion(2, 8, 12);
}
if (this->PopulateInterfaceLinkLibrariesProperty(
gt, cmGeneratorExpression::InstallInterface, properties) &&
!this->ExportOld) {
this->SetRequiredCMakeVersion(2, 8, 12);
}
if (targetType == cmStateEnums::INTERFACE_LIBRARY) {
this->SetRequiredCMakeVersion(3, 0, 0);

View File

@ -1394,7 +1394,6 @@ private:
mutable OutputNameMapType OutputNameMap;
mutable std::set<cmLinkItem> UtilityItems;
cmPolicies::PolicyMap PolicyMap;
mutable bool PolicyWarnedCMP0022 = false;
mutable bool PolicyReportedCMP0069 = false;
mutable bool DebugIncludesDone = false;
mutable bool DebugCompileOptionsDone = false;

View File

@ -718,10 +718,6 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config,
}
}
}
} else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
this->GetPolicyStatusCMP0022() == cmPolicies::OLD) {
// The link implementation is the default link interface.
iface.ImplementationIsInterface = true;
}
if (this->LinkLanguagePropagatesToDependents()) {
@ -804,62 +800,10 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// An explicit list of interface libraries may be set for shared
// libraries and executables that export symbols.
bool haveExplicitLibraries = false;
cmValue explicitLibrariesCMP0022OLD;
std::string linkIfacePropCMP0022OLD;
bool const cmp0022NEW = (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
this->GetPolicyStatusCMP0022() != cmPolicies::WARN);
if (cmp0022NEW) {
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
haveExplicitLibraries = !this->Target->GetLinkInterfaceEntries().empty() ||
!this->Target->GetLinkInterfaceDirectEntries().empty() ||
!this->Target->GetLinkInterfaceDirectExcludeEntries().empty();
} else {
// CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
// shared lib or executable.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
// Lookup the per-configuration property.
linkIfacePropCMP0022OLD = cmStrCat("LINK_INTERFACE_LIBRARIES", suffix);
explicitLibrariesCMP0022OLD = this->GetProperty(linkIfacePropCMP0022OLD);
// If not set, try the generic property.
if (!explicitLibrariesCMP0022OLD) {
linkIfacePropCMP0022OLD = "LINK_INTERFACE_LIBRARIES";
explicitLibrariesCMP0022OLD =
this->GetProperty(linkIfacePropCMP0022OLD);
}
}
if (explicitLibrariesCMP0022OLD &&
this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
!this->PolicyWarnedCMP0022) {
// Compare the explicitly set old link interface properties to the
// preferred new link interface property one and warn if different.
cmValue newExplicitLibraries =
this->GetProperty("INTERFACE_LINK_LIBRARIES");
if (newExplicitLibraries &&
(*newExplicitLibraries != *explicitLibrariesCMP0022OLD)) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
"Target \"" << this->GetName() << "\" has an "
"INTERFACE_LINK_LIBRARIES property which differs from its " <<
linkIfacePropCMP0022OLD << " properties."
"\n"
"INTERFACE_LINK_LIBRARIES:\n"
" " << *newExplicitLibraries << "\n" <<
linkIfacePropCMP0022OLD << ":\n"
" " << *explicitLibrariesCMP0022OLD << "\n";
/* clang-format on */
this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING,
w.str());
this->PolicyWarnedCMP0022 = true;
}
}
haveExplicitLibraries = static_cast<bool>(explicitLibrariesCMP0022OLD);
}
bool const haveExplicitLibraries =
!this->Target->GetLinkInterfaceEntries().empty() ||
!this->Target->GetLinkInterfaceDirectEntries().empty() ||
!this->Target->GetLinkInterfaceDirectExcludeEntries().empty();
// There is no implicit link interface for executables or modules
// so if none was explicitly set then there is no link interface.
@ -869,85 +813,21 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
return;
}
iface.Exists = true;
iface.Explicit = true;
// If CMP0022 is NEW then the plain tll signature sets the
// INTERFACE_LINK_LIBRARIES property. Even if the project
// clears it, the link interface is still explicit.
iface.Explicit = cmp0022NEW || explicitLibrariesCMP0022OLD;
if (cmp0022NEW) {
// The interface libraries are specified by INTERFACE_LINK_LIBRARIES.
// Use its special representation directly to get backtraces.
this->ExpandLinkItems(
kINTERFACE_LINK_LIBRARIES, this->Target->GetLinkInterfaceEntries(),
config, headTarget, usage, LinkInterfaceField::Libraries, iface);
this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT,
this->Target->GetLinkInterfaceDirectEntries(),
config, headTarget, usage,
LinkInterfaceField::HeadInclude, iface);
this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE,
this->Target->GetLinkInterfaceDirectExcludeEntries(),
config, headTarget, usage,
LinkInterfaceField::HeadExclude, iface);
} else if (explicitLibrariesCMP0022OLD) {
// The interface libraries have been explicitly set in pre-CMP0022 style.
std::vector<BT<std::string>> entries;
entries.emplace_back(*explicitLibrariesCMP0022OLD);
this->ExpandLinkItems(linkIfacePropCMP0022OLD, cmMakeRange(entries),
config, headTarget, usage,
LinkInterfaceField::Libraries, iface);
}
// If the link interface is explicit, do not fall back to the link impl.
if (iface.Explicit) {
return;
}
// The link implementation is the default link interface.
if (cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibrariesInternal(config, headTarget,
usage)) {
iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(),
impl->Libraries.end());
if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
!this->PolicyWarnedCMP0022 && usage == UseTo::Link) {
// Compare the link implementation fallback link interface to the
// preferred new link interface property and warn if different.
cmLinkInterface ifaceNew;
this->ExpandLinkItems(
kINTERFACE_LINK_LIBRARIES, this->Target->GetLinkInterfaceEntries(),
config, headTarget, usage, LinkInterfaceField::Libraries, ifaceNew);
if (ifaceNew.Libraries != iface.Libraries) {
std::string oldLibraries = cmJoin(impl->Libraries, ";");
std::string newLibraries = cmJoin(ifaceNew.Libraries, ";");
if (oldLibraries.empty()) {
oldLibraries = "(empty)";
}
if (newLibraries.empty()) {
newLibraries = "(empty)";
}
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
"Target \"" << this->GetName() << "\" has an "
"INTERFACE_LINK_LIBRARIES property. "
"This should be preferred as the source of the link interface "
"for this library but because CMP0022 is not set CMake is "
"ignoring the property and using the link implementation "
"as the link interface instead."
"\n"
"INTERFACE_LINK_LIBRARIES:\n"
" " << newLibraries << "\n"
"Link implementation:\n"
" " << oldLibraries << "\n";
/* clang-format on */
this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING,
w.str());
this->PolicyWarnedCMP0022 = true;
}
}
}
// The interface libraries are specified by INTERFACE_LINK_LIBRARIES.
// Use its special representation directly to get backtraces.
this->ExpandLinkItems(
kINTERFACE_LINK_LIBRARIES, this->Target->GetLinkInterfaceEntries(), config,
headTarget, usage, LinkInterfaceField::Libraries, iface);
this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT,
this->Target->GetLinkInterfaceDirectEntries(), config,
headTarget, usage, LinkInterfaceField::HeadInclude,
iface);
this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE,
this->Target->GetLinkInterfaceDirectExcludeEntries(),
config, headTarget, usage,
LinkInterfaceField::HeadExclude, iface);
}
namespace {
@ -1218,9 +1098,7 @@ public:
void TransitiveLinkImpl::Follow(cmGeneratorTarget const* target)
{
if (!target || !this->Followed.insert(target).second ||
target->GetPolicyStatusCMP0022() == cmPolicies::OLD ||
target->GetPolicyStatusCMP0022() == cmPolicies::WARN) {
if (!target || !this->Followed.insert(target).second) {
return;
}

View File

@ -2156,23 +2156,6 @@ bool HandleExportMode(std::vector<std::string> const& args,
cmExportSet& exportSet =
helper.Makefile->GetGlobalGenerator()->GetExportSets()[exp];
if (exportOld) {
for (auto const& te : exportSet.GetTargetExports()) {
cmTarget* tgt =
helper.Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
(tgt && tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if (!newCMP0022Behavior) {
status.SetError(cmStrCat(
"INSTALL(EXPORT) given keyword \""
"EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"",
te->TargetName, "\" does not have policy CMP0022 set to NEW."));
return false;
}
}
}
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(helper.Makefile);

View File

@ -79,7 +79,7 @@ class cmMakefile;
2, 8, 12, NEW) \
SELECT(POLICY, CMP0022, \
"INTERFACE_LINK_LIBRARIES defines the link interface.", 2, 8, 12, \
WARN) \
NEW) \
SELECT( \
POLICY, CMP0023, \
"Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \

View File

@ -999,14 +999,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// Record current policies for later use.
this->impl->Makefile->RecordPolicies(this->impl->PolicyMap);
if (this->impl->TargetType == cmStateEnums::INTERFACE_LIBRARY) {
// This policy is checked in a few conditions. The properties relevant
// to the policy are always ignored for cmStateEnums::INTERFACE_LIBRARY
// targets,
// so ensure that the conditions don't lead to nonsense.
this->impl->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW);
}
std::set<TargetProperty::InitCondition> metConditions;
metConditions.insert(TargetProperty::InitCondition::Always);
if (this->CanCompileSources()) {

View File

@ -25,8 +25,6 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmValue.h"
#include "cmake.h"
namespace {
@ -327,21 +325,6 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
cmSystemTools::SetFatalErrorOccurred();
}
const cmPolicies::PolicyStatus policy22Status =
target->GetPolicyStatusCMP0022();
// If any of the LINK_ options were given, make sure the
// LINK_INTERFACE_LIBRARIES target property exists.
// Use of any of the new keywords implies awareness of
// this property. And if no libraries are named, it should
// result in an empty link interface.
if ((policy22Status == cmPolicies::OLD ||
policy22Status == cmPolicies::WARN) &&
currentProcessingState != ProcessingLinkLibraries &&
!target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
}
return true;
}
@ -528,54 +511,6 @@ bool TLL::HandleLibrary(ProcessingState currentProcessingState,
// property of the target on the LHS shall be populated.)
this->AppendProperty("INTERFACE_LINK_LIBRARIES",
this->Target->GetDebugGeneratorExpressions(lib, llt));
// Stop processing if called without any keyword.
if (currentProcessingState == ProcessingLinkLibraries) {
return true;
}
// Stop processing if policy CMP0022 is set to NEW.
const cmPolicies::PolicyStatus policy22Status =
this->Target->GetPolicyStatusCMP0022();
if (policy22Status != cmPolicies::OLD &&
policy22Status != cmPolicies::WARN) {
return true;
}
// Stop processing if called with an INTERFACE library on the LHS.
if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return true;
}
// Handle (additional) backward-compatibility case where the command was
// called with PUBLIC / INTERFACE / LINK_PUBLIC / LINK_INTERFACE_LIBRARIES.
// (The policy CMP0022 is not set to NEW.)
{
// Get the list of configurations considered to be DEBUG.
std::vector<std::string> debugConfigs =
this->Makefile.GetCMakeInstance()->GetDebugConfigs();
std::string prop;
// Include this library in the link interface for the target.
if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
// Put in the DEBUG configuration interfaces.
for (std::string const& dc : debugConfigs) {
prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
this->AppendProperty(prop, lib);
}
}
if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
// Put in the non-DEBUG configuration interfaces.
this->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
// Make sure the DEBUG configuration interfaces exist so that the
// general one will not be used as a fall-back.
for (std::string const& dc : debugConfigs) {
prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
if (!this->Target->GetProperty(prop)) {
this->Target->SetProperty(prop, "");
}
}
}
}
return true;
}

View File

@ -1,7 +1,4 @@
# Using 2.8 will trigger a deprecation warning. In this case it's explicitly
# intentional since the tests checks various policy implementations prior to
# 3.10
cmake_minimum_required(VERSION 2.8.11) # old enough to not set CMP0022
cmake_minimum_required(VERSION 3.10)
if(POLICY CMP0129)
cmake_policy(SET CMP0129 NEW)
@ -53,38 +50,38 @@ generate_export_header(depC)
target_link_libraries(depC LINK_PUBLIC depA LINK_PUBLIC depA)
assert_property(depA LINK_INTERFACE_LIBRARIES "")
assert_property(depB LINK_INTERFACE_LIBRARIES "")
assert_property(depC LINK_INTERFACE_LIBRARIES "depA;depA")
assert_property(depA INTERFACE_LINK_LIBRARIES "")
assert_property(depB INTERFACE_LINK_LIBRARIES "")
assert_property(depC INTERFACE_LINK_LIBRARIES "depA;depA")
add_executable(targetA targetA.cpp)
target_link_libraries(targetA LINK_INTERFACE_LIBRARIES depA depB)
assert_property(targetA LINK_INTERFACE_LIBRARIES "depA;depB")
assert_property(targetA INTERFACE_LINK_LIBRARIES "depA;depB")
set_target_properties(targetA PROPERTIES LINK_INTERFACE_LIBRARIES "")
set_target_properties(targetA PROPERTIES INTERFACE_LINK_LIBRARIES "")
assert_property(targetA LINK_INTERFACE_LIBRARIES "")
assert_property(targetA INTERFACE_LINK_LIBRARIES "")
add_subdirectory(subdir)
target_link_libraries(targetA subdirlib)
target_link_libraries(targetA depB depC)
assert_property(targetA LINK_INTERFACE_LIBRARIES "")
assert_property(targetA INTERFACE_LINK_LIBRARIES ";subdirlib;depB;depC")
# Exclude depIfaceOnly from ALL so that it will only be built if something
# depends on it. As it is in the link interface of depB, targetA
# will depend on it. That dependency is what is being tested here.
add_library(depIfaceOnly SHARED EXCLUDE_FROM_ALL depIfaceOnly.cpp)
generate_export_header(depIfaceOnly)
set_property(TARGET depB APPEND PROPERTY LINK_INTERFACE_LIBRARIES depIfaceOnly)
set_property(TARGET depB APPEND PROPERTY INTERFACE_LINK_LIBRARIES depIfaceOnly)
add_library(depD SHARED depD.cpp)
generate_export_header(depD)
set_property(TARGET depD APPEND PROPERTY
LINK_INTERFACE_LIBRARIES
INTERFACE_LINK_LIBRARIES
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:depA>
)

View File

@ -1,5 +1,5 @@
set(CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_DEPENDENCIES "1942b4fa-b2c5-4546-9385-83f254070067")
cmake_minimum_required(VERSION 2.8.11) # old enough to not set CMP0022
cmake_minimum_required(VERSION 3.10)
if(POLICY CMP0129)
cmake_policy(SET CMP0129 NEW)
endif()
@ -22,10 +22,9 @@ add_library(testExe2libImp SHARED testExe2libImp.c)
set_property(TARGET testExe2libImp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl)
add_library(testExe2lib SHARED testExe2lib.c)
target_link_libraries(testExe2lib testExe2libImp)
set_property(TARGET testExe2lib PROPERTY LINK_INTERFACE_LIBRARIES "")
add_executable(testExe2 testExe2.c)
set_property(TARGET testExe2 PROPERTY ENABLE_EXPORTS 1)
set_property(TARGET testExe2 PROPERTY LINK_INTERFACE_LIBRARIES testExe2lib)
set_property(TARGET testExe2 PROPERTY INTERFACE_LINK_LIBRARIES testExe2lib)
add_library(compileOnly INTERFACE)
target_compile_definitions(compileOnly INTERFACE FROM_compileOnly)
@ -36,7 +35,6 @@ target_link_libraries(noUses INTERFACE this::target_does_not_exist)
add_library(testLib1 STATIC testLib1.c)
add_library(testLib2 STATIC testLib2.c)
target_link_libraries(testLib2 testLib1)
target_link_libraries(testLib2
PRIVATE
testLib1
@ -68,7 +66,6 @@ set_property(TARGET testLib3Imp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl)
target_link_libraries(testLib3Imp testLib3ImpDep)
add_library(testLib3 SHARED testLib3.c)
target_link_libraries(testLib3 testLib3Imp)
set_property(TARGET testLib3 PROPERTY LINK_INTERFACE_LIBRARIES "")
set_property(TARGET testLib3 PROPERTY VERSION 1.2)
set_property(TARGET testLib3 PROPERTY SOVERSION 3)
@ -108,8 +105,6 @@ else()
set(maybe_OBJECTS_DESTINATION "")
endif()
cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
add_library(testLib9ObjPub OBJECT testLib9ObjPub.c)
target_compile_definitions(testLib9ObjPub INTERFACE testLib9ObjPub_USED)
add_library(testLib9ObjPriv OBJECT testLib9ObjPriv.c)
@ -119,41 +114,37 @@ target_compile_definitions(testLib9ObjIface INTERFACE testLib9ObjIface_USED)
add_library(testLib9 STATIC testLib9.c)
target_link_libraries(testLib9 INTERFACE testLib9ObjIface PUBLIC testLib9ObjPub PRIVATE testLib9ObjPriv)
target_link_libraries(testLib9 PUBLIC Foo::Foo)
cmake_policy(POP)
block()
cmake_policy(SET CMP0022 NEW)
add_library(testLib10 STATIC testLib10.c)
set_target_properties(testLib10 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_C"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_L"
INTERFACE_CUSTOM_C "TESTLIB10_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB10_INTERFACE_CUSTOM_L"
)
target_compile_definitions(testLib10 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_L>"
)
add_library(testLib11 STATIC testLib11.c)
target_link_libraries(testLib11 PRIVATE testLib10)
set_target_properties(testLib11 PROPERTIES
INTERFACE_CUSTOM_C "TESTLIB11_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB11_INTERFACE_CUSTOM_L"
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_D"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_M"
INTERFACE_CUSTOM_D "TESTLIB11_INTERFACE_CUSTOM_D"
INTERFACE_CUSTOM_M "TESTLIB11_INTERFACE_CUSTOM_M"
)
target_compile_definitions(testLib11 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_D>"
"$<TARGET_PROPERTY:CUSTOM_L>"
"$<TARGET_PROPERTY:CUSTOM_M>"
)
endblock()
add_library(testLib10 STATIC testLib10.c)
set_target_properties(testLib10 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_C"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_L"
INTERFACE_CUSTOM_C "TESTLIB10_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB10_INTERFACE_CUSTOM_L"
)
target_compile_definitions(testLib10 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_L>"
)
add_library(testLib11 STATIC testLib11.c)
target_link_libraries(testLib11 PRIVATE testLib10)
set_target_properties(testLib11 PROPERTIES
INTERFACE_CUSTOM_C "TESTLIB11_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB11_INTERFACE_CUSTOM_L"
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_D"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_M"
INTERFACE_CUSTOM_D "TESTLIB11_INTERFACE_CUSTOM_D"
INTERFACE_CUSTOM_M "TESTLIB11_INTERFACE_CUSTOM_M"
)
target_compile_definitions(testLib11 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_D>"
"$<TARGET_PROPERTY:CUSTOM_L>"
"$<TARGET_PROPERTY:CUSTOM_M>"
)
# Test using the target_link_libraries command to set the
# LINK_INTERFACE_LIBRARIES* properties. We construct two libraries
# INTERFACE_LINK_LIBRARIES properties. We construct two libraries
# providing the same two symbols. In each library one of the symbols
# will work and the other one will fail to link. The import part of
# this test will try to use the symbol corresponding to the
@ -166,7 +157,7 @@ set_property(TARGET testLib4libdbg PROPERTY COMPILE_DEFINITIONS LIB_DBG)
set_property(TARGET testLib4libopt PROPERTY COMPILE_DEFINITIONS LIB_OPT)
target_link_libraries(testLib4
LINK_INTERFACE_LIBRARIES
testLib4lib debug testLib4libdbg optimized testLib4libopt
testLib4lib debug $<TARGET_NAME:testLib4libdbg> optimized $<TARGET_NAME:testLib4libopt>
)
add_executable(testExe3 testExe3.c)
@ -219,9 +210,6 @@ install(
DESTINATION include/testInterfaceIncludeUser
)
cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
# Test control over direct linking.
include(../../InterfaceLinkLibrariesDirect/testStaticLibPlugin.cmake)
include(../../InterfaceLinkLibrariesDirect/testSharedLibWithHelper.cmake)
@ -237,10 +225,8 @@ add_library(testLibDepends testLibDepends.c)
target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired)
add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c)
target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate)
cmake_policy(POP)
cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0079 NEW)
add_library(TopDirLib STATIC testTopDirLib.c)
add_subdirectory(SubDirLinkA)
@ -387,8 +373,6 @@ install(FILES
DESTINATION include/testSharedLibRequiredUser
)
cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
add_library(testSharedLibRequiredUser2 SHARED testSharedLibRequiredUser2.cpp)
generate_export_header(testSharedLibRequiredUser2)
set_property(TARGET testSharedLibRequiredUser2 APPEND PROPERTY
@ -401,7 +385,6 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequireduser2_export.h"
DESTINATION include/testSharedLibRequiredUser2
)
cmake_policy(POP)
cmake_policy(PUSH)
cmake_policy(SET CMP0041 NEW)
@ -426,28 +409,17 @@ set_property(TARGET testSharedLibDepends APPEND PROPERTY
)
cmake_policy(POP)
# LINK_PRIVATE because the LINK_INTERFACE_LIBRARIES is specified above.
target_link_libraries(testSharedLibDepends LINK_PRIVATE testSharedLibRequired)
target_link_libraries(testSharedLibDepends LINK_PUBLIC renamed_on_export)
target_link_libraries(testSharedLibDepends LINK_INTERFACE_LIBRARIES
target_link_libraries(testSharedLibDepends INTERFACE
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:$<TARGET_NAME:testSharedLibRequired>>)
cmake_policy(PUSH)
cmake_policy(SET CMP0022 OLD)
add_library(cmp0022OLD SHARED cmp0022_vs6_1.cpp)
generate_export_header(cmp0022OLD BASE_NAME cmp0022)
target_include_directories(cmp0022OLD PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>"
)
cmake_policy(SET CMP0022 NEW)
add_library(cmp0022NEW SHARED cmp0022_vs6_1.cpp)
set_property(TARGET cmp0022NEW PROPERTY DEFINE_SYMBOL cmp0022OLD_EXPORTS)
generate_export_header(cmp0022NEW BASE_NAME cmp0022)
target_include_directories(cmp0022NEW PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>"
)
cmake_policy(POP)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmp0022.h"
"${CMAKE_CURRENT_BINARY_DIR}/cmp0022_export.h"
@ -466,9 +438,6 @@ set_property(TARGET testLib4 PROPERTY
EXPORT_PROPERTIES EXPORTED_PROPERTY2 EXPORTED_PROPERTY3)
set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2)
# set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLibIncludeRequired2) # TODO: Test for error
set_property(TARGET cmp0022OLD APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2)
set_property(TARGET cmp0022OLD APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib3)
add_library(noIncludesInterface empty.cpp)
@ -622,7 +591,7 @@ install(
testSharedLibWithHelper testSharedLibHelperObj
testExeWithPluginHelper testExePluginHelperObj
testMod1 testMod2
cmp0022NEW cmp0022OLD
cmp0022NEW
TopDirLib SubDirLinkA
systemlib
testInterfaceIncludeUser
@ -684,7 +653,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3
testExe2libImp testLib3Imp testLib3ImpDep subdirlib
testSharedLibRequired testSharedLibRequiredUser testSharedLibRequiredUser2
testSharedLibDepends renamed_on_export
cmp0022NEW cmp0022OLD
cmp0022NEW
TopDirLib SubDirLinkA
systemlib noUses
testInterfaceIncludeUser

View File

@ -186,13 +186,9 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND
endforeach()
endif()
add_executable(cmp0022OLD_test cmp0022OLD_test_vs6_1.cpp)
target_link_libraries(cmp0022OLD_test bld_cmp0022OLD)
add_executable(cmp0022NEW_test cmp0022NEW_test_vs6_1.cpp)
target_link_libraries(cmp0022NEW_test bld_cmp0022NEW)
add_executable(cmp0022OLD_exp_test cmp0022OLD_test_vs6_2.cpp)
target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD)
add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp)
target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW)
@ -427,32 +423,16 @@ target_link_libraries(iface_test_bld bld_testSharedLibDepends)
set_property(TARGET iface_test_bld PROPERTY NO_SYSTEM_FROM_IMPORTED 1)
set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY
LINK_INTERFACE_LIBRARIES
INTERFACE_LINK_LIBRARIES
excludedFromAll
)
get_target_property(_configs bld_testSharedLibRequired IMPORTED_CONFIGURATIONS)
foreach(_config ${_configs})
set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
excludedFromAll
)
endforeach()
unset(_configs)
add_executable(iface_test_exp iface_test.cpp)
target_link_libraries(iface_test_exp testSharedLibDepends)
set_property(TARGET testSharedLibDepends APPEND PROPERTY
LINK_INTERFACE_LIBRARIES
INTERFACE_LINK_LIBRARIES
excludedFromAll
)
get_target_property(_configs testSharedLibDepends IMPORTED_CONFIGURATIONS)
foreach(_config ${_configs})
set_property(TARGET testSharedLibDepends APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
excludedFromAll
)
endforeach()
unset(_configs)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
OR CMAKE_C_COMPILER_ID MATCHES "LCC"

View File

@ -1,12 +0,0 @@
#ifdef USING_TESTLIB2
# error Unexpected USING_TESTLIB2
#endif
#ifndef USING_TESTLIB3
# error Expected USING_TESTLIB3
#endif
int main(void)
{
return 0;
}

View File

@ -1 +0,0 @@
#include "cmp0022OLD_test.cpp"

View File

@ -1 +0,0 @@
#include "cmp0022OLD_test.cpp"

View File

@ -1,7 +1,5 @@
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0022 NEW)
project(InterfaceLinkLibraries)
add_library(foo_shared SHARED foo_vs6_1.cpp)

View File

@ -1,7 +0,0 @@
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")

View File

@ -1,8 +1,6 @@
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
add_library(foo STATIC empty_vs6_1.cpp)
add_library(bar STATIC empty_vs6_2.cpp)
add_library(bat STATIC empty_vs6_3.cpp)

View File

@ -1,19 +0,0 @@
^CMake Warning \(dev\) in CMakeLists\.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "bar" has an INTERFACE_LINK_LIBRARIES property. This should be
preferred as the source of the link interface for this library but because
CMP0022 is not set CMake is ignoring the property and using the link
implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
foo
Link implementation:
\(empty\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,10 +0,0 @@
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
set_property(TARGET bar PROPERTY INTERFACE_LINK_LIBRARIES foo)
add_library(user empty.cpp)
target_link_libraries(user bar)

View File

@ -1,19 +0,0 @@
CMake Warning \(dev\) in CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "bar" has an INTERFACE_LINK_LIBRARIES property. This should be
preferred as the source of the link interface for this library but because
CMP0022 is not set CMake is ignoring the property and using the link
implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
foo
Link implementation:
bat
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -1,11 +0,0 @@
enable_language(CXX)
add_library(foo STATIC empty_vs6_1.cpp)
add_library(bar STATIC empty_vs6_2.cpp)
add_library(bat STATIC empty_vs6_3.cpp)
set_property(TARGET bar PROPERTY INTERFACE_LINK_LIBRARIES foo)
set_property(TARGET bar PROPERTY LINK_LIBRARIES bat)
add_library(user empty.cpp)
target_link_libraries(user bar)

View File

@ -1,17 +0,0 @@
^CMake Warning \(dev\) in CMakeLists\.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from
its LINK_INTERFACE_LIBRARIES properties.
INTERFACE_LINK_LIBRARIES:
foo
LINK_INTERFACE_LIBRARIES:
bat
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -1,17 +0,0 @@
CMake Warning \(dev\) in CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from
its LINK_INTERFACE_LIBRARIES(_DEBUG)? properties.
INTERFACE_LINK_LIBRARIES:
foo
LINK_INTERFACE_LIBRARIES(_DEBUG)?:
bat
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,13 +0,0 @@
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)
target_link_libraries(bar LINK_PUBLIC foo)
# Replace the compatibility values set by target_link_libraries
set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat)
set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES_DEBUG bat)
add_library(user SHARED empty.cpp)
target_link_libraries(user bar)

View File

@ -1,18 +0,0 @@
enable_language(CXX)
cmake_policy(SET CMP0042 NEW)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)
set_property(TARGET bar PROPERTY INTERFACE_LINK_LIBRARIES foo)
set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat)
add_library(user empty.cpp)
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)

View File

@ -1,7 +1,5 @@
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
add_library(testLib empty_vs6_1.cpp)
add_executable(testExe empty_vs6_2.cpp)
target_link_libraries(testExe testLib)

View File

@ -1,8 +1,6 @@
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
add_library(cmp0022NEW SHARED empty_vs6_1.cpp)
add_library(testLib SHARED empty_vs6_2.cpp)

View File

@ -1,8 +1,6 @@
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
add_library(cmp0022NEW SHARED empty_vs6_1.cpp)
add_library(testLib SHARED empty_vs6_2.cpp)

View File

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -1,11 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(CMP0022-WARN)
run_cmake(CMP0022-WARN-tll)
run_cmake(CMP0022-WARN-static)
run_cmake(CMP0022-WARN-empty-old)
run_cmake(CMP0022-NOWARN-exe)
run_cmake(CMP0022-NOWARN-shared)
run_cmake(CMP0022-NOWARN-static)
run_cmake(CMP0022-NOWARN-static-NEW)

View File

@ -1,5 +1,3 @@
cmake_policy(SET CMP0022 NEW)
enable_language(C)
add_library(AnObjLib OBJECT a.c)

View File

@ -1,5 +1,3 @@
cmake_policy(SET CMP0022 NEW)
enable_language(C)
add_library(AnObjLib OBJECT a.c)

View File

@ -1,6 +1,5 @@
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0023 NEW)
add_library(somelib empty.cpp)