diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 4207db406..eec138cd0 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -84,3 +84,15 @@ Enable warnings that are meant for the author of the CMakeLists.txt files. + +``-Wdeprecated`` + Enable deprecated functionality warnings. + + Enable warnings for usage of deprecated functionality, that are meant + for the author of the CMakeLists.txt files. + +``-Wno-deprecated`` + Suppress deprecated functionality warnings. + + Suppress warnings for usage of deprecated functionality, that are meant + for the author of the CMakeLists.txt files. diff --git a/Help/release/dev/cmake-W-options.rst b/Help/release/dev/cmake-W-options.rst new file mode 100644 index 000000000..e64d61807 --- /dev/null +++ b/Help/release/dev/cmake-W-options.rst @@ -0,0 +1,5 @@ +cmake-W-options +--------------- + +* The :variable:`CMAKE_WARN_DEPRECATED` variable can now be set using the + ``-Wdeprecated`` and ``-Wno-deprecated`` :manual:`cmake(1)` options. diff --git a/Help/variable/CMAKE_WARN_DEPRECATED.rst b/Help/variable/CMAKE_WARN_DEPRECATED.rst index 662cbd8c7..5f87c348a 100644 --- a/Help/variable/CMAKE_WARN_DEPRECATED.rst +++ b/Help/variable/CMAKE_WARN_DEPRECATED.rst @@ -1,7 +1,10 @@ CMAKE_WARN_DEPRECATED --------------------- -Whether to issue deprecation warnings for macros and functions. +Whether to issue warnings for deprecated functionality. -If ``TRUE``, this can be used by macros and functions to issue deprecation -warnings. This variable is ``FALSE`` by default. +If ``TRUE``, use of deprecated functionality will issue warnings. +If this variable is not set, CMake behaves as if it were set to ``FALSE``. + +When running :manual:`cmake(1)`, this option can be enabled with the +``-Wdeprecated`` option, or disabled with the ``-Wno-deprecated`` option. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e6433bd6b..37d7e0a7a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1263,6 +1263,26 @@ int cmake::Configure() { DiagLevel diagLevel; + if (this->DiagLevels.count("deprecated") == 1) + { + + diagLevel = this->DiagLevels["deprecated"]; + if (diagLevel == DIAG_IGNORE) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", + "Whether to issue warnings for deprecated " + "functionality.", + cmState::INTERNAL); + } + else if (diagLevel == DIAG_WARN) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE", + "Whether to issue warnings for deprecated " + "functionality.", + cmState::INTERNAL); + } + } + if (this->DiagLevels.count("dev") == 1) { diff --git a/Source/cmake.h b/Source/cmake.h index 1bd6d4d0f..8739b87b7 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -444,7 +444,9 @@ private: {"-T ", "Specify toolset name if supported by generator."}, \ {"-A ", "Specify platform name if supported by generator."}, \ {"-Wno-dev", "Suppress developer warnings."},\ - {"-Wdev", "Enable developer warnings."} + {"-Wdev", "Enable developer warnings."},\ + {"-Wdeprecated", "Enable deprecation warnings."},\ + {"-Wno-deprecated", "Suppress deprecation warnings."} #define FOR_EACH_C_FEATURE(F) \ F(c_function_prototypes) \ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index d4f399c56..f726ae257 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -133,6 +133,14 @@ set(RunCMake_TEST_OPTIONS -Wdev) run_cmake(Wdev) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS -Wdeprecated) +run_cmake(Wdeprecated) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Wno-deprecated) +run_cmake(Wno-deprecated) +unset(RunCMake_TEST_OPTIONS) + # Dev warnings should be on by default run_cmake(Wdev) diff --git a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt new file mode 100644 index 000000000..e9be1dcb3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt @@ -0,0 +1,4 @@ +^CMake Deprecation Warning at Wdeprecated.cmake:1 \(message\): + Some deprecated warning +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CommandLine/Wdeprecated.cmake b/Tests/RunCMake/CommandLine/Wdeprecated.cmake new file mode 100644 index 000000000..3142b42dc --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wdeprecated.cmake @@ -0,0 +1 @@ +message(DEPRECATION "Some deprecated warning") diff --git a/Tests/RunCMake/CommandLine/Wno-deprecated.cmake b/Tests/RunCMake/CommandLine/Wno-deprecated.cmake new file mode 100644 index 000000000..3142b42dc --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wno-deprecated.cmake @@ -0,0 +1 @@ +message(DEPRECATION "Some deprecated warning")