CMP0048: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-12-05 14:54:46 -05:00
parent 05b2c563bb
commit 292048874f
43 changed files with 19 additions and 138 deletions

View File

@@ -1,6 +1,9 @@
CMP0048
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
The :command:`project` command manages ``VERSION`` variables.
CMake version 3.0 introduced the ``VERSION`` option of the :command:`project`
@@ -17,7 +20,5 @@ The ``NEW`` behavior for this policy is to set ``VERSION`` as documented by the
:command:`project` 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

@@ -1694,13 +1694,9 @@ void cmMakefile::Configure()
"CMake is pretending there is a \"project(Project)\" command on "
"the first line.",
this->Backtrace);
cmListFileFunction project{ "project",
0,
0,
{ { "Project", cmListFileArgument::Unquoted,
0 },
{ "__CMAKE_INJECTED_PROJECT_COMMAND__",
cmListFileArgument::Unquoted, 0 } } };
cmListFileFunction project{
"project", 0, 0, { { "Project", cmListFileArgument::Unquoted, 0 } }
};
listFile.Functions.insert(listFile.Functions.begin(), project);
}
}

View File

@@ -145,7 +145,7 @@ class cmMakefile;
SELECT(POLICY, CMP0047, "Use QCC compiler id for the qcc drivers on QNX.", \
3, 0, 0, NEW) \
SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \
0, 0, WARN) \
0, 0, NEW) \
SELECT(POLICY, CMP0049, \
"Do not expand variables in target source entries.", 3, 0, 0, WARN) \
SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.", \

View File

@@ -107,7 +107,6 @@ bool cmProjectCommand(std::vector<std::string> const& args,
bool haveLanguages = false;
bool haveDescription = false;
bool haveHomepage = false;
bool injectedProjectCommand = false;
std::string version;
std::string description;
std::string homepage;
@@ -198,8 +197,6 @@ bool cmProjectCommand(std::vector<std::string> const& args,
"by a value that expanded to nothing.");
resetReporter();
};
} else if (i == 1 && args[i] == "__CMAKE_INJECTED_PROJECT_COMMAND__") {
injectedProjectCommand = true;
} else if (doing == DoingVersion) {
doing = DoingLanguages;
version = args[i];
@@ -234,17 +231,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
languages.emplace_back("NONE");
}
cmPolicies::PolicyStatus const cmp0048 =
mf.GetPolicyStatus(cmPolicies::CMP0048);
if (haveVersion) {
// Set project VERSION variables to given values
if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
mf.IssueMessage(MessageType::FATAL_ERROR,
"VERSION not allowed unless CMP0048 is set to NEW");
cmSystemTools::SetFatalErrorOccurred();
return true;
}
cmsys::RegularExpression vx(
R"(^([0-9]+(\.[0-9]+(\.[0-9]+(\.[0-9]+)?)?)?)?$)");
if (!vx.find(version)) {
@@ -315,7 +302,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
version_components[2]);
TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_TWEAK",
version_components[3]);
} else if (cmp0048 != cmPolicies::OLD) {
} else {
// Set project VERSION variables to empty
std::vector<std::string> vv = { "PROJECT_VERSION",
"PROJECT_VERSION_MAJOR",
@@ -334,26 +321,12 @@ bool cmProjectCommand(std::vector<std::string> const& args,
vv.emplace_back("CMAKE_PROJECT_VERSION_PATCH");
vv.emplace_back("CMAKE_PROJECT_VERSION_TWEAK");
}
std::string vw;
for (std::string const& i : vv) {
cmValue v = mf.GetDefinition(i);
if (cmNonempty(v)) {
if (cmp0048 == cmPolicies::WARN) {
if (!injectedProjectCommand) {
vw += "\n ";
vw += i;
}
} else {
mf.AddDefinition(i, "");
}
mf.AddDefinition(i, "");
}
}
if (!vw.empty()) {
mf.IssueMessage(
MessageType::AUTHOR_WARNING,
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
"\nThe following variable(s) would be set to empty:", vw));
}
}
mf.AddDefinition("PROJECT_DESCRIPTION", description);

View File

@@ -1,7 +0,0 @@
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
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\.$

View File

@@ -1,7 +1,5 @@
include(PrintVersions.cmake)
cmake_policy(SET CMP0048 NEW)
project(ProjectA VERSION 1.2.3.4 LANGUAGES NONE)
print_versions(ProjectA)

View File

@@ -1,4 +0,0 @@
CMake Error at CMP0048-OLD-VERSION.cmake:1 \(project\):
VERSION not allowed unless CMP0048 is set to NEW
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1,2 +0,0 @@
project(MyProject VERSION 1 LANGUAGES NONE)
message("This line not reached.")

View File

@@ -1,18 +0,0 @@
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
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\.
+
CMake Deprecation Warning at CMP0048-OLD\.cmake:1 \(cmake_policy\):
The OLD behavior for policy CMP0048 will be removed from a future version
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1,2 +0,0 @@
-- PROJECT_VERSION='1'
-- MyProject_VERSION_TWEAK='0'

View File

@@ -1,6 +0,0 @@
cmake_policy(SET CMP0048 OLD)
set(PROJECT_VERSION 1)
set(MyProject_VERSION_TWEAK 0)
project(MyProject NONE)
message(STATUS "PROJECT_VERSION='${PROJECT_VERSION}'")
message(STATUS "MyProject_VERSION_TWEAK='${MyProject_VERSION_TWEAK}'")

View File

