Merge topic 'avoid-LIB_DEPENDS'

7723e9a058 Do not produce legacy _LIB_DEPENDS cache entries
2124a1364a cmTarget: Remove unnecessary RecordDependencies member
1c5bfab532 cmTarget: Simplify ClearDependencyInformation implementation
910a9d608e cmTarget: Simplify ClearDependencyInformation signature

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com>
Merge-request: !1828
This commit is contained in:
Brad King
2018-03-08 14:54:38 +00:00
committed by Kitware Robot
12 changed files with 77 additions and 33 deletions
+8
View File
@@ -51,6 +51,14 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
to determine whether to report an error on use of deprecated macros or
functions.
Policies Introduced by CMake 3.12
=================================
.. toctree::
:maxdepth: 1
CMP0073: Do not produce legacy _LIB_DEPENDS cache entries. </policy/CMP0073>
Policies Introduced by CMake 3.11
=================================
+25
View File
@@ -0,0 +1,25 @@
CMP0073
-------
Do not produce legacy ``_LIB_DEPENDS`` cache entries.
Ancient CMake versions once used ``<tgt>_LIB_DEPENDS`` cache entries to
propagate library link dependencies. This has long been done by other
means, leaving the :command:`export_library_dependencies` command as the
only user of these values. That command has long been disallowed by
policy :policy:`CMP0033`, but the ``<tgt>_LIB_DEPENDS`` cache entries
were left for compatibility with possible non-standard uses by projects.
CMake 3.12 and above now prefer to not produce these cache entries
at all. This policy provides compatibility with projects that have
not been updated to avoid using them.
The ``OLD`` behavior for this policy is to set ``<tgt>_LIB_DEPENDS`` cache
entries. The ``NEW`` behavior for this policy is to not set them.
This policy was introduced in CMake version 3.12. Use the
:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
Unlike most policies, CMake version |release| does *not* warn
when this policy is not set and simply uses ``OLD`` behavior.
.. include:: DEPRECATED.txt
+5
View File
@@ -0,0 +1,5 @@
avoid-LIB_DEPENDS
-----------------
* CMake no longer produces ``<tgt>_LIB_DEPENDS`` cache entries
for library targets. See policy :policy:`CMP0073`.
+1 -1
View File
@@ -1867,7 +1867,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
// Clear its dependencies. Otherwise, dependencies might persist
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
target->ClearDependencyInformation(*this, lname);
target->ClearDependencyInformation(*this);
if (excludeFromAll) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
+5 -1
View File
@@ -214,6 +214,9 @@ class cmMakefile;
3, 10, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0072, \
"FindOpenGL prefers GLVND by default when available.", 3, 11, 0, \
cmPolicies::WARN) \
SELECT(POLICY, CMP0073, \
"Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0, \
cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
@@ -238,7 +241,8 @@ class cmMakefile;
F(CMP0063) \
F(CMP0065) \
F(CMP0068) \
F(CMP0069)
F(CMP0069) \
F(CMP0073)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies
+8 -29
View File
@@ -186,14 +186,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->ImportedGloballyVisible = vis == VisibilityImportedGlobally;
this->BuildInterfaceIncludesAppended = false;
// only add dependency information for library targets
if (this->TargetTypeValue >= cmStateEnums::STATIC_LIBRARY &&
this->TargetTypeValue <= cmStateEnums::MODULE_LIBRARY) {
this->RecordDependencies = true;
} else {
this->RecordDependencies = false;
}
// Check whether this is a DLL platform.
this->DLLPlatform =
(this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
@@ -635,27 +627,11 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const
return this->LinkDirectories;
}
void cmTarget::ClearDependencyInformation(cmMakefile& mf,
const std::string& target)
void cmTarget::ClearDependencyInformation(cmMakefile& mf)
{
// Clear the dependencies. The cache variable must exist iff we are
// recording dependency information for this target.
std::string depname = target;
std::string depname = this->GetName();
depname += "_LIB_DEPENDS";
if (this->RecordDependencies) {
mf.AddCacheDefinition(depname, "", "Dependencies for target",
cmStateEnums::STATIC);
} else {
if (mf.GetDefinition(depname)) {
std::string message = "Target ";
message += target;
message += " has dependency information when it shouldn't.\n";
message += "Your cache is probably stale. Please remove the entry\n ";
message += depname;
message += "\nfrom the cache.";
cmSystemTools::Error(message.c_str());
}
}
mf.RemoveCacheDefinition(depname);
}
std::string cmTarget::GetDebugGeneratorExpressions(
@@ -752,7 +728,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib,
this->OriginalLinkLibraries.emplace_back(lib, llt);
}
// Add the explicit dependency information for this target. This is
// Add the explicit dependency information for libraries. This is
// simply a set of libraries separated by ";". There should always
// be a trailing ";". These library names are not canonical, in that
// they may be "-framework x", "-ly", "/path/libz.a", etc.
@@ -760,7 +736,10 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib,
// may be purposefully duplicated to handle recursive dependencies,
// and we removing one instance will break the link line. Duplicates
// will be appropriately eliminated at emit time.
if (this->RecordDependencies) {
if (this->TargetTypeValue >= cmStateEnums::STATIC_LIBRARY &&
this->TargetTypeValue <= cmStateEnums::MODULE_LIBRARY &&
(this->GetPolicyStatusCMP0073() == cmPolicies::OLD ||
this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) {
std::string targetEntry = this->Name;
targetEntry += "_LIB_DEPENDS";
std::string dependencies;
+1 -2
View File
@@ -137,7 +137,7 @@ public:
/**
* Clear the dependency information recorded for this target, if any.
*/
void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
void ClearDependencyInformation(cmMakefile& mf);
void AddLinkLibrary(cmMakefile& mf, const std::string& lib,
cmTargetLinkLibraryType llt);
@@ -310,7 +310,6 @@ private:
cmTargetInternalPointer Internal;
cmStateEnums::TargetType TargetTypeValue;
bool HaveInstallRule;
bool RecordDependencies;
bool DLLPlatform;
bool IsAndroid;
bool IsImportedTarget;
@@ -23,6 +23,7 @@
\* CMP0065
\* CMP0068
\* CMP0069
\* CMP0073
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1,3 @@
-- warn_LIB_DEPENDS='general;bar;'
-- old_LIB_DEPENDS='general;bar;'
-- new_LIB_DEPENDS=''
+18
View File
@@ -0,0 +1,18 @@
enable_language(C)
add_library(warn empty.c)
target_link_libraries(warn bar)
message(STATUS "warn_LIB_DEPENDS='${warn_LIB_DEPENDS}'")
cmake_policy(SET CMP0073 OLD)
add_library(old empty.c)
target_link_libraries(old bar)
message(STATUS "old_LIB_DEPENDS='${old_LIB_DEPENDS}'")
cmake_policy(SET CMP0073 NEW)
add_library(new empty.c)
target_link_libraries(new bar)
message(STATUS "new_LIB_DEPENDS='${new_LIB_DEPENDS}'")
if(DEFINED new_LIB_DEPENDS)
message(FATAL_ERROR "new_LIB_DEPENDS set but should not be")
endif()
@@ -1,5 +1,7 @@
include(RunCMake)
run_cmake(CMP0073)
run_cmake(INTERFACEwithNoSources)
run_cmake(OBJECTwithNoSources)
run_cmake(STATICwithNoSources)
View File