diff --git a/Help/release/dev/deprecated-commands.rst b/Help/release/dev/deprecated-commands.rst new file mode 100644 index 0000000000..b6915b65a0 --- /dev/null +++ b/Help/release/dev/deprecated-commands.rst @@ -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. diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 7e2fb69070..d23b3aed54 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -4,6 +4,7 @@ #include +#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 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(); diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 474bbc41a1..a3f75a7ef8 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -4,6 +4,7 @@ #include +#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 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(); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 6b184103f2..791fd5e2ed 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -5,6 +5,7 @@ #include #include +#include "cmDiagnostics.h" #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -13,13 +14,17 @@ bool cmInstallTargetsCommand(std::vector 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(); diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx index 241e0cdbd1..4302f4cb41 100644 --- a/Source/cmMakeDirectoryCommand.cxx +++ b/Source/cmMakeDirectoryCommand.cxx @@ -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 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); diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index 7ce0a50f51..0db4d17d43 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -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 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 const& args, } // add the definition - status.GetMakefile().AddDefinition(variable, value); + mf.AddDefinition(variable, value); return true; } diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index e4f0384546..fd87e09bc9 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -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 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") { diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index f862c51932..54e1e4d480 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -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 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 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); diff --git a/Tests/RunCMake/PrecompileHeaders-Reuse/PchReuseFromSubdir-stderr.txt b/Tests/RunCMake/PrecompileHeaders-Reuse/PchReuseFromSubdir-stderr.txt new file mode 100644 index 0000000000..54788c0dce --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders-Reuse/PchReuseFromSubdir-stderr.txt @@ -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\. diff --git a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt index ee8009a9ec..02ea542874 100644 --- a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt +++ b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt @@ -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\): diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt index be06f0ede2..33eb146cc0 100644 --- a/Tests/RunCMake/get_property/directory_properties-stderr.txt +++ b/Tests/RunCMake/get_property/directory_properties-stderr.txt @@ -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<-- diff --git a/Tests/RunCMake/install/Deprecated-stderr.txt b/Tests/RunCMake/install/Deprecated-stderr.txt new file mode 100644 index 0000000000..81b0e443b0 --- /dev/null +++ b/Tests/RunCMake/install/Deprecated-stderr.txt @@ -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\.