@@ -1,12 +0,0 @@
CMake Warning \(dev\) at CMP0048-WARN.cmake:3 \(project\):
Policy CMP0048 is not set: project\(\) command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The following variable\(s\) would be set to empty:
PROJECT_VERSION
MyProject_VERSION_TWEAK
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@@ -1,3 +0,0 @@
set(PROJECT_VERSION 1)
set(MyProject_VERSION_TWEAK 0)
project(MyProject NONE)

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0096 NEW)
include(CMP0096-common.cmake)

View File

@@ -1,3 +1,2 @@
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0096 OLD)
include(CMP0096-common.cmake)

View File

@@ -1,3 +1 @@
cmake_policy(SET CMP0048 NEW)
include(CMP0096-common.cmake)

View File

@@ -1,7 +1,5 @@
if("x${RunCMake_TEST}" STREQUAL "xNoMinimumRequired")
# No cmake_minimum_required(VERSION)
elseif(RunCMake_TEST MATCHES "^CMP0048")
cmake_minimum_required(VERSION 2.8.12) # old enough to not set CMP0048
else()
cmake_minimum_required(VERSION 3.10)
# CMP0180 needs to be set before the project() call for these tests

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 DESCRIPTION "Test Project" LANGUAGES)
if(NOT PROJECT_DESCRIPTION)
message(FATAL_ERROR "PROJECT_DESCRIPTION expected to be set")

View File

@@ -1,2 +1 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 DESCRIPTION "Test Project" DESCRIPTION "Only once allowed" LANGUAGES)

View File

@@ -1,2 +1 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE DESCRIPTION)

View File

@@ -1,2 +1 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 DESCRIPTION LANGUAGES NONE)

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectHomepageTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" LANGUAGES)
if(NOT PROJECT_HOMEPAGE_URL)
message(FATAL_ERROR "PROJECT_HOMEPAGE_URL expected to be set")

View File

@@ -1,4 +1,4 @@
^CMake Error at ProjectHomepage2.cmake:2 \(project\):
^CMake Error at ProjectHomepage2.cmake:[0-9]+ \(project\):
HOMEPAGE_URL may be specified at most once.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1,2 +1 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" HOMEPAGE_URL "http://example.com" LANGUAGES)

View File

@@ -1,4 +1,4 @@
^CMake Warning at ProjectHomepageNoArg.cmake:2 \(project\):
^CMake Warning at ProjectHomepageNoArg.cmake:[0-9]+ \(project\):
HOMEPAGE_URL keyword not followed by a value or was followed by a value
that expanded to nothing.
Call Stack \(most recent call first\):

View File

@@ -1,2 +1 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE HOMEPAGE_URL)

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectTwiceTestFirst
VERSION 1.2.3.4
DESCRIPTION "Test Project"

View File

@@ -53,9 +53,6 @@ run_cmake(VersionMissingValueOkay)
run_cmake(VersionTwice)
run_cmake(VersionMax)
run_cmake(CMP0048-OLD)
run_cmake(CMP0048-OLD-VERSION)
run_cmake(CMP0048-WARN)
run_cmake(CMP0048-NEW)
run_cmake(CMP0096-WARN)

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectA VERSION 1 LANGUAGES NONE)
get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES)
message(STATUS "ENABLED_LANGUAGES='${langs}'")

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
set(PROJECT_VERSION 1)
project(ProjectA VERSION "" LANGUAGES NONE)
get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES)

View File

@@ -1,4 +1,4 @@
CMake Error at VersionInvalid.cmake:2 \(project\):
CMake Error at VersionInvalid.cmake:[0-9]+ \(project\):
VERSION "NONE" format invalid.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1,3 +1,2 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectA VERSION NONE)
message("This line not reached.")

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0096 OLD)
enable_language(C)

View File

@@ -1,4 +1,4 @@
CMake Error at VersionMissingLanguages.cmake:2 \(project\):
CMake Error at VersionMissingLanguages.cmake:[0-9]+ \(project\):
project with VERSION, DESCRIPTION or HOMEPAGE_URL must use LANGUAGES before
language names.
Call Stack \(most recent call first\):

View File

@@ -1,3 +1,2 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectA VERSION 1 NONE)
message("This line not reached.")

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0048 NEW)
set(PROJECT_VERSION 1)
project(ProjectA VERSION LANGUAGES NONE)
get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES)

View File

@@ -1,4 +1,4 @@
CMake Error at VersionTwice.cmake:2 \(project\):
CMake Error at VersionTwice.cmake:[0-9]+ \(project\):
VERSION may be specified at most once.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1,3 +1,2 @@
cmake_policy(SET CMP0048 NEW)
project(ProjectA VERSION 1 VERSION)
message("This line not reached.")

View File

@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.12.2) # old enough to not set CMP0048
cmake_minimum_required(VERSION 3.10)
# no project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -9,12 +9,4 @@
CMake is pretending there is a "project\(Project\)" command on the first
line\.
This warning is for project developers. Use -Wno-dev to suppress it\.
+
CMake Deprecation Warning at CMakeLists\.txt:1 \(cmake_minimum_required\):
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\.$
This warning is for project developers. Use -Wno-dev to suppress it\.$

View File

@@ -9,5 +9,5 @@ set(RunCMake_TEST_OPTIONS
-DCMAKE_PROJECT_VERSION_MINOR:STATIC=2
-DCMAKE_PROJECT_VERSION_PATCH:STATIC=3
)
run_cmake(CMP0048-WARN)
run_cmake(Inject)
unset(RunCMake_TEST_OPTIONS)