CMP0036: Remove support for OLD build_name command

This commit is contained in:
Brad King 2024-11-26 15:14:15 -05:00
parent 5b255fe7da
commit 850174c507
16 changed files with 9 additions and 121 deletions

View File

@ -1,6 +1,9 @@
CMP0036
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
The :command:`build_name` command should not be called.
This command was added in May 2001 to compute a name for the current
@ -9,6 +12,4 @@ documented as discouraged and replaced by the :variable:`CMAKE_SYSTEM`
and :variable:`CMAKE_<LANG>_COMPILER` variables.
.. |disallowed_version| replace:: 3.0
.. include:: DISALLOWED_COMMAND.txt
.. include:: DEPRECATED.txt
.. include:: REMOVED_COMMAND.txt

View File

@ -548,8 +548,6 @@ add_library(
cmBreakCommand.h
cmBuildCommand.cxx
cmBuildCommand.h
cmBuildNameCommand.cxx
cmBuildNameCommand.h
cmCMakeHostSystemInformationCommand.cxx
cmCMakeHostSystemInformationCommand.h
cmCMakeLanguageCommand.cxx

View File

@ -1,61 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBuildNameCommand.h"
#include <algorithm>
#include "cmsys/RegularExpression.hxx"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmValue.h"
bool cmBuildNameCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.empty()) {
status.SetError("called with incorrect number of arguments");
return false;
}
cmMakefile& mf = status.GetMakefile();
cmValue cacheValue = mf.GetDefinition(args[0]);
if (cacheValue) {
// do we need to correct the value?
cmsys::RegularExpression reg("[()/]");
std::string cv = *cacheValue;
if (reg.find(cv)) {
std::replace(cv.begin(), cv.end(), '/', '_');
std::replace(cv.begin(), cv.end(), '(', '_');
std::replace(cv.begin(), cv.end(), ')', '_');
mf.AddCacheDefinition(args[0], cv, "Name of build.",
cmStateEnums::STRING);
}
return true;
}
std::string buildname = "WinNT";
if (mf.GetDefinition("UNIX")) {
buildname.clear();
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
if (!buildname.empty()) {
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
cmsys::RegularExpression reg(RegExp);
if (reg.find(buildname)) {
buildname = reg.match(1) + "-" + reg.match(2);
}
}
}
std::string compiler = "${CMAKE_CXX_COMPILER}";
mf.ExpandVariablesInString(compiler);
buildname += "-";
buildname += cmSystemTools::GetFilenameName(compiler);
std::replace(buildname.begin(), buildname.end(), '/', '_');
std::replace(buildname.begin(), buildname.end(), '(', '_');
std::replace(buildname.begin(), buildname.end(), ')', '_');
mf.AddCacheDefinition(args[0], buildname, "Name of build.",
cmStateEnums::STRING);
return true;
}

View File

@ -1,13 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
class cmExecutionStatus;
bool cmBuildNameCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);

View File

@ -93,7 +93,6 @@
# include "cmAddCompileOptionsCommand.h"
# include "cmAddLinkOptionsCommand.h"
# include "cmAuxSourceDirectoryCommand.h"
# include "cmBuildNameCommand.h"
# include "cmCMakeHostSystemInformationCommand.h"
# include "cmCMakePkgConfigCommand.h"
# include "cmExportCommand.h"
@ -209,9 +208,8 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("variable_watch", cmVariableWatchCommand);
state->AddBuiltinCommand("write_file", cmWriteFileCommand);
state->AddDisallowedCommand(
"build_name", cmBuildNameCommand, cmPolicies::CMP0036,
"The build_name command should not be called; see CMP0036.");
state->AddRemovedCommand(
"build_name", "The build_name command has been removed; see CMP0036.");
state->AddRemovedCommand(
"use_mangled_mesa",
"The use_mangled_mesa command has been removed; see CMP0030.");

View File

@ -113,7 +113,7 @@ class cmMakefile;
SELECT(POLICY, CMP0035, \
"The variable_requires command should not be called.", 3, 0, 0, NEW) \
SELECT(POLICY, CMP0036, "The build_name command should not be called.", 3, \
0, 0, WARN) \
0, 0, NEW) \
SELECT(POLICY, CMP0037, \
"Target names should not be reserved and should match a validity " \
"pattern.", \

View File

@ -1,4 +1,4 @@
CMake Error at CMP0036-NEW.cmake:2 \(build_name\):
The build_name command should not be called; see CMP0036.
CMake Error at CMP0036-NEW.cmake:1 \(build_name\):
The build_name command has been removed; see CMP0036.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -1,2 +1 @@
cmake_policy(SET CMP0036 NEW)
build_name()

View File

@ -1,4 +0,0 @@
CMake Error at CMP0036-OLD.cmake:2 \(build_name\):
build_name called with incorrect number of arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -1,2 +0,0 @@
cmake_policy(SET CMP0036 OLD)
build_name()

View File

@ -1,12 +0,0 @@
CMake Warning \(dev\) at CMP0036-WARN.cmake:1 \(build_name\):
Policy CMP0036 is not set: The build_name command should not be called.
Run "cmake --help-policy CMP0036" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMP0036-WARN.cmake:1 \(build_name\):
build_name called with incorrect number of arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -1 +0,0 @@
build_name()

View File

@ -8,16 +8,7 @@ foreach(p
CMP0033
CMP0034
CMP0035
)
run_cmake(${p}-NEW)
endforeach()
return()
foreach(p
CMP0036
)
run_cmake(${p}-WARN)
run_cmake(${p}-OLD)
run_cmake(${p}-NEW)
endforeach()

View File

@ -30,10 +30,6 @@ endif ()
# Extra coverage
#
build_command(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM})
block(SCOPE_FOR POLICIES)
cmake_policy(VERSION 2.8.12) # old enough to not set CMP0036
build_name(BUILD_NAME_VAR)
endblock()
site_name(SITE_NAME_VAR)
#