From c0e8bb5150b98a8003181b32396d0f3609bc6fce Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Oct 2022 11:52:35 -0400 Subject: Add deprecation warnings for policies CMP0108 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.18 and below to encourage projects to port away from setting policies to OLD. --- Source/cmMakefile.cxx | 4 ++-- Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt | 10 ++++++++++ .../alias_targets/duplicate-target-CMP0107-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt | 10 ++++++++++ .../target_link_libraries/CMP0108-OLD-self-link-stderr.txt | 10 ++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt create mode 100644 Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt create mode 100644 Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6e0d704..4100d1f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4470,12 +4470,12 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, } // Deprecate old policies. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0102 && + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0108 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 || - id == cmPolicies::CMP0091)) && + id == cmPolicies::CMP0091 || id == cmPolicies::CMP0104)) && (!this->IsSet("CMAKE_WARN_DEPRECATED") || this->IsOn("CMAKE_WARN_DEPRECATED"))) { this->IssueMessage(MessageType::DEPRECATION_WARNING, diff --git a/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt b/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt new file mode 100644 index 0000000..66d3016 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0104-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0104 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/CMP0106/CMP0106-OLD-stderr.txt b/Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt new file mode 100644 index 0000000..ef48d5c --- /dev/null +++ b/Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0106-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0106 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/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt new file mode 100644 index 0000000..f5247ca --- /dev/null +++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at duplicate-target-CMP0107-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0107 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/export/Repeat-CMP0103-OLD-stderr.txt b/Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt new file mode 100644 index 0000000..1183f86 --- /dev/null +++ b/Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Repeat-CMP0103-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0103 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/target_link_libraries/CMP0108-OLD-self-link-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt new file mode 100644 index 0000000..07e9a9f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0108-OLD-self-link.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0108 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\)$ -- cgit v0.12 From 6bd18eed8e81a1e63f5cedc4c3caeb02137e0cd6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Oct 2022 12:41:25 -0400 Subject: export: Increase maximum policy version in exported files to 3.24 The files generatd by `install(EXPORT)` and `export()` commands are known to work with policies as of CMake 3.24, 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 50bc78c..2c61163 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -939,13 +939,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.23 (this upper limit may be reviewed + // policy settings for up to CMake 3.24 (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.8.3...3.23)\n"; + << "cmake_policy(VERSION 2.8.3...3.24)\n"; /* clang-format on */ } -- cgit v0.12 From 5f998bbcb3242a2d464843640d090cccbc05d814 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Oct 2022 12:43:27 -0400 Subject: Configure CMake itself with policies through CMake 3.24 --- CMakeLists.txt | 6 +----- Utilities/Doxygen/CMakeLists.txt | 2 +- Utilities/Sphinx/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b9eb2d..b2ca218 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,10 @@ # 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.13...3.23 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.24 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) -if(POLICY CMP0129) - cmake_policy(SET CMP0129 NEW) # CMake 3.23 -endif() - project(CMake) unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index bc16350..b084dd5 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.13...3.23 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.24 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 886f4e0..bd2f305 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.13...3.23 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.24 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