mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Add deprecation diagnostics to deprecated commands
The `install_files`, `install_programs`, `install_targets`, `make_directory`, `remove`, `subdirs` and `write_file` commands have been deprecated since CMake 3.0. Tweak them to emit deprecation diagnostics. Note that the `exec_program` command does not need a diagnostic as it is disallowed under CMP0153.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
deprecated-commands
|
||||
-------------------
|
||||
|
||||
* The :command:`install_files`, :command:`install_programs`,
|
||||
:command:`install_targets`, :command:`make_directory`, :command:`remove`,
|
||||
:command:`subdirs` and :command:`write_file` commands, which have been
|
||||
deprecated since CMake 3.0, now emit deprecation diagnostics when used.
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@@ -27,13 +28,17 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest,
|
||||
bool cmInstallFilesCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'install_files' command has been superseded. "
|
||||
"Use 'install(FILES)' instead.");
|
||||
|
||||
if (args.size() < 2) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
// Enable the install target.
|
||||
mf.GetGlobalGenerator()->EnableInstallTarget();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@@ -23,13 +24,17 @@ static std::string FindInstallSource(cmMakefile& makefile, char const* name);
|
||||
bool cmInstallProgramsCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'install_programs' command has been superseded. "
|
||||
"Use 'install(PROGRAMS)' instead.");
|
||||
|
||||
if (args.size() < 2) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
// Enable the install target.
|
||||
mf.GetGlobalGenerator()->EnableInstallTarget();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
@@ -13,13 +14,17 @@
|
||||
bool cmInstallTargetsCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'install_targets' command has been superseded. "
|
||||
"Use 'install(TARGETS)' instead.");
|
||||
|
||||
if (args.size() < 2) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
// Enable the install target.
|
||||
mf.GetGlobalGenerator()->EnableInstallTarget();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmMakeDirectoryCommand.h"
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSystemTools.h"
|
||||
@@ -10,11 +11,17 @@
|
||||
bool cmMakeDirectoryCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'make_directory' command has been superseded. "
|
||||
"Use 'file(MAKE_DIRECTORY)' instead.");
|
||||
|
||||
if (args.size() != 1) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
if (!status.GetMakefile().CanIWriteThisFile(args[0])) {
|
||||
if (!mf.CanIWriteThisFile(args[0])) {
|
||||
std::string e = "attempted to create a directory: " + args[0] +
|
||||
" into a source directory.";
|
||||
status.SetError(e);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmRemoveCommand.h"
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
@@ -11,13 +12,19 @@
|
||||
bool cmRemoveCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'remove' command has been superseded. "
|
||||
"Use 'list(REMOVE_ITEM)' instead.");
|
||||
|
||||
if (args.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string const& variable = args[0]; // VAR is always first
|
||||
// get the old value
|
||||
cmValue cacheValue = status.GetMakefile().GetDefinition(variable);
|
||||
cmValue cacheValue = mf.GetDefinition(variable);
|
||||
|
||||
// if there is no old value then return
|
||||
if (!cacheValue) {
|
||||
@@ -50,7 +57,7 @@ bool cmRemoveCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// add the definition
|
||||
status.GetMakefile().AddDefinition(variable, value);
|
||||
mf.AddDefinition(variable, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmSubdirCommand.h"
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -10,13 +11,18 @@
|
||||
bool cmSubdirCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'subdirs' command has been superseded. "
|
||||
"Use the 'add_subdirectory' command instead.");
|
||||
|
||||
if (args.empty()) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
bool res = true;
|
||||
bool excludeFromAll = false;
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
for (std::string const& i : args) {
|
||||
if (i == "EXCLUDE_FROM_ALL") {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "cm_sys_stat.h"
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -15,6 +16,12 @@
|
||||
bool cmWriteFileCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
"The 'write_file' command has been superseded. "
|
||||
"Use 'file(WRITE)' instead.");
|
||||
|
||||
if (args.size() < 2) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
@@ -34,7 +41,7 @@ bool cmWriteFileCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
}
|
||||
|
||||
if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
|
||||
if (!mf.CanIWriteThisFile(fileName)) {
|
||||
std::string e =
|
||||
"attempted to write a file: " + fileName + " into a source directory.";
|
||||
status.SetError(e);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
CMake Warning \(deprecated\) at PchReuseFromSubdir\.cmake:[0-9]+ \(subdirs\):
|
||||
The 'subdirs' command has been superseded\. Use the 'add_subdirectory'
|
||||
command instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
@@ -3,6 +3,14 @@
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:DEFERRED
|
||||
+
|
||||
CMake Warning \(deprecated\) at defer_call_add_subdirectory.cmake:2 \(subdirs\):
|
||||
The 'subdirs' command has been superseded\. Use the 'add_subdirectory'
|
||||
command instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:DEFERRED
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
+
|
||||
CMake Error at defer_call_add_subdirectory\.cmake:2 \(subdirs\):
|
||||
Subdirectories may not be created during deferred execution\.
|
||||
Call Stack \(most recent call first\):
|
||||
|
||||
@@ -4,6 +4,12 @@ get_directory_property: -->value<--
|
||||
get_property: -->value<--
|
||||
get_directory_property: --><--
|
||||
get_property: --><--
|
||||
CMake Warning \(deprecated\) at directory_properties/CMakeLists.txt:2 \(subdirs\):
|
||||
The 'subdirs' command has been superseded\. Use the 'add_subdirectory'
|
||||
command instead\.
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
||||
get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
||||
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<--
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_files\):
|
||||
The 'install_files' command has been superseded\. Use 'install\(FILES\)'
|
||||
instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_files\):
|
||||
The 'install_files' command has been superseded\. Use 'install\(FILES\)'
|
||||
instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_files\):
|
||||
The 'install_files' command has been superseded\. Use 'install\(FILES\)'
|
||||
instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_targets\):
|
||||
The 'install_targets' command has been superseded\. Use 'install\(TARGETS\)'
|
||||
instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_programs\):
|
||||
The 'install_programs' command has been superseded\. Use
|
||||
'install\(PROGRAMS\)' instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_programs\):
|
||||
The 'install_programs' command has been superseded\. Use
|
||||
'install\(PROGRAMS\)' instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
|
||||
CMake Warning \(deprecated\) at Deprecated\.cmake:[0-9]+ \(install_programs\):
|
||||
The 'install_programs' command has been superseded\. Use
|
||||
'install\(PROGRAMS\)' instead\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-author or -Wno-deprecated
|
||||
to suppress it\.
|
||||
Reference in New Issue
Block a user