From b51e6a0be738877b99b847656887f8b7fc593f32 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Oct 2024 14:27:57 -0400 Subject: [PATCH 1/4] Help/dev: Update export policy version in post-release development Since commit 20fa4ce8d8 (export: Factor out CMake-specific export generation (2/2), 2024-07-18) the code that needs editing is in a different method. --- Help/dev/maint.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/dev/maint.rst b/Help/dev/maint.rst index c904673fb6..71e16106ab 100644 --- a/Help/dev/maint.rst +++ b/Help/dev/maint.rst @@ -339,7 +339,7 @@ Commit with a message such as:: away from setting policies to OLD. Update the ``cmake_policy`` version range generated by ``install(EXPORT)`` -in ``cmExportFileGenerator::GeneratePolicyHeaderCode`` and +in ``cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode`` and ``install_jar_exports`` in ``javaTargets.cmake.in`` to end at the previous release. We use one release back since we now know all the policies added for that version. Commit with a message such as:: From fe6cf6d28c5064cdef5ee1be9ee2f9a986dad196 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Oct 2024 13:59:10 -0400 Subject: [PATCH 2/4] Add deprecation warnings for policies CMP0139 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.24 and below to encourage projects to port away from setting policies to OLD. --- Source/cmMakefile.cxx | 4 ++-- Tests/RunCMake/CMP0132/CMP0132-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/CMP0135/CMP0135-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/CMP0139/CMP0139-OLD-stderr.txt | 13 ++++++++++++- .../CheckIPOSupported/CMP0138-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/block/Scope-POLICIES-stderr.txt | 10 ++++++++++ Tests/RunCMake/block/Scope-VARIABLES-stderr.txt | 10 ++++++++++ Tests/RunCMake/block/Scope-stderr.txt | 10 ++++++++++ Tests/RunCMake/find_file/Registry-query-stderr.txt | 10 ++++++++++ .../RunCMake/find_library/Registry-query-stderr.txt | 10 ++++++++++ .../RunCMake/find_package/Registry-query-stderr.txt | 10 ++++++++++ Tests/RunCMake/find_path/Registry-query-stderr.txt | 10 ++++++++++ .../RunCMake/find_program/Registry-query-stderr.txt | 10 ++++++++++ Tests/RunCMake/while/CMP0130-OLD-stderr.txt | 10 ++++++++++ 14 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 Tests/RunCMake/CMP0132/CMP0132-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0135/CMP0135-OLD-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/CMP0138-OLD-stderr.txt create mode 100644 Tests/RunCMake/block/Scope-POLICIES-stderr.txt create mode 100644 Tests/RunCMake/block/Scope-VARIABLES-stderr.txt create mode 100644 Tests/RunCMake/block/Scope-stderr.txt create mode 100644 Tests/RunCMake/find_file/Registry-query-stderr.txt create mode 100644 Tests/RunCMake/find_library/Registry-query-stderr.txt create mode 100644 Tests/RunCMake/find_package/Registry-query-stderr.txt create mode 100644 Tests/RunCMake/find_path/Registry-query-stderr.txt create mode 100644 Tests/RunCMake/find_program/Registry-query-stderr.txt create mode 100644 Tests/RunCMake/while/CMP0130-OLD-stderr.txt diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 98da10dc81..50cc72920c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4645,14 +4645,14 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, } // Deprecate old policies. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0129 && + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0139 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 || id == cmPolicies::CMP0091 || id == cmPolicies::CMP0104 || id == cmPolicies::CMP0123 || id == cmPolicies::CMP0126 || - id == cmPolicies::CMP0128)) && + id == cmPolicies::CMP0128 || id == cmPolicies::CMP0136)) && (!this->IsSet("CMAKE_WARN_DEPRECATED") || this->IsOn("CMAKE_WARN_DEPRECATED"))) { this->IssueMessage(MessageType::DEPRECATION_WARNING, diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD-stderr.txt b/Tests/RunCMake/CMP0132/CMP0132-OLD-stderr.txt new file mode 100644 index 0000000000..025665de8d --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0132-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0132 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/CMP0135/CMP0135-OLD-stderr.txt b/Tests/RunCMake/CMP0135/CMP0135-OLD-stderr.txt new file mode 100644 index 0000000000..59a7a58fbc --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0135-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0135 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/CMP0139/CMP0139-OLD-stderr.txt b/Tests/RunCMake/CMP0139/CMP0139-OLD-stderr.txt index 1cfb319449..b04cd1aa50 100644 --- a/Tests/RunCMake/CMP0139/CMP0139-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0139/CMP0139-OLD-stderr.txt @@ -1,3 +1,14 @@ +^CMake Deprecation Warning at CMP0139-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0139 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\) ++ CMake Error at CMP0139-OLD.cmake:[0-9]+ \(if\): if given arguments: @@ -5,4 +16,4 @@ CMake Error at CMP0139-OLD.cmake:[0-9]+ \(if\): Unknown arguments specified Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/CMP0138-OLD-stderr.txt b/Tests/RunCMake/CheckIPOSupported/CMP0138-OLD-stderr.txt new file mode 100644 index 0000000000..375ab1d246 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/CMP0138-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0138-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0138 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/block/Scope-POLICIES-stderr.txt b/Tests/RunCMake/block/Scope-POLICIES-stderr.txt new file mode 100644 index 0000000000..84b99aaf05 --- /dev/null +++ b/Tests/RunCMake/block/Scope-POLICIES-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Scope-POLICIES\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0139 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/block/Scope-VARIABLES-stderr.txt b/Tests/RunCMake/block/Scope-VARIABLES-stderr.txt new file mode 100644 index 0000000000..458daa7e85 --- /dev/null +++ b/Tests/RunCMake/block/Scope-VARIABLES-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Scope-VARIABLES\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0139 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/block/Scope-stderr.txt b/Tests/RunCMake/block/Scope-stderr.txt new file mode 100644 index 0000000000..af84e88392 --- /dev/null +++ b/Tests/RunCMake/block/Scope-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Scope\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0139 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/find_file/Registry-query-stderr.txt b/Tests/RunCMake/find_file/Registry-query-stderr.txt new file mode 100644 index 0000000000..0532022f9a --- /dev/null +++ b/Tests/RunCMake/find_file/Registry-query-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Registry-query\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0134 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/find_library/Registry-query-stderr.txt b/Tests/RunCMake/find_library/Registry-query-stderr.txt new file mode 100644 index 0000000000..0532022f9a --- /dev/null +++ b/Tests/RunCMake/find_library/Registry-query-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Registry-query\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0134 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/find_package/Registry-query-stderr.txt b/Tests/RunCMake/find_package/Registry-query-stderr.txt new file mode 100644 index 0000000000..0532022f9a --- /dev/null +++ b/Tests/RunCMake/find_package/Registry-query-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Registry-query\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0134 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/find_path/Registry-query-stderr.txt b/Tests/RunCMake/find_path/Registry-query-stderr.txt new file mode 100644 index 0000000000..0532022f9a --- /dev/null +++ b/Tests/RunCMake/find_path/Registry-query-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Registry-query\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0134 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/find_program/Registry-query-stderr.txt b/Tests/RunCMake/find_program/Registry-query-stderr.txt new file mode 100644 index 0000000000..0532022f9a --- /dev/null +++ b/Tests/RunCMake/find_program/Registry-query-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Registry-query\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0134 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/while/CMP0130-OLD-stderr.txt b/Tests/RunCMake/while/CMP0130-OLD-stderr.txt new file mode 100644 index 0000000000..e673966a77 --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0130-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0130 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\)$ From 10f8c6a2742500ddc708091f194d218a37543129 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Oct 2024 14:26:42 -0400 Subject: [PATCH 3/4] export: Increase maximum policy version in exported files to 3.30 The files generated by `install(EXPORT)`, `export()`, and `install_jar_exports()` commands are known to work with policies as of CMake 3.30, so enable them in sufficiently new CMake versions. --- Modules/UseJava/javaTargets.cmake.in | 2 +- Source/cmExportCMakeConfigGenerator.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/UseJava/javaTargets.cmake.in b/Modules/UseJava/javaTargets.cmake.in index 6002d4eed0..11f1f0621e 100644 --- a/Modules/UseJava/javaTargets.cmake.in +++ b/Modules/UseJava/javaTargets.cmake.in @@ -1,5 +1,5 @@ cmake_policy(PUSH) -cmake_policy(VERSION 2.8.12...3.29) +cmake_policy(VERSION 2.8.12...3.30) #---------------------------------------------------------------- # Generated CMake Java target import file. diff --git a/Source/cmExportCMakeConfigGenerator.cxx b/Source/cmExportCMakeConfigGenerator.cxx index 4f4765c964..522c1c86b7 100644 --- a/Source/cmExportCMakeConfigGenerator.cxx +++ b/Source/cmExportCMakeConfigGenerator.cxx @@ -185,7 +185,7 @@ void cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode(std::ostream& os) // Isolate the file policy level. // Support CMake versions as far back as the // RequiredCMakeVersion{Major,Minor,Patch}, but also support using NEW - // policy settings for up to CMake 3.29 (this upper limit may be reviewed + // policy settings for up to CMake 3.30 (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. @@ -194,7 +194,7 @@ void cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode(std::ostream& os) << "cmake_policy(VERSION " << this->RequiredCMakeVersionMajor << '.' << this->RequiredCMakeVersionMinor << '.' - << this->RequiredCMakeVersionPatch << "...3.29)\n"; + << this->RequiredCMakeVersionPatch << "...3.30)\n"; /* clang-format on */ } From 3a96346a3f49508dd49e3e91db5b9f606ba268fd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Oct 2024 14:31:20 -0400 Subject: [PATCH 4/4] Configure CMake itself with policies through CMake 3.30 --- CMakeLists.txt | 2 +- Source/Checks/Curses/CMakeLists.txt | 2 +- Utilities/Doxygen/CMakeLists.txt | 2 +- Utilities/Sphinx/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a562cbf6..ae1359efec 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.13...3.29 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.30 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) diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt index bd7c415fbd..1f04bd2929 100644 --- a/Source/Checks/Curses/CMakeLists.txt +++ b/Source/Checks/Curses/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13...3.29 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR) project(CheckCurses C) set(CURSES_NEED_NCURSES TRUE) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 111bd6f152..64f9a3fb5c 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.29 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.30 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 ed7b63196c..a919b9147a 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.29 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.30 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)