From d76cb12905df6d76fe3ee5376913e5d61161f71d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jun 2021 09:40:23 -0400 Subject: Add deprecation warnings for policies CMP0088 and below The OLD behaviors of all policies are deprecated, but only by documentation. Add an explicit deprecation diagnostic for policies introduced in CMake 3.14 and below to encourage projects to port away from setting policies to OLD. --- Source/cmMakefile.cxx | 7 +++---- Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt | 8 ++++++++ Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt | 8 ++++++++ Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/install/CMP0087-OLD-stderr.txt | 8 ++++++++ 6 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt create mode 100644 Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt create mode 100644 Tests/RunCMake/install/CMP0087-OLD-stderr.txt diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c970abe..a2d64e2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,13 +4426,12 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Deprecate old policies, especially those that require a lot - // of code to maintain the old behavior. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0081 && + // Deprecate old policies. + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0088 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. - id == cmPolicies::CMP0065))) { + id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083))) { this->IssueMessage(MessageType::DEPRECATION_WARNING, cmPolicies::GetPolicyDeprecatedWarning(id)); } diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt new file mode 100644 index 0000000..cae3679 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0085 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.$ diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt new file mode 100644 index 0000000..fca7a73 --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0086-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0086 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\)$ diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt new file mode 100644 index 0000000..50838c3 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0082 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.$ diff --git a/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt b/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt new file mode 100644 index 0000000..0db83aa --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0084-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0084 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\)$ diff --git a/Tests/RunCMake/install/CMP0087-OLD-stderr.txt b/Tests/RunCMake/install/CMP0087-OLD-stderr.txt new file mode 100644 index 0000000..5233ebc --- /dev/null +++ b/Tests/RunCMake/install/CMP0087-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMP0087-OLD/CMakeLists.txt:5 \(cmake_policy\): + The OLD behavior for policy CMP0087 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.$ -- cgit v0.12 From 83a3db56317bf0ef3b41c4fc437a6a31d36c8b73 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jun 2021 09:41:37 -0400 Subject: export: Increase maximum policy version in exported files to 3.20 The files generatd by `install(EXPORT)` and `export()` commands are known to work with policies as of CMake 3.20, so enable them in sufficiently new CMake versions. --- Source/cmExportFileGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dd611de..c69d484 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -924,13 +924,13 @@ void cmExportFileGenerator::GeneratePolicyHeaderCode(std::ostream& os) // Isolate the file policy level. // Support CMake versions as far back as 2.6 but also support using NEW - // policy settings for up to CMake 3.19 (this upper limit may be reviewed + // policy settings for up to CMake 3.20 (this upper limit may be reviewed // and increased from time to time). This reduces the opportunity for CMake // warnings when an older export file is later used with newer CMake // versions. /* clang-format off */ os << "cmake_policy(PUSH)\n" - << "cmake_policy(VERSION 2.6...3.19)\n"; + << "cmake_policy(VERSION 2.6...3.20)\n"; /* clang-format on */ } -- cgit v0.12 From 2c209097b9c29aae4ed2bd414e5c48fe6f4e148e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jun 2021 09:42:46 -0400 Subject: Configure CMake itself with policies through CMake 3.20 --- CMakeLists.txt | 2 +- Utilities/Doxygen/CMakeLists.txt | 2 +- Utilities/Sphinx/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6016cd6..1261eb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -cmake_minimum_required(VERSION 3.1...3.19 FATAL_ERROR) +cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR) set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake) set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake) project(CMake) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 0ccb721..69b4e2f 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -3,7 +3,7 @@ if(NOT CMake_SOURCE_DIR) set(CMakeDeveloperReference_STANDALONE 1) - cmake_minimum_required(VERSION 3.1...3.19 FATAL_ERROR) + cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 32efd48..a71dfcd 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -3,7 +3,7 @@ if(NOT CMake_SOURCE_DIR) set(CMakeHelp_STANDALONE 1) - cmake_minimum_required(VERSION 3.1...3.19 FATAL_ERROR) + cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) -- cgit v0.12