CMP0024: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-11-22 16:35:44 -05:00
parent 2994eb88c3
commit 65b45de1dd
13 changed files with 22 additions and 115 deletions

View File

@ -1,6 +1,9 @@
CMP0024
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Disallow include export result.
CMake 2.8.12 and lower allowed use of the :command:`include` command with the
@ -18,7 +21,5 @@ an :command:`export` command. The ``NEW`` behavior for this policy is not to
allow including the result of an :command:`export` command.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
.. |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

@ -4716,7 +4716,7 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026(
// LOCATION property or to export() a file to be include()d. However
// there is no cmGeneratorTarget at configure-time, so search the SOURCES
// for TARGET_OBJECTS instead for backwards compatibility with OLD
// behavior of CMP0024 and CMP0026 only.
// behavior of CMP0026 only.
cmBTStringRange rng = this->Target->GetSourceEntries();
for (auto const& entry : rng) {
cmList files{ entry.Value };

View File

@ -239,7 +239,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
// LOCATION property or to export() a file to be include()d. However
// there is no cmGeneratorTarget at configure-time, so search the SOURCES
// for TARGET_OBJECTS instead for backwards compatibility with OLD
// behavior of CMP0024 and CMP0026 only.
// behavior of CMP0026 only.
cmBTStringRange sourceEntries = this->Target->GetSourceEntries();
for (auto const& entry : sourceEntries) {

View File

@ -129,7 +129,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->CurrentConfigureMakefile = nullptr;
this->TryCompileOuterMakefile = nullptr;
this->ConfigureDoneCMP0026AndCMP0024 = false;
this->ConfigureDoneCMP0026 = false;
this->FirstTimeProgress = 0.0f;
cm->GetState()->SetIsGeneratorMultiConfig(false);
@ -315,24 +315,6 @@ void cmGlobalGenerator::AddBuildExportExportSet(
this->AddBuildExportSet(gen);
}
bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
{
auto const it = this->BuildExportSets.find(file);
if (it != this->BuildExportSets.end()) {
bool result = it->second->GenerateImportFile();
if (!this->ConfigureDoneCMP0026AndCMP0024) {
for (const auto& m : this->Makefiles) {
m->RemoveExportBuildFileGeneratorCMP0024(it->second);
}
}
this->BuildExportSets.erase(it);
return result;
}
return false;
}
void cmGlobalGenerator::ForceLinkerLanguages()
{
}
@ -1383,11 +1365,11 @@ void cmGlobalGenerator::Configure()
}
// now do it
this->ConfigureDoneCMP0026AndCMP0024 = false;
this->ConfigureDoneCMP0026 = false;
dirMf->Configure();
dirMf->EnforceDirectoryLevelRules();
this->ConfigureDoneCMP0026AndCMP0024 = true;
this->ConfigureDoneCMP0026 = true;
// Put a copy of each global target in every directory.
{

View File

@ -621,7 +621,6 @@ public:
void AddBuildExportSet(cmExportBuildFileGenerator* gen);
void AddBuildExportExportSet(cmExportBuildFileGenerator* gen);
bool IsExportedTargetsFile(const std::string& filename) const;
bool GenerateImportFile(const std::string& file);
cmExportBuildFileGenerator* GetExportedTargetsFile(
const std::string& filename) const;
void AddCMP0042WarnTarget(const std::string& target);
@ -640,10 +639,7 @@ public:
cmFileLockPool& GetFileLockPool() { return this->FileLockPool; }
#endif
bool GetConfigureDoneCMP0026() const
{
return this->ConfigureDoneCMP0026AndCMP0024;
}
bool GetConfigureDoneCMP0026() const { return this->ConfigureDoneCMP0026; }
std::string MakeSilentFlag;
@ -945,6 +941,6 @@ protected:
bool ForceUnixPaths;
bool ToolSupportsColor;
bool InstallTargetEnabled;
bool ConfigureDoneCMP0026AndCMP0024;
bool ConfigureDoneCMP0026;
bool AllowGlobalTargetCodegen;
};

View File

@ -3,7 +3,6 @@
#include "cmIncludeCommand.h"
#include <map>
#include <sstream>
#include <utility>
#include "cmExecutionStatus.h"
@ -117,36 +116,15 @@ bool cmIncludeCommand(std::vector<std::string> const& args,
cmGlobalGenerator* gg = status.GetMakefile().GetGlobalGenerator();
if (gg->IsExportedTargetsFile(fname_abs)) {
const char* modal = nullptr;
std::ostringstream e;
MessageType messageType = MessageType::AUTHOR_WARNING;
switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0024)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0024) << "\n";
modal = "should";
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
modal = "may";
messageType = MessageType::FATAL_ERROR;
}
if (modal) {
e << "The file\n " << fname_abs
<< "\nwas generated by the export() "
"command. It "
<< modal
<< " not be used as the argument to the "
"include() command. Use ALIAS targets instead to refer to targets "
"by alternative names.\n";
status.GetMakefile().IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
gg->CreateGenerationObjects();
gg->GenerateImportFile(fname_abs);
status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
"The file\n ", fname_abs,
"\nwas generated by the export() "
"command. It may not be used as the argument to the "
"include() command. Use ALIAS targets instead to refer to targets "
"by alternative names.\n"));
return false;
}
std::string listFile = cmSystemTools::CollapseFullPath(

View File

@ -952,20 +952,6 @@ cmMakefile::GetExportBuildFileGenerators() const
return this->ExportBuildFileGenerators;
}
void cmMakefile::RemoveExportBuildFileGeneratorCMP0024(
cmExportBuildFileGenerator* gen)
{
auto it =
std::find_if(this->ExportBuildFileGenerators.begin(),
this->ExportBuildFileGenerators.end(),
[gen](std::unique_ptr<cmExportBuildFileGenerator> const& p) {
return p.get() == gen;
});
if (it != this->ExportBuildFileGenerators.end()) {
this->ExportBuildFileGenerators.erase(it);
}
}
void cmMakefile::AddExportBuildFileGenerator(
std::unique_ptr<cmExportBuildFileGenerator> gen)
{

View File

@ -1034,7 +1034,6 @@ public:
std::vector<std::unique_ptr<cmExportBuildFileGenerator>> const&
GetExportBuildFileGenerators() const;
void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen);
void AddExportBuildFileGenerator(
std::unique_ptr<cmExportBuildFileGenerator> gen);

View File

@ -84,7 +84,7 @@ class cmMakefile;
POLICY, CMP0023, \
"Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \
8, 12, NEW) \
SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0, WARN) \
SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0, NEW) \
SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.", \
3, 0, 0, WARN) \
SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \

View File

@ -1,25 +0,0 @@
^CMake Deprecation Warning at CMP0024-WARN\.cmake:[0-9]+ \(cmake_policy\):
Compatibility with CMake < 3\.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value\. Or, use the <min>\.\.\.<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Warning \(dev\) at subdir2/CMakeLists\.txt:2 \(include\):
Policy CMP0024 is not set: Disallow include export result. Run "cmake
--help-policy CMP0024" for policy details\. Use the cmake_policy command to
set the policy and suppress this warning\.
The file
[^
]*/Tests/RunCMake/include/CMP0024-WARN-build/subdir1/theTargets\.cmake
was generated by the export\(\) command\. It should not be used as the
argument to the include\(\) command\. Use ALIAS targets instead to refer to
targets by alternative names\.
This warning is for project developers\. Use -Wno-dev to suppress it\.

View File

@ -1,8 +0,0 @@
cmake_policy(VERSION 2.8.12) # Leave CMP0024 unset.
enable_language(CXX)
add_library(foo SHARED empty.cpp)
add_subdirectory(subdir1)
add_subdirectory(subdir2)

View File

@ -2,7 +2,6 @@ include(RunCMake)
run_cmake(EmptyString)
run_cmake(EmptyStringOptional)
run_cmake(CMP0024-WARN)
run_cmake(CMP0024-NEW)
run_cmake(ExportExportInclude)
run_cmake(IncludeIsDirectory)