From cfcb36ca3443ac27cc51638129bc6c9cae7a73f0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Dec 2024 19:43:54 -0500 Subject: [PATCH 01/15] CMP0055: Remove support for OLD behavior --- Help/policy/CMP0055.rst | 9 +-- Source/cmBreakCommand.cxx | 57 +++---------------- Source/cmPolicies.h | 2 +- .../CMP0055-NEW-Out-of-Scope-stderr.txt | 2 +- .../CMP0055/CMP0055-NEW-Out-of-Scope.cmake | 3 - .../CMP0055-NEW-Reject-Arguments-stderr.txt | 2 +- .../CMP0055-NEW-Reject-Arguments.cmake | 5 +- .../CMP0055-OLD-Out-of-Scope-result.txt | 1 - .../CMP0055-OLD-Out-of-Scope-stderr.txt | 10 ---- .../CMP0055/CMP0055-OLD-Out-of-Scope.cmake | 4 -- .../CMP0055-OLD-Reject-Arguments-result.txt | 1 - .../CMP0055-OLD-Reject-Arguments-stderr.txt | 10 ---- .../CMP0055-OLD-Reject-Arguments.cmake | 6 -- .../CMP0055-WARN-Out-of-Scope-result.txt | 1 - .../CMP0055-WARN-Out-of-Scope-stderr.txt | 9 --- .../CMP0055/CMP0055-WARN-Out-of-Scope.cmake | 2 - .../CMP0055-WARN-Reject-Arguments-result.txt | 1 - .../CMP0055-WARN-Reject-Arguments-stderr.txt | 9 --- .../CMP0055-WARN-Reject-Arguments.cmake | 4 -- Tests/RunCMake/CMP0055/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0055/RunCMakeTest.cmake | 6 -- 21 files changed, 19 insertions(+), 127 deletions(-) delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt delete mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake diff --git a/Help/policy/CMP0055.rst b/Help/policy/CMP0055.rst index dc83863494..eda4700c07 100644 --- a/Help/policy/CMP0055.rst +++ b/Help/policy/CMP0055.rst @@ -1,6 +1,9 @@ CMP0055 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.2 Strict checking for the :command:`break` command. @@ -14,7 +17,5 @@ outside of loop contexts and ignores any arguments. The ``NEW`` behavior for th policy is to issue an error if a misplaced break or any arguments are found. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.2 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx index d9bc9269c6..40b8ca4a44 100644 --- a/Source/cmBreakCommand.cxx +++ b/Source/cmBreakCommand.cxx @@ -2,68 +2,29 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmBreakCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" -#include "cmPolicies.h" // cmBreakCommand bool cmBreakCommand(std::vector const& args, cmExecutionStatus& status) { if (!status.GetMakefile().IsLoopBlock()) { - bool issueMessage = true; - std::ostringstream e; - MessageType messageType = MessageType::AUTHOR_WARNING; - switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n"; - break; - case cmPolicies::OLD: - issueMessage = false; - break; - case cmPolicies::NEW: - messageType = MessageType::FATAL_ERROR; - break; - } - - if (issueMessage) { - e << "A BREAK command was found outside of a proper " - "FOREACH or WHILE loop scope."; - status.GetMakefile().IssueMessage(messageType, e.str()); - if (messageType == MessageType::FATAL_ERROR) { - return false; - } - } + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + "A BREAK command was found outside of a proper " + "FOREACH or WHILE loop scope."); + return false; } status.SetBreakInvoked(); if (!args.empty()) { - bool issueMessage = true; - std::ostringstream e; - MessageType messageType = MessageType::AUTHOR_WARNING; - switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n"; - break; - case cmPolicies::OLD: - issueMessage = false; - break; - case cmPolicies::NEW: - messageType = MessageType::FATAL_ERROR; - break; - } - - if (issueMessage) { - e << "The BREAK command does not accept any arguments."; - status.GetMakefile().IssueMessage(messageType, e.str()); - if (messageType == MessageType::FATAL_ERROR) { - return false; - } - } + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + "The BREAK command does not accept any arguments."); + return false; } return true; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 73fcb277d0..53ed6de4da 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -164,7 +164,7 @@ class cmMakefile; "Only interpret if() arguments as variables or keywords when unquoted.", \ 3, 1, 0, NEW) \ SELECT(POLICY, CMP0055, "Strict checking for break() command.", 3, 2, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0056, \ "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \ WARN) \ diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt index 27e81405dd..8a708f73cd 100644 --- a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at CMP0055-NEW-Out-of-Scope.cmake:4 \(break\): +CMake Error at CMP0055-NEW-Out-of-Scope.cmake:1 \(break\): A BREAK command was found outside of a proper FOREACH or WHILE loop scope. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake index 53ac214ad3..aa3ab26ed7 100644 --- a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake @@ -1,4 +1 @@ - -cmake_policy(SET CMP0055 NEW) - break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt index 32947af2a3..24d02044f2 100644 --- a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at CMP0055-NEW-Reject-Arguments.cmake:5 \(break\): +CMake Error at CMP0055-NEW-Reject-Arguments.cmake:2 \(break\): The BREAK command does not accept any arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake index 52eaa6aa53..c00c418e39 100644 --- a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake @@ -1,6 +1,3 @@ - -cmake_policy(SET CMP0055 NEW) - foreach(i RANGE 1 2) break(1) -endforeach() \ No newline at end of file +endforeach() diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt deleted file mode 100644 index d0a156cbcb..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0055-OLD-Out-of-Scope.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0055 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/CMP0055/CMP0055-OLD-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake deleted file mode 100644 index 57195c2487..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -cmake_policy(SET CMP0055 OLD) - -break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt deleted file mode 100644 index 937b352da2..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0055-OLD-Reject-Arguments.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0055 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/CMP0055/CMP0055-OLD-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake deleted file mode 100644 index d8fdddf10c..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake +++ /dev/null @@ -1,6 +0,0 @@ - -cmake_policy(SET CMP0055 OLD) - -foreach(i RANGE 1 2) - break(1) -endforeach() \ No newline at end of file diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt deleted file mode 100644 index ad850ac935..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Warning \(dev\) at CMP0055-WARN-Out-of-Scope.cmake:2 \(break\): - Policy CMP0055 is not set: Strict checking for break\(\) command. Run "cmake - --help-policy CMP0055" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - A BREAK command was found outside of a proper FOREACH or WHILE loop scope. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake deleted file mode 100644 index 373a95a7c8..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake +++ /dev/null @@ -1,2 +0,0 @@ - -break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt deleted file mode 100644 index 3cc686dc01..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Warning \(dev\) at CMP0055-WARN-Reject-Arguments.cmake:3 \(break\): - Policy CMP0055 is not set: Strict checking for break\(\) command. Run "cmake - --help-policy CMP0055" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - The BREAK command does not accept any arguments. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake deleted file mode 100644 index ec6b90f8a5..0000000000 --- a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -foreach(i RANGE 1 2) - break(1) -endforeach() diff --git a/Tests/RunCMake/CMP0055/CMakeLists.txt b/Tests/RunCMake/CMP0055/CMakeLists.txt index ef2163c298..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0055/CMakeLists.txt +++ b/Tests/RunCMake/CMP0055/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0055/RunCMakeTest.cmake b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake index 33a5b4b3b7..d9db6f5393 100644 --- a/Tests/RunCMake/CMP0055/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake @@ -1,10 +1,4 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0055-OLD-Out-of-Scope) run_cmake(CMP0055-NEW-Out-of-Scope) -run_cmake(CMP0055-WARN-Out-of-Scope) - -run_cmake(CMP0055-OLD-Reject-Arguments) run_cmake(CMP0055-NEW-Reject-Arguments) -run_cmake(CMP0055-WARN-Reject-Arguments) From cbe7fc4b81dba2be0027e2385c0d332781591979 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Dec 2024 19:49:45 -0500 Subject: [PATCH 02/15] CMP0056: Remove support for OLD behavior --- Help/command/try_compile.rst | 5 +- Help/policy/CMP0056.rst | 11 +++-- .../variable/CMAKE_POLICY_WARNING_CMPNNNN.rst | 4 +- Modules/FortranCInterface.cmake | 7 +-- Modules/FortranCInterface/Detect.cmake | 8 +--- Source/cmCoreTryCompile.cxx | 38 ++++----------- Source/cmPolicies.h | 2 +- Tests/RunCMake/try_compile/CMP0056-stderr.txt | 24 ---------- Tests/RunCMake/try_compile/CMP0056-stdout.txt | 3 -- Tests/RunCMake/try_compile/CMP0056.cmake | 48 ------------------- 10 files changed, 21 insertions(+), 129 deletions(-) delete mode 100644 Tests/RunCMake/try_compile/CMP0056-stderr.txt diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 822ec9fa55..33d710e4a3 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -320,15 +320,14 @@ Other Behavior Settings * :variable:`CMAKE_CUDA_RUNTIME_LIBRARY` * :variable:`CMAKE_ENABLE_EXPORTS` + * :variable:`CMAKE_EXE_LINKER_FLAGS`, unless using CMake versions + prior to 4.0 without policy :policy:`CMP0056` set to ``NEW`` * :variable:`CMAKE_LINK_SEARCH_START_STATIC` * :variable:`CMAKE_LINK_SEARCH_END_STATIC` * :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` * :variable:`CMAKE_POSITION_INDEPENDENT_CODE` * :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` - If :policy:`CMP0056` is set to ``NEW``, then - :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. - .. versionchanged:: 3.14 If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct behavior at link time, the ``check_pie_supported()`` command from the diff --git a/Help/policy/CMP0056.rst b/Help/policy/CMP0056.rst index ca238e25ab..41ca3ba202 100644 --- a/Help/policy/CMP0056.rst +++ b/Help/policy/CMP0056.rst @@ -1,6 +1,9 @@ CMP0056 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.2 Honor link flags in :command:`try_compile` source-file signature. @@ -28,11 +31,9 @@ set it on the command line by defining the variable in the cache. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.2 -.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default -.. include:: STANDARD_ADVICE.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: did *not* warn by default +.. include:: REMOVED_EPILOGUE.txt See documentation of the :variable:`CMAKE_POLICY_WARNING_CMP0056 >` -variable to control the warning. - -.. include:: DEPRECATED.txt +variable to control the warning in CMake versions before 4.0. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 81978c1f42..0ef81f1bb6 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -10,8 +10,8 @@ only for the policies that do not warn by default: policy :policy:`CMP0025` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0047`` controlled the warning for policy :policy:`CMP0047` in CMake versions before 4.0. -* ``CMAKE_POLICY_WARNING_CMP0056`` controls the warning for - policy :policy:`CMP0056`. +* ``CMAKE_POLICY_WARNING_CMP0056`` controlled the warning for + policy :policy:`CMP0056` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for policy :policy:`CMP0060`. * ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 3b0e13bf07..ca04d04c0c 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -348,12 +348,7 @@ function(FortranCInterface_VERIFY) set(_FortranCInterface_OSX_ARCH "") endif() - cmake_policy(GET CMP0056 _FortranCInterface_CMP0056) - if(_FortranCInterface_CMP0056 STREQUAL "NEW") - set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") - else() - set(_FortranCInterface_EXE_LINKER_FLAGS "") - endif() + set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") # Build a sample project which reports symbols. set(CMAKE_TRY_COMPILE_CONFIGURATION Release) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 00b8ad562b..a27f76113e 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -36,13 +36,7 @@ else() set(_FortranCInterface_OSX_ARCH "") endif() -cmake_policy(GET CMP0056 _FortranCInterface_CMP0056) -if(_FortranCInterface_CMP0056 STREQUAL "NEW") - set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") -else() - set(_FortranCInterface_EXE_LINKER_FLAGS "") -endif() -unset(_FortranCInterface_CMP0056) +set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") # Build a sample project which reports symbols. set(CMAKE_TRY_COMPILE_CONFIGURATION Release) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a8fd0e0929..32df7812e9 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -786,36 +786,14 @@ cm::optional cmCoreTryCompile::TryCompileCode( } } break; } - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) { - case cmPolicies::WARN: - if (this->Makefile->PolicyOptionalWarningEnabled( - "CMAKE_POLICY_WARNING_CMP0056")) { - std::ostringstream w; - /* clang-format off */ - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0056) << "\n" - "For compatibility with older versions of CMake, try_compile " - "is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) " - "in the test project." - ; - /* clang-format on */ - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); - } - CM_FALLTHROUGH; - case cmPolicies::OLD: - // OLD behavior is to do nothing. - break; - case cmPolicies::NEW: - // NEW behavior is to pass linker flags. - { - cmValue exeLinkFlags = - this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS"); - fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", - cmOutputConverter::EscapeForCMake(*exeLinkFlags).c_str()); - if (exeLinkFlags) { - cmakeVariables.emplace("CMAKE_EXE_LINKER_FLAGS", *exeLinkFlags); - } - } - break; + { + cmValue exeLinkFlags = + this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS"); + fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", + cmOutputConverter::EscapeForCMake(*exeLinkFlags).c_str()); + if (exeLinkFlags) { + cmakeVariables.emplace("CMAKE_EXE_LINKER_FLAGS", *exeLinkFlags); + } } fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 53ed6de4da..8540598864 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -167,7 +167,7 @@ class cmMakefile; NEW) \ SELECT(POLICY, CMP0056, \ "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0, \ WARN) \ SELECT(POLICY, CMP0058, \ diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt deleted file mode 100644 index de442059d7..0000000000 --- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt +++ /dev/null @@ -1,24 +0,0 @@ -before try_compile with CMP0056 WARN-default -after try_compile with CMP0056 WARN-default -* -CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\): - Policy CMP0056 is not set: Honor link flags in try_compile\(\) source-file - signature. Run "cmake --help-policy CMP0056" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - For compatibility with older versions of CMake, try_compile is not honoring - caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Deprecation Warning at CMP0056.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0056 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/try_compile/CMP0056-stdout.txt b/Tests/RunCMake/try_compile/CMP0056-stdout.txt index 89e7c437b0..b9406148a2 100644 --- a/Tests/RunCMake/try_compile/CMP0056-stdout.txt +++ b/Tests/RunCMake/try_compile/CMP0056-stdout.txt @@ -1,4 +1 @@ --- try_compile with CMP0056 WARN-default worked as expected --- try_compile with CMP0056 WARN-enabled worked as expected --- try_compile with CMP0056 OLD worked as expected -- try_compile with CMP0056 NEW worked as expected diff --git a/Tests/RunCMake/try_compile/CMP0056.cmake b/Tests/RunCMake/try_compile/CMP0056.cmake index 634576e273..86cb49d1ac 100644 --- a/Tests/RunCMake/try_compile/CMP0056.cmake +++ b/Tests/RunCMake/try_compile/CMP0056.cmake @@ -1,4 +1,3 @@ -cmake_policy(VERSION 3.1) enable_language(C) set(obj "${CMAKE_C_OUTPUT_EXTENSION}") if(BORLAND) @@ -7,53 +6,6 @@ endif() set(CMAKE_EXE_LINKER_FLAGS ${pre}BADFLAG${obj}) #----------------------------------------------------------------------------- -message("before try_compile with CMP0056 WARN-default") -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0056 WARN-default worked as expected") -endif() -message("after try_compile with CMP0056 WARN-default") - -#----------------------------------------------------------------------------- -set(CMAKE_POLICY_WARNING_CMP0056 ON) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0056 WARN-enabled worked as expected") -endif() - -#----------------------------------------------------------------------------- -cmake_policy(SET CMP0056 OLD) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0056 OLD worked as expected") -endif() - -#----------------------------------------------------------------------------- -cmake_policy(SET CMP0056 NEW) try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c OUTPUT_VARIABLE out From 2782d095b0817652b5857fcabbefdcb7655d03c1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Dec 2024 20:03:50 -0500 Subject: [PATCH 03/15] Remove compatibility with CMake versions older than 3.2 This compatibility has been deprecated since commit 3a4791548d (Deprecate compatibility with CMake versions older than 3.5, 2023-02-09, v3.27.0-rc1~508^2). The behavior itself has been deprecated since CMake 3.2. Issue: #26613 --- Help/command/DEPRECATED_POLICY_VERSIONS.txt | 4 ++-- Help/release/dev/remove-old-compatibility.rst | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmPolicies.cxx | 6 +++--- .../cmake_minimum_required/BeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/BeforeVersionRemoved.cmake | 2 +- .../PolicyBeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/PolicyBeforeVersionRemoved.cmake | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Help/command/DEPRECATED_POLICY_VERSIONS.txt b/Help/command/DEPRECATED_POLICY_VERSIONS.txt index b6eb8f46c7..e34e72ec33 100644 --- a/Help/command/DEPRECATED_POLICY_VERSIONS.txt +++ b/Help/command/DEPRECATED_POLICY_VERSIONS.txt @@ -1,9 +1,9 @@ .. versionchanged:: 4.0 - Compatibility with versions of CMake older than 3.1 is removed. + Compatibility with versions of CMake older than 3.2 is removed. Calls to :command:`cmake_minimum_required(VERSION)` or :command:`cmake_policy(VERSION)` that do not specify at least - 3.1 as their policy version (optionally via ``...``) + 3.2 as their policy version (optionally via ``...``) will produce an error in CMake 4.0 and above. .. versionchanged:: 3.31 diff --git a/Help/release/dev/remove-old-compatibility.rst b/Help/release/dev/remove-old-compatibility.rst index aabdd3ccc5..8d74e6702c 100644 --- a/Help/release/dev/remove-old-compatibility.rst +++ b/Help/release/dev/remove-old-compatibility.rst @@ -1,7 +1,7 @@ remove-old-compatibility ------------------------ -* Compatibility with versions of CMake older than 3.1 has been removed. +* Compatibility with versions of CMake older than 3.2 has been removed. Calls to :command:`cmake_minimum_required` or :command:`cmake_policy` that set the policy version to an older value now issue an error. Note that calls to those commands can still support older versions of diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f46ebd858f..8e16f17f9d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1600,7 +1600,7 @@ void cmMakefile::Configure() this->SetCheckCMP0000(true); // Implicitly set the version for the user. - cmPolicies::ApplyPolicyVersion(this, 3, 1, 0, + cmPolicies::ApplyPolicyVersion(this, 3, 2, 0, cmPolicies::WarnCompat::Off); } } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 9005dbb6ec..7c697b07d1 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -295,16 +295,16 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, WarnCompat warnCompat) { // Error on policy versions for which support has been removed. - if (majorVer < 3 || (majorVer == 3 && minorVer < 1)) { + if (majorVer < 3 || (majorVer == 3 && minorVer < 2)) { if (IsFromLegacyInstallEXPORT(mf, majorVer, minorVer, patchVer)) { // Silently tolerate cmake_policy calls generated by install(EXPORT) // in CMake versions prior to 3.18. majorVer = 3; - minorVer = 1; + minorVer = 2; patchVer = 0; } else { mf->IssueMessage(MessageType::FATAL_ERROR, - "Compatibility with CMake < 3.1 has been removed " + "Compatibility with CMake < 3.2 has been removed " "from CMake.\n" ADVICE_UPDATE_VERSION_ARGUMENT); cmSystemTools::SetFatalErrorOccurred(); return false; diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt index 0cdd272b04..07c84e71ab 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at BeforeVersionRemoved\.cmake:1 \(cmake_minimum_required\): - Compatibility with CMake < 3\.1 has been removed from CMake\. + Compatibility with CMake < 3\.2 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake index 03be826d84..c1fcf45cd7 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt index 34e9ce4297..9c14473a77 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at PolicyBeforeVersionRemoved\.cmake:1 \(cmake_policy\): - Compatibility with CMake < 3\.1 has been removed from CMake\. + Compatibility with CMake < 3\.2 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake index 644d3b7564..17e8290cef 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_policy(VERSION 3.0) +cmake_policy(VERSION 3.1) From 2cf04f3034f2ef3f13dee204bb598c5875156cd7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 22 Jan 2025 09:12:10 -0500 Subject: [PATCH 04/15] Source: Include BundleUtilities from running cmake at install time Since commit 249a9bb44d (cmake-gui: use BundleUtilities in place of custom script., 2010-10-14, v2.8.4~299^2) our install scripts include the `BundleUtilities` module from our own source, rather than from the `cmake` that's running at install time. We've now long required a `cmake` version high enough to have the `BundleUtilities` we need. Avoid including a `BundleUtilities` that may be newer than the running `cmake` understands. --- Source/QtDialog/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index e4b53fd2e7..55f40bf476 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -364,7 +364,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/CMake") endif() install(CODE " - include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\") + include(BundleUtilities) set(BU_CHMOD_BUNDLE_ITEMS ON) fixup_bundle(\"${fixup_exe}\" \"${QT_PLUGINS}\" \"${Qt_BIN_DIR};${QT_LIBRARY_DIR};${QT_BINARY_DIR}\") " ${COMPONENT}) From c283aafe62355795ceee471346895e98b38785cd Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Dec 2024 20:08:29 -0500 Subject: [PATCH 05/15] CMP0057: Remove support for OLD behavior --- Help/policy/CMP0057.rst | 9 +++--- Modules/BundleUtilities.cmake | 5 ---- Modules/CMakeFindBinUtils.cmake | 5 ---- Modules/CMakeIOSInstallCombined.cmake | 5 ---- Modules/CSharpUtilities.cmake | 5 ---- Modules/Compiler/ARMClang.cmake | 5 ---- Modules/Compiler/CrayPrgEnv.cmake | 5 ---- Modules/Compiler/IAR-CXX.cmake | 5 ---- Modules/ExternalProject.cmake | 5 ---- Modules/FindBoost.cmake | 1 - Modules/FindDoxygen.cmake | 5 ---- Modules/FindHDF5.cmake | 3 -- Modules/FindJNI.cmake | 5 ---- Modules/FindMPI.cmake | 1 - Modules/FindMatlab.cmake | 1 - Modules/FindOpenMP.cmake | 1 - Modules/FindPackageHandleStandardArgs.cmake | 8 ------ Modules/FindPkgConfig.cmake | 5 ---- Modules/FindPostgreSQL.cmake | 1 - Modules/FindPython/Support.cmake | 2 -- Modules/FindTIFF.cmake | 1 - Modules/FindVulkan.cmake | 1 - Modules/FindwxWidgets.cmake | 5 ---- Modules/GetPrerequisites.cmake | 5 ---- Modules/Internal/CPack/CPackDeb.cmake | 5 ---- Modules/Internal/CPack/CPackRPM.cmake | 5 ---- Modules/Internal/CheckSourceCompiles.cmake | 5 ---- Modules/Internal/CheckSourceRuns.cmake | 5 ---- Modules/Platform/Android-Determine.cmake | 1 - Modules/UseSWIG.cmake | 2 -- Source/cmConditionEvaluator.cxx | 28 ++++--------------- Source/cmConditionEvaluator.h | 1 - Source/cmPolicies.h | 3 +- Tests/CompileFeatures/CMakeLists.txt | 1 - .../AppleTextStubs/LibraryWithVersions.cmake | 2 -- Tests/RunCMake/CMP0057/CMP0057-NEW.cmake | 2 -- Tests/RunCMake/CMP0057/CMP0057-OLD-result.txt | 1 - Tests/RunCMake/CMP0057/CMP0057-OLD-stderr.txt | 8 ------ Tests/RunCMake/CMP0057/CMP0057-OLD.cmake | 7 ----- .../RunCMake/CMP0057/CMP0057-WARN-result.txt | 1 - .../RunCMake/CMP0057/CMP0057-WARN-stderr.txt | 19 ------------- Tests/RunCMake/CMP0057/CMP0057-WARN.cmake | 5 ---- Tests/RunCMake/CMP0057/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0057/RunCMakeTest.cmake | 3 -- Tests/RunCMake/CPack/CPackTestHelpers.cmake | 2 -- Tests/RunCMake/CXXModules/RunCMakeTest.cmake | 3 -- Tests/RunCMake/CXXModules/check-json.cmake | 5 ---- .../examples/build-database-check.cmake | 5 ---- .../CompileFeatures/RunCMakeTest.cmake | 1 - .../RunCMakeTest.cmake | 2 -- .../PrecompileHeaders/RunCMakeTest.cmake | 1 - Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 2 -- .../find_package/CMP0074-common.cmake | 1 - Tests/RunCMake/find_package/PackageRoot.cmake | 1 - .../PackageRootNestedConfig.cmake | 1 - .../PackageRootNestedModule.cmake | 1 - .../RunCMake/project/LanguagesDuplicate.cmake | 2 -- 57 files changed, 12 insertions(+), 215 deletions(-) delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-OLD-result.txt delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-OLD-stderr.txt delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-OLD.cmake delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-WARN-result.txt delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-WARN-stderr.txt delete mode 100644 Tests/RunCMake/CMP0057/CMP0057-WARN.cmake diff --git a/Help/policy/CMP0057.rst b/Help/policy/CMP0057.rst index 07bc96969c..4c78568e07 100644 --- a/Help/policy/CMP0057.rst +++ b/Help/policy/CMP0057.rst @@ -1,6 +1,9 @@ CMP0057 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Support new :command:`if` IN_LIST operator. @@ -11,7 +14,5 @@ The ``OLD`` behavior for this policy is to ignore the IN_LIST operator. The ``NEW`` behavior is to interpret the IN_LIST operator. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 5307901be4..df5248714d 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -247,9 +247,6 @@ if(DEFINED CMAKE_GENERATOR) endif() endif() -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # The functions defined in this file depend on the get_prerequisites function # (and possibly others) found in: # @@ -1127,5 +1124,3 @@ function(verify_app app) message(FATAL_ERROR "error: verify_app failed") endif() endfunction() - -cmake_policy(POP) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index dc28f128d5..7796321a93 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -20,9 +20,6 @@ # on UNIX, cygwin and mingw -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # Resolve full path of CMAKE_TOOL from user-defined name and SEARCH_PATH. function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING) @@ -274,5 +271,3 @@ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") set(CMAKE_IAR_LINKER "${CMAKE_LINKER}" CACHE FILEPATH "The IAR ILINK linker") mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR) endif() - -cmake_policy(POP) diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index fbbe65fcd3..925e8a84c0 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -1,9 +1,6 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # Function to print messages of this module function(_ios_install_combined_message) message(STATUS "[iOS combined] " ${ARGN}) @@ -319,5 +316,3 @@ function(ios_install_combined target destination) _ios_install_combined_message("Install done: ${destination}") endfunction() - -cmake_policy(POP) diff --git a/Modules/CSharpUtilities.cmake b/Modules/CSharpUtilities.cmake index cd4416905a..44c9df5755 100644 --- a/Modules/CSharpUtilities.cmake +++ b/Modules/CSharpUtilities.cmake @@ -186,9 +186,6 @@ Helper functions which are used by the above ones #]=======================================================================] -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - function(csharp_get_filename_keys OUT) set(${OUT} "") foreach(f ${ARGN}) @@ -309,5 +306,3 @@ function(csharp_set_xaml_cs_properties) endif() endforeach() endfunction() - -cmake_policy(POP) diff --git a/Modules/Compiler/ARMClang.cmake b/Modules/Compiler/ARMClang.cmake index 87a41b9a9d..f85da96aa2 100644 --- a/Modules/Compiler/ARMClang.cmake +++ b/Modules/Compiler/ARMClang.cmake @@ -12,9 +12,6 @@ set(_ARMClang_CMAKE_LOADED TRUE) # Save the CMP0123 setting in a variable used both below and by try_compile. cmake_policy(GET CMP0123 CMAKE_ARMClang_CMP0123) -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - set(CMAKE_EXECUTABLE_SUFFIX ".elf") if (CMAKE_LINKER MATCHES "armlink") @@ -142,5 +139,3 @@ macro(__compiler_armclang lang) set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) endmacro() - -cmake_policy(POP) diff --git a/Modules/Compiler/CrayPrgEnv.cmake b/Modules/Compiler/CrayPrgEnv.cmake index f6e46acaac..8bdc982205 100644 --- a/Modules/Compiler/CrayPrgEnv.cmake +++ b/Modules/Compiler/CrayPrgEnv.cmake @@ -7,9 +7,6 @@ set(__cmake_craype_crayprgenv 1) # CrayPrgEnv: loaded when compiling through the Cray compiler wrapper. # The compiler wrapper can run on a front-end node or a compute node. -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # One-time setup of the craype environment. First, check the wrapper config. # The wrapper's selection of a compiler (gcc, clang, intel, etc.) and # default include/library paths is selected using the "module" command. @@ -132,5 +129,3 @@ macro(__CrayPrgEnv_setup lang) endif() endmacro() - -cmake_policy(POP) diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index 7dd03f35a3..bd74e2baa1 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -16,9 +16,6 @@ endif() # Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file. if(NOT CMAKE_IAR_CXX_FLAG) - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) # if IN_LIST - set(_CMAKE_IAR_MODERNCXX_LIST 14 17) if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR ("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98)) @@ -27,8 +24,6 @@ if(NOT CMAKE_IAR_CXX_FLAG) set(CMAKE_IAR_CXX_FLAG --eec++) endif() unset(_CMAKE_IAR_MODERNCXX_LIST) - - cmake_policy(POP) endif() set(CMAKE_CXX_STANDARD_COMPILE_OPTION "") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 2528f44f14..e2d26ca91d 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1300,9 +1300,6 @@ The custom step could then be triggered from the main build like so:: include(${CMAKE_CURRENT_LIST_DIR}/ExternalProject/shared_internal_commands.cmake) -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST - define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED) define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED) define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED) @@ -3088,5 +3085,3 @@ function(ExternalProject_Add name) # _ep_add_test_command(${name}) endfunction() - -cmake_policy(POP) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 39ddfbed7f..d6647d0d5a 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -400,7 +400,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # Save project's policies cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 5d8ac2ae4d..7b882d7f84 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -400,9 +400,6 @@ Deprecated Hint Variables #]=======================================================================] -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # For backwards compatibility support if(Doxygen_FIND_QUIETLY) set(DOXYGEN_FIND_QUIETLY TRUE) @@ -1215,5 +1212,3 @@ doxygen_add_docs() for target ${targetName}") endif() endfunction() - -cmake_policy(POP) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 242d36fd0a..c74a6b6bad 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -481,15 +481,12 @@ function(_HDF5_select_imported_config target imported_conf) message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}") endif() # Now find the first of these that is present in imported_conf - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) # support IN_LISTS foreach (_conf IN LISTS _preferred_confs) if (${_conf} IN_LIST _imported_conf) set(_imported_conf ${_conf}) break() endif() endforeach() - cmake_policy(POP) endif() if(HDF5_FIND_DEBUG) message(STATUS "Selected imported configuration: ${_imported_conf}") diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index e807750ea4..ac3af76827 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -98,9 +98,6 @@ The following cache variables are also available to set or use: The include path to ``jawt.h``. #]=======================================================================] -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) - include(CheckSourceCompiles) include(CMakePushCheckState) include(FindPackageHandleStandardArgs) @@ -692,5 +689,3 @@ if(JNI_FOUND) unset(_JNI_JVM_TYPE) endif() endif() - -cmake_policy(POP) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index a3cdf89396..b6ef962ce9 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -264,7 +264,6 @@ Additionally, the following variables are deprecated: #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 15a0cbe7ca..55f8cbbd46 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -299,7 +299,6 @@ Reference #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}") diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 7664a707ef..cbbf09d7dd 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -111,7 +111,6 @@ to know what include directories are needed. #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ function(_OPENMP_FLAG_CANDIDATES LANG) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 0b7325d2ea..a6fb37b460 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -214,11 +214,6 @@ Example for the usage: include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) -cmake_policy(PUSH) -# IN_LIST operator -cmake_policy(SET CMP0057 NEW) - - # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) set(__msg "${_msg}") @@ -602,6 +597,3 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) endfunction() - - -cmake_policy(POP) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index e525b3626c..acbab8d5bb 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -33,9 +33,6 @@ for how these variables are initialized. #]========================================] -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - ### Common stuff #### set(PKG_CONFIG_VERSION 1) @@ -1046,5 +1043,3 @@ Variables Affecting Behavior ### Local Variables: ### mode: cmake ### End: - -cmake_policy(POP) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 229f364ad0..4131a4ef89 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -92,7 +92,6 @@ is set regardless of the presence of the ``Server`` component in find_package ca # ---------------------------------------------------------------------------- cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index c64731575a..9f6df8052d 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -10,8 +10,6 @@ # cmake_policy(PUSH) -# IN_LIST operator -cmake_policy (SET CMP0057 NEW) # foreach loop variable scope cmake_policy (SET CMP0124 NEW) # registry view behavior diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 27beaa02e2..e541e776f3 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -66,7 +66,6 @@ The following cache variables may also be set: #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ set(_TIFF_args) diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 226211919e..c3ba2db9b9 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -220,7 +220,6 @@ environment. #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ # Provide compatibility with a common invalid component request that diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 88aaf96207..277d5ffccb 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -188,9 +188,6 @@ macro(DBG_MSG_V _MSG) # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") endmacro() -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - # Clear return values in case the module is loaded more than once. set(wxWidgets_FOUND FALSE) set(wxWidgets_INCLUDE_DIRS "") @@ -1241,5 +1238,3 @@ function(WXWIDGETS_ADD_RESOURCES _outfiles) set(${_outfiles} ${${_outfiles}} PARENT_SCOPE) endfunction() - -cmake_policy(POP) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 8e43f33e41..e866512564 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -174,9 +174,6 @@ Possible types are: other #]=======================================================================] -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - function(gp_append_unique list_var value) if(NOT value IN_LIST ${list_var}) set(${list_var} ${${list_var}} "${value}" PARENT_SCOPE) @@ -1046,5 +1043,3 @@ function(list_prerequisites_by_glob glob_arg glob_exp) endif() endforeach() endfunction() - -cmake_policy(POP) diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index e98ed175ea..832a69008e 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -10,9 +10,6 @@ if(CMAKE_BINARY_DIR) message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.") endif() -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - function(cpack_deb_variable_fallback OUTPUT_VAR_NAME) set(FALLBACK_VAR_NAMES ${ARGN}) @@ -886,5 +883,3 @@ function(cpack_deb_prepare_package_vars) endfunction() cpack_deb_prepare_package_vars() - -cmake_policy(POP) diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index c39eb471d7..5ac5336a69 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -3,9 +3,6 @@ # Author: Eric Noulard with the help of Alexander Neundorf. -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - function(set_spec_script_if_enabled TYPE PACKAGE_NAME VAR) if(NOT "${VAR}" STREQUAL "" AND NOT "${VAR}" STREQUAL "\n") if(PACKAGE_NAME) @@ -1999,5 +1996,3 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT endfunction() cpack_rpm_generate_package() - -cmake_policy(POP) diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index e1dcfb71c6..a92ddbba1a 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -3,9 +3,6 @@ include_guard(GLOBAL) -block(SCOPE_FOR POLICIES) -cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST - function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) if(NOT DEFINED "${_var}") set(_lang_filename "src") @@ -138,5 +135,3 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) endif() endif() endfunction() - -endblock() diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index d73db5c6fa..8bdd79264f 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -3,9 +3,6 @@ include_guard(GLOBAL) -block(SCOPE_FOR POLICIES) -cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST - function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) if(NOT DEFINED "${_var}") @@ -130,5 +127,3 @@ function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) endif() endif() endfunction() - -endblock() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index bab604298d..23c8a18646 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -31,7 +31,6 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") endif() cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ # If using Android tools for Visual Studio, compile a sample project to get the diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index d6510f30b3..b9753e5898 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -394,8 +394,6 @@ Deprecated Commands #]=======================================================================] cmake_policy(PUSH) -# IN_LIST operator -cmake_policy (SET CMP0057 NEW) # Ninja generator normalizes custom command depfile paths cmake_policy (SET CMP0116 NEW) diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 15b327c6e4..555aeedb82 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -218,7 +218,6 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt) : Makefile(makefile) , Backtrace(std::move(bt)) - , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) , Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064)) , Policy139Status(makefile.GetPolicyStatus(cmPolicies::CMP0139)) { @@ -665,29 +664,12 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, } else if (this->IsKeyword(keyIN_LIST, *args.next)) { + cmValue lhs = this->GetVariableOrString(*args.current); + cmValue rhs = this->Makefile.GetDefinition(args.nextnext->GetValue()); - if (this->Policy57Status != cmPolicies::OLD && - this->Policy57Status != cmPolicies::WARN) { - - cmValue lhs = this->GetVariableOrString(*args.current); - cmValue rhs = this->Makefile.GetDefinition(args.nextnext->GetValue()); - - newArgs.ReduceTwoArgs( - rhs && - cm::contains(cmList{ *rhs, cmList::EmptyElements::Yes }, *lhs), - args); - } - - else if (this->Policy57Status == cmPolicies::WARN) { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) - << "\n" - "IN_LIST will be interpreted as an operator " - "when the policy is set to NEW. " - "Since the policy is not set the OLD behavior will be used."; - - this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - } + newArgs.ReduceTwoArgs( + rhs && cm::contains(cmList{ *rhs, cmList::EmptyElements::Yes }, *lhs), + args); } else if (this->IsKeyword(keyPATH_EQUAL, *args.next)) { diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index 1990f5fca3..bd1edc5930 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -66,7 +66,6 @@ private: cmMakefile& Makefile; cmListFileBacktrace Backtrace; - cmPolicies::PolicyStatus Policy57Status; cmPolicies::PolicyStatus Policy64Status; cmPolicies::PolicyStatus Policy139Status; }; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 8540598864..bea5a5a2dd 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -168,8 +168,7 @@ class cmMakefile; SELECT(POLICY, CMP0056, \ "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \ NEW) \ - SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0, \ - WARN) \ + SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0, NEW) \ SELECT(POLICY, CMP0058, \ "Ninja requires custom command byproducts to be explicit.", 3, 3, 0, \ WARN) \ diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 29174e5b92..5bbefe49d6 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.10) -cmake_policy(SET CMP0057 NEW) project(CompileFeatures) diff --git a/Tests/RunCMake/AppleTextStubs/LibraryWithVersions.cmake b/Tests/RunCMake/AppleTextStubs/LibraryWithVersions.cmake index 110a61cda7..5f86f90788 100644 --- a/Tests/RunCMake/AppleTextStubs/LibraryWithVersions.cmake +++ b/Tests/RunCMake/AppleTextStubs/LibraryWithVersions.cmake @@ -25,8 +25,6 @@ set (GENERATE_CONTENT "if (\"${CMAKE_TAPI}\") endif()\n\n") string (APPEND GENERATE_CONTENT [[ -cmake_policy (SET CMP0057 NEW) - macro (CHECK_FILE test_msg path) if (NOT EXISTS "${path}") string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" not found\n") diff --git a/Tests/RunCMake/CMP0057/CMP0057-NEW.cmake b/Tests/RunCMake/CMP0057/CMP0057-NEW.cmake index ebd7ba580e..5689868f0f 100644 --- a/Tests/RunCMake/CMP0057/CMP0057-NEW.cmake +++ b/Tests/RunCMake/CMP0057/CMP0057-NEW.cmake @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0057 NEW) - set(MY_NON_EXISTENT_LIST) set(MY_EMPTY_LIST "") diff --git a/Tests/RunCMake/CMP0057/CMP0057-OLD-result.txt b/Tests/RunCMake/CMP0057/CMP0057-OLD-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CMP0057/CMP0057-OLD-stderr.txt b/Tests/RunCMake/CMP0057/CMP0057-OLD-stderr.txt deleted file mode 100644 index f3fad8da96..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-OLD-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at CMP0057-OLD.cmake:5 \(if\): - if given arguments: - - "foo" "IN_LIST" "MY_LIST" - - Unknown arguments specified -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0057/CMP0057-OLD.cmake b/Tests/RunCMake/CMP0057/CMP0057-OLD.cmake deleted file mode 100644 index cf9ec890bf..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-OLD.cmake +++ /dev/null @@ -1,7 +0,0 @@ -cmake_policy(SET CMP0057 OLD) - -set(MY_LIST foo bar) - -if("foo" IN_LIST MY_LIST) - message("foo is in MY_LIST") -endif() diff --git a/Tests/RunCMake/CMP0057/CMP0057-WARN-result.txt b/Tests/RunCMake/CMP0057/CMP0057-WARN-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CMP0057/CMP0057-WARN-stderr.txt b/Tests/RunCMake/CMP0057/CMP0057-WARN-stderr.txt deleted file mode 100644 index b1c9b63b42..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-WARN-stderr.txt +++ /dev/null @@ -1,19 +0,0 @@ -CMake Warning \(dev\) at CMP0057-WARN.cmake:3 \(if\): - Policy CMP0057 is not set: Support new IN_LIST if\(\) operator. Run "cmake - --help-policy CMP0057" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - IN_LIST will be interpreted as an operator when the policy is set to NEW. - Since the policy is not set the OLD behavior will be used. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Error at CMP0057-WARN.cmake:3 \(if\): - if given arguments: - - "foo" "IN_LIST" "MY_LIST" - - Unknown arguments specified -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0057/CMP0057-WARN.cmake b/Tests/RunCMake/CMP0057/CMP0057-WARN.cmake deleted file mode 100644 index 45f53a52cf..0000000000 --- a/Tests/RunCMake/CMP0057/CMP0057-WARN.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(MY_LIST foo bar) - -if("foo" IN_LIST MY_LIST) - message("foo is in MY_LIST") -endif() diff --git a/Tests/RunCMake/CMP0057/CMakeLists.txt b/Tests/RunCMake/CMP0057/CMakeLists.txt index 18dfd2686f..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0057/CMakeLists.txt +++ b/Tests/RunCMake/CMP0057/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0057/RunCMakeTest.cmake b/Tests/RunCMake/CMP0057/RunCMakeTest.cmake index 76eaca6e7f..979158701a 100644 --- a/Tests/RunCMake/CMP0057/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0057/RunCMakeTest.cmake @@ -1,6 +1,3 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0057-OLD) -run_cmake(CMP0057-WARN) run_cmake(CMP0057-NEW) diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 3ec4c691e0..5d60aacdc6 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0057 NEW) - function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE package_target) if(TEST_TYPE IN_LIST types) string(REGEX MATCH "^[^.]*" GENERATOR_TYPE "${TEST_TYPE}") diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 47475d36f1..8ed2f97f20 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -1,8 +1,5 @@ include(RunCMake) -# For `if (IN_LIST)` -cmake_policy(SET CMP0057 NEW) - run_cmake(Inspect) include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") diff --git a/Tests/RunCMake/CXXModules/check-json.cmake b/Tests/RunCMake/CXXModules/check-json.cmake index ec15f14765..09edc33e5b 100644 --- a/Tests/RunCMake/CXXModules/check-json.cmake +++ b/Tests/RunCMake/CXXModules/check-json.cmake @@ -1,6 +1,3 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) - function (json_placeholders in out) string(REPLACE "" "${CXXModules_config}" in "${in}") string(TOLOWER "${CXXModules_config}" config_lower) @@ -228,5 +225,3 @@ function (check_json actual expect) set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) endfunction () - -cmake_policy(POP) diff --git a/Tests/RunCMake/CXXModules/examples/build-database-check.cmake b/Tests/RunCMake/CXXModules/examples/build-database-check.cmake index 734b5809f8..c09aceaecd 100644 --- a/Tests/RunCMake/CXXModules/examples/build-database-check.cmake +++ b/Tests/RunCMake/CXXModules/examples/build-database-check.cmake @@ -1,6 +1,3 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) - include("${CMAKE_CURRENT_LIST_DIR}/../check-json.cmake") function (check_build_database expect_basename fname component) @@ -77,5 +74,3 @@ function (check_build_database expect_basename fname component) set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) endfunction () - -cmake_policy(POP) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 487284ba75..508662e2b0 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0057 NEW) include(RunCMake) run_cmake(NotAFeature) diff --git a/Tests/RunCMake/GenEx-TARGET_IMPORT_FILE/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_IMPORT_FILE/RunCMakeTest.cmake index 04ff640942..5a272418c3 100644 --- a/Tests/RunCMake/GenEx-TARGET_IMPORT_FILE/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-TARGET_IMPORT_FILE/RunCMakeTest.cmake @@ -1,7 +1,5 @@ include(RunCMake) -cmake_policy(SET CMP0057 NEW) - function(run_cmake_with_config test) if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index c8a5c154c7..139d58673c 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0057 NEW) include(RunCMake) function(run_test name) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 117b0cd292..37f780c786 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0057 NEW) - include(RunCMake) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) diff --git a/Tests/RunCMake/find_package/CMP0074-common.cmake b/Tests/RunCMake/find_package/CMP0074-common.cmake index bfacd82c4a..80410d1c9c 100644 --- a/Tests/RunCMake/find_package/CMP0074-common.cmake +++ b/Tests/RunCMake/find_package/CMP0074-common.cmake @@ -1,5 +1,4 @@ # (includer selects CMP0074) -cmake_policy(SET CMP0057 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/PackageRoot.cmake b/Tests/RunCMake/find_package/PackageRoot.cmake index aa12e9b5f2..0ce172b65e 100644 --- a/Tests/RunCMake/find_package/PackageRoot.cmake +++ b/Tests/RunCMake/find_package/PackageRoot.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake index 1ef32cbbaa..cc784ae766 100644 --- a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake +++ b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake index 017834cd34..82e71a3865 100644 --- a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake +++ b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/project/LanguagesDuplicate.cmake b/Tests/RunCMake/project/LanguagesDuplicate.cmake index 97a79d0823..e1f6c9514d 100644 --- a/Tests/RunCMake/project/LanguagesDuplicate.cmake +++ b/Tests/RunCMake/project/LanguagesDuplicate.cmake @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0057 NEW) - project(ProjectA C C C) project(ProjectB C C CXX CXX) From 8f9f01b24dfe662d6e6ebcafbebb24b85f312974 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Dec 2024 20:19:00 -0500 Subject: [PATCH 06/15] CMP0058: Remove support for OLD behavior --- Help/policy/CMP0058.rst | 13 +- Source/cmGlobalNinjaGenerator.cxx | 149 ------------------ Source/cmGlobalNinjaGenerator.h | 14 -- Source/cmPolicies.h | 2 +- Tests/CustomCommandByproducts/CMakeLists.txt | 8 - .../CustomCommandByproducts/ninja-check.cmake | 20 --- Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake | 1 - Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake | 1 - .../Ninja/CMP0058-OLD-by-build-stdout.txt | 4 - .../RunCMake/Ninja/CMP0058-OLD-by-stderr.txt | 20 --- Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake | 4 - .../Ninja/CMP0058-OLD-no-build-stdout.txt | 4 - .../RunCMake/Ninja/CMP0058-OLD-no-stderr.txt | 20 --- Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake | 3 - .../Ninja/CMP0058-WARN-by-build-stdout.txt | 4 - .../RunCMake/Ninja/CMP0058-WARN-by-stderr.txt | 9 -- Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake | 3 - .../Ninja/CMP0058-WARN-no-build-stdout.txt | 4 - .../RunCMake/Ninja/CMP0058-WARN-no-stderr.txt | 29 ---- Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake | 2 - Tests/RunCMake/Ninja/RunCMakeTest.cmake | 4 - 21 files changed, 8 insertions(+), 310 deletions(-) delete mode 100644 Tests/CustomCommandByproducts/ninja-check.cmake delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt delete mode 100644 Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake diff --git a/Help/policy/CMP0058.rst b/Help/policy/CMP0058.rst index 2b729e0dcf..7069a93a8c 100644 --- a/Help/policy/CMP0058.rst +++ b/Help/policy/CMP0058.rst @@ -1,6 +1,9 @@ CMP0058 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Ninja requires custom command byproducts to be explicit. @@ -104,12 +107,10 @@ rules for unknown dependencies in the build tree. The ``NEW`` behavior for this policy is to not generate these and instead require projects to specify custom command ``BYPRODUCTS`` explicitly. -.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: - warns when it sees unknown dependencies in out-of-source build trees -.. include:: STANDARD_ADVICE.txt - The policy setting must be in scope at the end of the top-level ``CMakeLists.txt`` file of the project and has global effect. -.. include:: DEPRECATED.txt +.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 +.. |WARNED_OR_DID_NOT_WARN| replace:: + warned when it saw unknown dependencies in out-of-source build trees +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e65089329e..aff312b5a2 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -30,7 +30,6 @@ #include "cmDyndepCollation.h" #include "cmFortranParser.h" #include "cmGeneratedFileStream.h" -#include "cmGeneratorExpressionEvaluationFile.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLinkLineComputer.h" @@ -243,9 +242,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, // Write explicit outputs for (std::string const& output : build.Outputs) { buildStr = cmStrCat(buildStr, ' ', this->EncodePath(output)); - if (this->ComputingUnknownDependencies) { - this->CombinedBuildOutputs.insert(output); - } } // Write implicit outputs if (!build.ImplicitOuts.empty()) { @@ -254,9 +250,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, buildStr = cmStrCat(buildStr, " |"); for (std::string const& implicitOut : build.ImplicitOuts) { buildStr = cmStrCat(buildStr, ' ', this->EncodePath(implicitOut)); - if (this->ComputingUnknownDependencies) { - this->CombinedBuildOutputs.insert(implicitOut); - } } } @@ -371,14 +364,6 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( { this->AddCustomCommandRule(); - if (this->ComputingUnknownDependencies) { - // we need to track every dependency that comes in, since we are trying - // to find dependencies that are side effects of build commands - for (std::string const& dep : explicitDeps) { - this->CombinedCustomCommandExplicitDependencies.insert(dep); - } - } - { std::string ninjaDepfilePath; bool depfileIsOutput = false; @@ -641,19 +626,11 @@ void cmGlobalNinjaGenerator::Generate() this->ClangTidyExportFixesDirs.clear(); this->ClangTidyExportFixesFiles.clear(); - this->PolicyCMP0058 = - this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus( - cmPolicies::CMP0058); - this->ComputingUnknownDependencies = - (this->PolicyCMP0058 == cmPolicies::OLD || - this->PolicyCMP0058 == cmPolicies::WARN); - this->cmGlobalGenerator::Generate(); this->WriteAssumedSourceDependencies(); this->WriteTargetAliases(*this->GetCommonFileStream()); this->WriteFolderTargets(*this->GetCommonFileStream()); - this->WriteUnknownExplicitDependencies(*this->GetCommonFileStream()); this->WriteBuiltinTargets(*this->GetCommonFileStream()); if (cmSystemTools::GetErrorOccurredFlag()) { @@ -1227,10 +1204,6 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand( if (!this->CompileCommandsStream) { std::string buildFilePath = cmStrCat(buildFileDir, "/compile_commands.json"); - if (this->ComputingUnknownDependencies) { - this->CombinedBuildOutputs.insert( - this->NinjaOutputPath("compile_commands.json")); - } // Get a stream where to generate things. this->CompileCommandsStream = @@ -1779,128 +1752,6 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) } } -void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) -{ - if (!this->ComputingUnknownDependencies) { - return; - } - - // We need to collect the set of known build outputs. - // Start with those generated by WriteBuild calls. - // No other method needs this so we can take ownership - // of the set locally and throw it out when we are done. - std::set knownDependencies; - knownDependencies.swap(this->CombinedBuildOutputs); - - // now write out the unknown explicit dependencies. - - // union the configured files, evaluations files and the - // CombinedBuildOutputs, - // and then difference with CombinedExplicitDependencies to find the explicit - // dependencies that we have no rule for - - cmGlobalNinjaGenerator::WriteDivider(os); - /* clang-format off */ - os << "# Unknown Build Time Dependencies.\n" - << "# Tell Ninja that they may appear as side effects of build rules\n" - << "# otherwise ordered by order-only dependencies.\n\n"; - /* clang-format on */ - - // get the list of files that cmake itself has generated as a - // product of configuration. - - for (const auto& lg : this->LocalGenerators) { - // get the vector of files created by this makefile and convert them - // to ninja paths, which are all relative in respect to the build directory - for (std::string const& file : lg->GetMakefile()->GetOutputFiles()) { - knownDependencies.insert(this->ConvertToNinjaPath(file)); - } - if (!this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) { - // get list files which are implicit dependencies as well and will be - // phony for rebuild manifest - for (std::string const& j : lg->GetMakefile()->GetListFiles()) { - knownDependencies.insert(this->ConvertToNinjaPath(j)); - } - } - for (const auto& li : lg->GetMakefile()->GetEvaluationFiles()) { - // get all the files created by generator expressions and convert them - // to ninja paths - for (std::string const& evaluationFile : li->GetFiles()) { - knownDependencies.insert(this->ConvertToNinjaPath(evaluationFile)); - } - } - } - knownDependencies.insert(this->CMakeCacheFile); - - for (auto const& ta : this->TargetAliases) { - knownDependencies.insert(this->ConvertToNinjaPath(ta.first)); - } - - // remove all source files we know will exist. - for (auto const& i : this->AssumedSourceDependencies) { - knownDependencies.insert(this->ConvertToNinjaPath(i.first)); - } - - // now we difference with CombinedCustomCommandExplicitDependencies to find - // the list of items we know nothing about. - // We have encoded all the paths in CombinedCustomCommandExplicitDependencies - // and knownDependencies so no matter if unix or windows paths they - // should all match now. - - std::vector unknownExplicitDepends; - this->CombinedCustomCommandExplicitDependencies.erase(this->TargetAll); - - std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(), - this->CombinedCustomCommandExplicitDependencies.end(), - knownDependencies.begin(), knownDependencies.end(), - std::back_inserter(unknownExplicitDepends)); - - std::vector warnExplicitDepends; - if (!unknownExplicitDepends.empty()) { - cmake* cmk = this->GetCMakeInstance(); - std::string const& buildRoot = cmk->GetHomeOutputDirectory(); - bool const inSource = (buildRoot == cmk->GetHomeDirectory()); - bool const warn = (!inSource && (this->PolicyCMP0058 == cmPolicies::WARN)); - cmNinjaBuild build("phony"); - build.Outputs.emplace_back(""); - for (std::string const& ued : unknownExplicitDepends) { - // verify the file is in the build directory - std::string const absDepPath = - cmSystemTools::CollapseFullPath(ued, buildRoot); - if (cmSystemTools::IsSubDirectory(absDepPath, buildRoot)) { - // Generate phony build statement - build.Outputs[0] = ued; - this->WriteBuild(os, build); - // Add to warning on demand - if (warn && warnExplicitDepends.size() < 10) { - warnExplicitDepends.push_back(ued); - } - } - } - } - - if (!warnExplicitDepends.empty()) { - std::ostringstream w; - /* clang-format off */ - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0058) << "\n" - "This project specifies custom command DEPENDS on files " - "in the build tree that are not specified as the OUTPUT or " - "BYPRODUCTS of any add_custom_command or add_custom_target:\n" - " " << cmJoin(warnExplicitDepends, "\n ") << - "\n" - "For compatibility with versions of CMake that did not have " - "the BYPRODUCTS option, CMake is generating phony rules for " - "such files to convince 'ninja' to build." - "\n" - "Project authors should add the missing BYPRODUCTS or OUTPUT " - "options to the custom commands that produce these files." - ; - /* clang-format on */ - this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, - w.str()); - } -} - void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) { // Write headers. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 3af5c1ad1c..d3565720d1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -23,7 +23,6 @@ #include "cmGlobalCommonGenerator.h" #include "cmGlobalGeneratorFactory.h" #include "cmNinjaTypes.h" -#include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmTransformDepfile.h" @@ -531,7 +530,6 @@ private: void WriteTargetAliases(std::ostream& os); void WriteFolderTargets(std::ostream& os); - void WriteUnknownExplicitDependencies(std::ostream& os); void WriteBuiltinTargets(std::ostream& os); void WriteTargetDefault(std::ostream& os); @@ -566,18 +564,6 @@ private: /// The set of custom command outputs we have seen. std::set CustomCommandOutputs; - /// Whether we are collecting known build outputs and needed - /// dependencies to determine unknown dependencies. - bool ComputingUnknownDependencies = false; - cmPolicies::PolicyStatus PolicyCMP0058 = cmPolicies::WARN; - - /// The combined explicit dependencies of custom build commands - std::set CombinedCustomCommandExplicitDependencies; - - /// When combined with CombinedCustomCommandExplicitDependencies it allows - /// us to detect the set of explicit dependencies that have - std::set CombinedBuildOutputs; - /// The mapping from source file to assumed dependencies. std::map> AssumedSourceDependencies; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index bea5a5a2dd..03b6f81c75 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -171,7 +171,7 @@ class cmMakefile; SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0, NEW) \ SELECT(POLICY, CMP0058, \ "Ninja requires custom command byproducts to be explicit.", 3, 3, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0059, \ "Do not treat DEFINITIONS as a built-in directory property.", 3, 3, \ 0, WARN) \ diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index 73a7fccc1e..24d9a7d296 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.10) -cmake_policy(SET CMP0058 OLD) project(CustomCommandByproducts C) # Generate a byproduct in a rule that runs in the target consuming it. @@ -203,10 +202,3 @@ target_link_libraries( ExternalLibraryByproducts_WithInstallDirSubstitution ExternalLibraryWithInstallDirSubstitution ) - -if(CMAKE_GENERATOR STREQUAL "Ninja") - add_custom_target(CheckNinja ALL - COMMENT "Checking build.ninja" - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/ninja-check.cmake - ) -endif() diff --git a/Tests/CustomCommandByproducts/ninja-check.cmake b/Tests/CustomCommandByproducts/ninja-check.cmake deleted file mode 100644 index a7beb3d645..0000000000 --- a/Tests/CustomCommandByproducts/ninja-check.cmake +++ /dev/null @@ -1,20 +0,0 @@ -file(READ build.ninja build_ninja) -if("${build_ninja}" MATCHES [====[ -# Unknown Build Time Dependencies. -# Tell Ninja that they may appear as side effects of build rules -# otherwise ordered by order-only dependencies. - -((build [^:]*: phony[^\n]* -)*)# ========]====]) - set(phony "${CMAKE_MATCH_1}") - if(NOT phony) - message(STATUS "build.ninja correctly does not have extra phony rules") - else() - string(REGEX REPLACE "\n+$" "" phony "${phony}") - string(REGEX REPLACE "\n" "\n " phony " ${phony}") - message(FATAL_ERROR "build.ninja incorrectly has extra phony rules:\n" - "${phony}") - endif() -else() - message(FATAL_ERROR "build.ninja is incorrectly missing expected block") -endif() diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake b/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake index 0f7793096e..6128167967 100644 --- a/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake @@ -1,3 +1,2 @@ -cmake_policy(SET CMP0058 NEW) set(byproducts BYPRODUCTS byproduct1a byproduct1b) include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake b/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake index 582e3d530e..7bc66ef284 100644 --- a/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake @@ -1,2 +1 @@ -cmake_policy(SET CMP0058 NEW) include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt deleted file mode 100644 index 8646a13e87..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ -^[^ -]* Generating output1 -[^ -]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt deleted file mode 100644 index 4cf1f19ffd..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt +++ /dev/null @@ -1,20 +0,0 @@ -^CMake Deprecation Warning at CMP0058-OLD-by\.cmake:[0-9] \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9] \(include\) -+ -CMake Deprecation Warning at CMP0058-OLD-by\.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0058 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/Ninja/CMP0058-OLD-by.cmake b/Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake deleted file mode 100644 index 45e5aa3721..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake +++ /dev/null @@ -1,4 +0,0 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0058 OLD) -set(byproducts BYPRODUCTS byproduct1a byproduct1b) -include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt deleted file mode 100644 index 8646a13e87..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ -^[^ -]* Generating output1 -[^ -]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt deleted file mode 100644 index 6a9bc62106..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt +++ /dev/null @@ -1,20 +0,0 @@ -^CMake Deprecation Warning at CMP0058-OLD-no\.cmake:[0-9] \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9] \(include\) -+ -CMake Deprecation Warning at CMP0058-OLD-no\.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0058 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/Ninja/CMP0058-OLD-no.cmake b/Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake deleted file mode 100644 index 388e0184c4..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake +++ /dev/null @@ -1,3 +0,0 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0058 OLD) -include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt deleted file mode 100644 index 8646a13e87..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ -^[^ -]* Generating output1 -[^ -]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt deleted file mode 100644 index 5abfda7336..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -^CMake Deprecation Warning at CMP0058-WARN-by\.cmake:[0-9] \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9] \(include\)$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake b/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake deleted file mode 100644 index 6f5484a051..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake +++ /dev/null @@ -1,3 +0,0 @@ -cmake_policy(VERSION 3.2) -set(byproducts BYPRODUCTS byproduct1a byproduct1b) -include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt deleted file mode 100644 index 8646a13e87..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ -^[^ -]* Generating output1 -[^ -]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt deleted file mode 100644 index 70d94517f3..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt +++ /dev/null @@ -1,29 +0,0 @@ -^CMake Deprecation Warning at CMP0058-WARN-no\.cmake:[0-9] \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9] \(include\) -+ -CMake Warning \(dev\): - Policy CMP0058 is not set: Ninja requires custom command byproducts to be - explicit. Run "cmake --help-policy CMP0058" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - This project specifies custom command DEPENDS on files in the build tree - that are not specified as the OUTPUT or BYPRODUCTS of any - add_custom_command or add_custom_target: - - byproduct1a - byproduct1b - - For compatibility with versions of CMake that did not have the BYPRODUCTS - option, CMake is generating phony rules for such files to convince 'ninja' - to build. - - Project authors should add the missing BYPRODUCTS or OUTPUT options to the - custom commands that produce these files. -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake b/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake deleted file mode 100644 index 714ae6443b..0000000000 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(VERSION 3.2) -include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index d1f99b2178..003f19ea46 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -93,10 +93,6 @@ function(run_CMP0058 case) run_cmake_command(CMP0058-${case}-build ${CMAKE_COMMAND} --build .) endfunction() -run_CMP0058(OLD-no) -run_CMP0058(OLD-by) -run_CMP0058(WARN-no) -run_CMP0058(WARN-by) run_CMP0058(NEW-no) run_CMP0058(NEW-by) From 1393fbf13fdd5afd59ee5298ef4a7cd9e419a880 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Dec 2024 16:26:19 -0500 Subject: [PATCH 07/15] CMP0059: Remove support for OLD behavior --- Help/policy/CMP0059.rst | 9 +++---- Source/cmGetDirectoryPropertyCommand.cxx | 24 ------------------- Source/cmGetPropertyCommand.cxx | 15 ------------ Source/cmMakefile.cxx | 12 ---------- Source/cmMakefile.h | 5 ---- Source/cmPolicies.h | 2 +- Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt | 1 - Tests/RunCMake/CMP0059/CMP0059-NEW.cmake | 3 --- Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt | 1 - Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt | 2 -- Tests/RunCMake/CMP0059/CMP0059-OLD.cmake | 17 ------------- .../RunCMake/CMP0059/CMP0059-WARN-result.txt | 1 - .../RunCMake/CMP0059/CMP0059-WARN-stderr.txt | 18 -------------- Tests/RunCMake/CMP0059/CMP0059-WARN.cmake | 17 ------------- Tests/RunCMake/CMP0059/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0059/RunCMakeTest.cmake | 2 -- 16 files changed, 7 insertions(+), 124 deletions(-) delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-OLD.cmake delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt delete mode 100644 Tests/RunCMake/CMP0059/CMP0059-WARN.cmake diff --git a/Help/policy/CMP0059.rst b/Help/policy/CMP0059.rst index 4ac286d2f5..3dfc81b9ee 100644 --- a/Help/policy/CMP0059.rst +++ b/Help/policy/CMP0059.rst @@ -1,6 +1,9 @@ CMP0059 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Do not treat ``DEFINITIONS`` as a built-in directory property. @@ -14,7 +17,5 @@ so far to the :command:`add_definitions` command. The ``NEW`` behavior is to behave as a normal user-defined directory property. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index d05f1c6268..122eb168c3 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -5,14 +5,10 @@ #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmMessageType.h" -#include "cmPolicies.h" #include "cmSystemTools.h" #include "cmValue.h" namespace { -void StoreResult(cmMakefile& makefile, std::string const& variable, - const char* prop); void StoreResult(cmMakefile& makefile, std::string const& variable, cmValue prop); } @@ -78,31 +74,11 @@ bool cmGetDirectoryPropertyCommand(std::vector const& args, return false; } - if (*i == "DEFINITIONS") { - switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0059)) { - case cmPolicies::WARN: - status.GetMakefile().IssueMessage( - MessageType::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(cmPolicies::CMP0059)); - CM_FALLTHROUGH; - case cmPolicies::OLD: - StoreResult(status.GetMakefile(), variable, - status.GetMakefile().GetDefineFlagsCMP0059()); - return true; - case cmPolicies::NEW: - break; - } - } StoreResult(status.GetMakefile(), variable, dir->GetProperty(*i)); return true; } namespace { -void StoreResult(cmMakefile& makefile, std::string const& variable, - const char* prop) -{ - makefile.AddDefinition(variable, prop ? prop : ""); -} void StoreResult(cmMakefile& makefile, std::string const& variable, cmValue prop) { diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 96373494be..0a0df88ce3 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -12,7 +12,6 @@ #include "cmGlobalGenerator.h" #include "cmInstalledFile.h" #include "cmMakefile.h" -#include "cmMessageType.h" #include "cmPolicies.h" #include "cmProperty.h" #include "cmPropertyDefinition.h" @@ -370,20 +369,6 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name, } } - if (propertyName == "DEFINITIONS") { - switch (mf->GetPolicyStatus(cmPolicies::CMP0059)) { - case cmPolicies::WARN: - mf->IssueMessage(MessageType::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(cmPolicies::CMP0059)); - CM_FALLTHROUGH; - case cmPolicies::OLD: - return StoreResult(infoType, status.GetMakefile(), variable, - mf->GetDefineFlagsCMP0059()); - case cmPolicies::NEW: - break; - } - } - // Get the property. return StoreResult(infoType, status.GetMakefile(), variable, mf->GetProperty(propertyName)); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8e16f17f9d..630777933f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1245,9 +1245,6 @@ void cmMakefile::AddDefineFlag(std::string const& flag) return; } - // Update the string used for the old DEFINITIONS property. - s_AddDefineFlag(flag, this->DefineFlagsOrig); - // If this is really a definition, update COMPILE_DEFINITIONS. if (this->ParseDefineFlag(flag, false)) { return; @@ -1281,9 +1278,6 @@ void cmMakefile::RemoveDefineFlag(std::string const& flag) return; } - // Update the string used for the old DEFINITIONS property. - s_RemoveDefineFlag(flag, this->DefineFlagsOrig); - // If this is really a definition, update COMPILE_DEFINITIONS. if (this->ParseDefineFlag(flag, true)) { return; @@ -1357,7 +1351,6 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) // define flags this->DefineFlags = parent->DefineFlags; - this->DefineFlagsOrig = parent->DefineFlagsOrig; // Include transform property. There is no per-config version. { @@ -3977,11 +3970,6 @@ cmStateSnapshot cmMakefile::GetStateSnapshot() const return this->StateSnapshot; } -const char* cmMakefile::GetDefineFlagsCMP0059() const -{ - return this->DefineFlagsOrig.c_str(); -} - cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id, bool parent_scope) const { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 199995b9cd..74f988e8a1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1006,8 +1006,6 @@ public: cmStateSnapshot GetStateSnapshot() const; - const char* GetDefineFlagsCMP0059() const; - void EnforceDirectoryLevelRules() const; void AddEvaluationFile( @@ -1134,9 +1132,6 @@ protected: std::string ComplainFileRegularExpression; std::string DefineFlags; - // Track the value of the computed DEFINITIONS property. - std::string DefineFlagsOrig; - #if !defined(CMAKE_BOOTSTRAP) std::vector SourceGroups; size_t ObjectLibrariesSourceGroupIndex; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 03b6f81c75..041d67c17a 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -174,7 +174,7 @@ class cmMakefile; NEW) \ SELECT(POLICY, CMP0059, \ "Do not treat DEFINITIONS as a built-in directory property.", 3, 3, \ - 0, WARN) \ + 0, NEW) \ SELECT(POLICY, CMP0060, \ "Link libraries by full path even in implicit directories.", 3, 3, \ 0, WARN) \ diff --git a/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt b/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake b/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake index f7b9303cd4..0dde53692c 100644 --- a/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake +++ b/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake @@ -1,6 +1,3 @@ - -cmake_policy(SET CMP0059 NEW) - add_definitions(-DSOME_DEF) get_property(defs DIRECTORY . diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt b/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt deleted file mode 100644 index e35e8c5f1b..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -DEFS: -DSOME_DEF -CUSTOM CONTENT: -DSOME_DEF diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake b/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake deleted file mode 100644 index 25557744d4..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake +++ /dev/null @@ -1,17 +0,0 @@ - -cmake_policy(SET CMP0059 OLD) - -add_definitions(-DSOME_DEF) - -get_property(defs DIRECTORY . - PROPERTY DEFINITIONS -) -message("DEFS:${defs}") - -set_property(DIRECTORY . - PROPERTY DEFINITIONS CUSTOM_CONTENT -) -get_property(content DIRECTORY . - PROPERTY DEFINITIONS -) -message("CUSTOM CONTENT:${content}") diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt b/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt deleted file mode 100644 index 06c7be3120..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt +++ /dev/null @@ -1,18 +0,0 @@ -CMake Warning \(dev\) at CMP0059-WARN.cmake:6 \(get_property\): - Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory - property. Run "cmake --help-policy CMP0059" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -DEFS: -DSOME_DEF -CMake Warning \(dev\) at CMP0059-WARN.cmake:14 \(get_property\): - Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory - property. Run "cmake --help-policy CMP0059" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CUSTOM CONTENT: -DSOME_DEF diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake b/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake deleted file mode 100644 index 9d0b49c8e2..0000000000 --- a/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake +++ /dev/null @@ -1,17 +0,0 @@ - - - -add_definitions(-DSOME_DEF) - -get_property(defs DIRECTORY . - PROPERTY DEFINITIONS -) -message("DEFS:${defs}") - -set_property(DIRECTORY . - PROPERTY DEFINITIONS CUSTOM_CONTENT -) -get_property(content DIRECTORY . - PROPERTY DEFINITIONS -) -message("CUSTOM CONTENT:${content}") diff --git a/Tests/RunCMake/CMP0059/CMakeLists.txt b/Tests/RunCMake/CMP0059/CMakeLists.txt index ef2163c298..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0059/CMakeLists.txt +++ b/Tests/RunCMake/CMP0059/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0059/RunCMakeTest.cmake b/Tests/RunCMake/CMP0059/RunCMakeTest.cmake index 9b5757954c..b95bb0f943 100644 --- a/Tests/RunCMake/CMP0059/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0059/RunCMakeTest.cmake @@ -1,5 +1,3 @@ include(RunCMake) -run_cmake(CMP0059-OLD) run_cmake(CMP0059-NEW) -run_cmake(CMP0059-WARN) From 3dc19e24cb6be30a9d53f06530d6e65c0c0e66ed Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Dec 2024 16:32:10 -0500 Subject: [PATCH 08/15] CMP0060: Remove support for OLD behavior --- Help/command/target_link_libraries.rst | 3 +- Help/policy/CMP0060.rst | 11 ++-- .../CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst | 8 +-- .../variable/CMAKE_POLICY_WARNING_CMPNNNN.rst | 4 +- Source/cmComputeLinkInformation.cxx | 54 +------------------ Source/cmComputeLinkInformation.h | 2 - Source/cmPolicies.h | 2 +- Tests/RunCMake/CMP0060/CMP0060-NEW.cmake | 1 - .../CMP0060/CMP0060-OLD-Build-result.txt | 1 - .../CMP0060/CMP0060-OLD-Build-stdout.txt | 1 - Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt | 10 ---- Tests/RunCMake/CMP0060/CMP0060-OLD.cmake | 2 - .../CMP0060/CMP0060-WARN-OFF-Build-result.txt | 1 - .../CMP0060/CMP0060-WARN-OFF-Build-stdout.txt | 1 - Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake | 1 - .../CMP0060/CMP0060-WARN-ON-Build-result.txt | 1 - .../CMP0060/CMP0060-WARN-ON-Build-stdout.txt | 1 - .../CMP0060/CMP0060-WARN-ON-stderr.txt | 16 ------ Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake | 2 - Tests/RunCMake/CMP0060/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0060/RunCMakeTest.cmake | 4 -- 21 files changed, 17 insertions(+), 111 deletions(-) delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-OLD.cmake delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt delete mode 100644 Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index 07ab0c4916..064e96f737 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -59,7 +59,8 @@ Each ```` may be: There are some cases where CMake may ask the linker to search for the library (e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``), such as when a shared library is detected to have no ``SONAME`` field. - See policy :policy:`CMP0060` for discussion of another case. + In CMake versions prior to 4.0, see policy :policy:`CMP0060` for + discussion of another case. If the library file is in a macOS framework, the ``Headers`` directory of the framework will also be processed as a diff --git a/Help/policy/CMP0060.rst b/Help/policy/CMP0060.rst index 8fff803031..078f22e056 100644 --- a/Help/policy/CMP0060.rst +++ b/Help/policy/CMP0060.rst @@ -1,6 +1,9 @@ CMP0060 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Link libraries by full path even in implicit directories. @@ -59,11 +62,9 @@ The ``NEW`` behavior for this policy is to link libraries by full path even if they are in implicit link directories. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default -.. include:: STANDARD_ADVICE.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: did *not* warn by default +.. include:: REMOVED_EPILOGUE.txt See documentation of the :variable:`CMAKE_POLICY_WARNING_CMP0060 >` -variable to control the warning. - -.. include:: DEPRECATED.txt +variable to control the warning in CMake versions before 4.0. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst index 7e008dfc2b..030fcfc299 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst @@ -31,9 +31,9 @@ Some toolchains read implicit directories from an environment variable such as consistent when operating in a given build tree because CMake saves the value detected when first creating a build tree. -If policy :policy:`CMP0060` is not set to ``NEW``, then when a library in one -of these directories is given by full path to :command:`target_link_libraries` -CMake will generate the ``-l`` form on link lines for historical -purposes. +In CMake versions prior to 4.0, if policy :policy:`CMP0060` is not set +to ``NEW``, then when a library in one of these directories is given by +full path to :command:`target_link_libraries` CMake will generate the +``-l`` form on link lines for historical purposes. See also the :variable:`CMAKE__IMPLICIT_LINK_LIBRARIES` variable. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 0ef81f1bb6..62cc543b67 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -12,8 +12,8 @@ only for the policies that do not warn by default: policy :policy:`CMP0047` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0056`` controlled the warning for policy :policy:`CMP0056` in CMake versions before 4.0. -* ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for - policy :policy:`CMP0060`. +* ``CMAKE_POLICY_WARNING_CMP0060`` controlled the warning for + policy :policy:`CMP0060` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for policy :policy:`CMP0065`. * ``CMAKE_POLICY_WARNING_CMP0066`` controls the warning for diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5e78a73dc1..fb22ce6741 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -24,7 +24,6 @@ #include "cmMessageType.h" #include "cmOrderDirectories.h" #include "cmPlaceholderExpander.h" -#include "cmPolicies.h" #include "cmSourceFile.h" #include "cmState.h" #include "cmStateTypes.h" @@ -421,9 +420,6 @@ cmComputeLinkInformation::cmComputeLinkInformation( this->OrderDependentRPath->SetImplicitDirectories(this->ImplicitLinkDirs); this->OrderDependentRPath->AddLanguageDirectories(this->RuntimeLinkDirs); } - - this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled( - "CMAKE_POLICY_WARNING_CMP0060"); } cmComputeLinkInformation::~cmComputeLinkInformation() = default; @@ -650,22 +646,6 @@ bool cmComputeLinkInformation::Compute() // Add implicit language runtime libraries and directories. this->AddImplicitLinkInfo(); - if (!this->CMP0060WarnItems.empty()) { - std::ostringstream w; - /* clang-format off */ - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0060) << "\n" - "Some library files are in directories implicitly searched by " - "the linker when invoked for " << this->LinkLanguage << ":\n" - " " << cmJoin(this->CMP0060WarnItems, "\n ") << "\n" - "For compatibility with older versions of CMake, the generated " - "link line will ask the linker to search for these by library " - "name." - ; - /* clang-format on */ - this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); - } - // Record targets referenced by $ sources. this->AddExternalObjectTargets(); @@ -1765,39 +1745,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(LinkEntry const& entry) return false; } - // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) { - case cmPolicies::WARN: - if (this->CMP0060Warn) { - // Print the warning at most once for this item. - std::string const& wid = - cmStrCat("CMP0060-WARNING-GIVEN-", item.Value); - if (!this->CMakeInstance->GetPropertyAsBool(wid)) { - this->CMakeInstance->SetProperty(wid, "1"); - this->CMP0060WarnItems.insert(item.Value); - } - } - CM_FALLTHROUGH; - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - return false; - } - - // Many system linkers support multiple architectures by - // automatically selecting the implicit linker search path for the - // current architecture. If the library appears in an implicit link - // directory then just report the file name without the directory - // portion. This will allow the system linker to locate the proper - // library for the architecture at link time. - LinkEntry fileEntry{ entry }; - fileEntry.Item = file; - this->AddUserItem(fileEntry); - - // Make sure the link directory ordering will find the library. - this->OrderLinkerSearchPath->AddLinkLibrary(item.Value); - - return true; + return false; } void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry) diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 98f6e7ebd7..23594b0269 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -239,7 +239,6 @@ private: // Additional paths configured by the runtime linker std::vector RuntimeLinkDirs; - std::set CMP0060WarnItems; // Dependent library path computation. std::unique_ptr OrderDependentRPath; // Runtime path computation. @@ -252,7 +251,6 @@ private: bool LinkWithRuntimePath; bool LinkTypeEnabled; bool ArchivesMayBeShared; - bool CMP0060Warn; void AddLibraryRuntimeInfo(std::string const& fullPath, const cmGeneratorTarget* target); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 041d67c17a..db658cb26d 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -177,7 +177,7 @@ class cmMakefile; 0, NEW) \ SELECT(POLICY, CMP0060, \ "Link libraries by full path even in implicit directories.", 3, 3, \ - 0, WARN) \ + 0, NEW) \ SELECT(POLICY, CMP0061, \ "CTest does not by default tell make to ignore errors (-i).", 3, 3, \ 0, WARN) \ diff --git a/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake b/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake index 0414e4b4b9..6b84565a2b 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake +++ b/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake @@ -1,2 +1 @@ -cmake_policy(SET CMP0060 NEW) include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt deleted file mode 100644 index d197c913c2..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt +++ /dev/null @@ -1 +0,0 @@ -[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt deleted file mode 100644 index 240764c10a..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt deleted file mode 100644 index 465874736c..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0060-OLD.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0060 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/CMP0060/CMP0060-OLD.cmake b/Tests/RunCMake/CMP0060/CMP0060-OLD.cmake deleted file mode 100644 index a9cffefbde..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-OLD.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(SET CMP0060 OLD) -include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt deleted file mode 100644 index d197c913c2..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt +++ /dev/null @@ -1 +0,0 @@ -[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt deleted file mode 100644 index 240764c10a..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake deleted file mode 100644 index 6b84565a2b..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake +++ /dev/null @@ -1 +0,0 @@ -include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt deleted file mode 100644 index d197c913c2..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt +++ /dev/null @@ -1 +0,0 @@ -[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt deleted file mode 100644 index 240764c10a..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt deleted file mode 100644 index 07c17e2469..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -^CMake Warning \(dev\) at CMP0060-Common.cmake:[0-9]+ \(add_executable\): - Policy CMP0060 is not set: Link libraries by full path even in implicit - directories. Run "cmake --help-policy CMP0060" for policy details. Use - the cmake_policy command to set the policy and suppress this warning. - - Some library files are in directories implicitly searched by the linker - when invoked for C: - - .*/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-build/lib/(lib)?CMP0060.(a|lib|l) - - For compatibility with older versions of CMake, the generated link line - will ask the linker to search for these by library name. -Call Stack \(most recent call first\): - CMP0060-WARN-ON.cmake:[0-9]+ \(include\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake deleted file mode 100644 index a0a7950ef0..0000000000 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(CMAKE_POLICY_WARNING_CMP0060 1) -include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMakeLists.txt b/Tests/RunCMake/CMP0060/CMakeLists.txt index db6b701c04..d1b0d2c3e8 100644 --- a/Tests/RunCMake/CMP0060/CMakeLists.txt +++ b/Tests/RunCMake/CMP0060/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0060/RunCMakeTest.cmake b/Tests/RunCMake/CMP0060/RunCMakeTest.cmake index b7eae5a46b..024f79cfb8 100644 --- a/Tests/RunCMake/CMP0060/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0060/RunCMakeTest.cmake @@ -1,5 +1,4 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) function(run_cmake_CMP0060 CASE) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0060-${CASE}-build) @@ -14,7 +13,4 @@ function(run_cmake_CMP0060 CASE) ) endfunction() -run_cmake_CMP0060(OLD) -run_cmake_CMP0060(WARN-OFF) -run_cmake_CMP0060(WARN-ON) run_cmake_CMP0060(NEW) From 789a7d73d4c5ff2780fe248158893f81555ff473 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Dec 2024 16:42:40 -0500 Subject: [PATCH 09/15] CMP0061: Remove support for OLD behavior --- Help/command/build_command.rst | 8 +++---- Help/policy/CMP0061.rst | 9 ++++---- Source/CTest/cmCTestBuildCommand.cxx | 2 +- Source/cmBuildCommand.cxx | 4 ++-- Source/cmMakefile.cxx | 16 -------------- Source/cmMakefile.h | 2 -- Source/cmPolicies.h | 2 +- .../RunCMake/build_command/CMP0061-NEW.cmake | 1 - .../build_command/CMP0061-OLD-make-stderr.txt | 21 ------------------- .../build_command/CMP0061-OLD-make.cmake | 2 -- .../CMP0061-OLD-other-stderr.txt | 21 ------------------- .../build_command/CMP0061-OLD-other.cmake | 2 -- .../RunCMake/build_command/RunCMakeTest.cmake | 5 ----- .../BuildFailure-CMP0061-OLD-result.txt | 1 - .../BuildFailure-CMP0061-OLD-stderr.txt | 10 --------- Tests/RunCMake/ctest_build/RunCMakeTest.cmake | 11 ---------- 16 files changed, 13 insertions(+), 104 deletions(-) delete mode 100644 Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt delete mode 100644 Tests/RunCMake/build_command/CMP0061-OLD-make.cmake delete mode 100644 Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt delete mode 100644 Tests/RunCMake/build_command/CMP0061-OLD-other.cmake delete mode 100644 Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-result.txt delete mode 100644 Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt diff --git a/Help/command/build_command.rst b/Help/command/build_command.rst index 3d86a2e032..21adab9473 100644 --- a/Help/command/build_command.rst +++ b/Help/command/build_command.rst @@ -15,14 +15,14 @@ This is mainly intended for internal use by the :module:`CTest` module. Sets the given ```` to a command-line string of the form:: - --build . [--config ] [--parallel ] [--target ...] [-- -i] + --build . [--config ] [--parallel ] [--target ...] where ```` is the location of the :manual:`cmake(1)` command-line tool, and ````, ```` and ```` are the values provided to the ``CONFIGURATION``, ``PARALLEL_LEVEL`` and ``TARGET`` -options, if any. The trailing ``-- -i`` option is added for -:ref:`Makefile Generators` if policy :policy:`CMP0061` is not set to -``NEW``. +options, if any. In CMake versions prior to 4.0, a trailing ``-- -i`` +option was added for :ref:`Makefile Generators` if policy :policy:`CMP0061` +was not set to ``NEW``. When invoked, this :option:`cmake --build` command line will launch the underlying build system tool. diff --git a/Help/policy/CMP0061.rst b/Help/policy/CMP0061.rst index 22ec0d0b78..765ecb7786 100644 --- a/Help/policy/CMP0061.rst +++ b/Help/policy/CMP0061.rst @@ -1,6 +1,9 @@ CMP0061 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 CTest does not by default tell ``make`` to ignore errors (``-i``). @@ -22,7 +25,5 @@ calls in CTest. The ``NEW`` behavior for this policy is to not add ``-i``. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: did *not* warn +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index b57c9030e7..c85188c8d6 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -93,7 +93,7 @@ std::unique_ptr cmCTestBuildCommand::InitializeHandler( std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand( cmakeBuildTarget, cmakeBuildConfiguration, args.ParallelLevel, - cmakeBuildAdditionalFlags, mf.IgnoreErrorsCMP0061()); + cmakeBuildAdditionalFlags, false); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand << "\n", args.Quiet); diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 415a124472..75595b8b11 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -84,7 +84,7 @@ bool MainSignature(std::vector const& args, } std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand( - target, configuration, parallel, "", mf.IgnoreErrorsCMP0061()); + target, configuration, parallel, "", false); mf.AddDefinition(variable, makecommand); @@ -111,7 +111,7 @@ bool TwoArgsSignature(std::vector const& args, } std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand( - "", configType, "", "", mf.IgnoreErrorsCMP0061()); + "", configType, "", "", false); if (cacheValue) { return true; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 630777933f..4a019abddf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4101,22 +4101,6 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) const } } -bool cmMakefile::IgnoreErrorsCMP0061() const -{ - bool ignoreErrors = true; - switch (this->GetPolicyStatus(cmPolicies::CMP0061)) { - case cmPolicies::WARN: - // No warning for this policy! - CM_FALLTHROUGH; - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - ignoreErrors = false; - break; - } - return ignoreErrors; -} - cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf, const std::string& fileName, cmPolicies::PolicyMap const& pm) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 74f988e8a1..ba2f2edfe4 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -417,8 +417,6 @@ public: cmMakefile* Makefile; }; - bool IgnoreErrorsCMP0061() const; - std::string const& GetHomeDirectory() const; std::string const& GetHomeOutputDirectory() const; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index db658cb26d..f234d1582f 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -180,7 +180,7 @@ class cmMakefile; 0, NEW) \ SELECT(POLICY, CMP0061, \ "CTest does not by default tell make to ignore errors (-i).", 3, 3, \ - 0, WARN) \ + 0, NEW) \ SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0, \ WARN) \ SELECT(POLICY, CMP0063, \ diff --git a/Tests/RunCMake/build_command/CMP0061-NEW.cmake b/Tests/RunCMake/build_command/CMP0061-NEW.cmake index 2e439cbbd3..e0b3bebf0d 100644 --- a/Tests/RunCMake/build_command/CMP0061-NEW.cmake +++ b/Tests/RunCMake/build_command/CMP0061-NEW.cmake @@ -1,2 +1 @@ -cmake_policy(SET CMP0061 NEW) include(CMP0061Common.cmake) diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt deleted file mode 100644 index 1938da37fd..0000000000 --- a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt +++ /dev/null @@ -1,21 +0,0 @@ -^CMake Deprecation Warning at CMP0061-OLD-make.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0061 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\) -+ -[^ -]+ --build \. --config "Release" -- -i -[^ -]+ --build \. --config "Release" --target "MyTarget" -- -i -[^ -]+ --build \. --config "Debug" -- -i -[^ -]+ --build \. --config "Debug" --target "MyTarget" -- -i -[^ -]+ --build \. --config "Release" -- -i$ diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-make.cmake b/Tests/RunCMake/build_command/CMP0061-OLD-make.cmake deleted file mode 100644 index 1542d8c16b..0000000000 --- a/Tests/RunCMake/build_command/CMP0061-OLD-make.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(SET CMP0061 OLD) -include(CMP0061Common.cmake) diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt deleted file mode 100644 index 85bbdf1751..0000000000 --- a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt +++ /dev/null @@ -1,21 +0,0 @@ -^CMake Deprecation Warning at CMP0061-OLD-other.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0061 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\) -+ -[^ -]+ --build \. --config "Release" -[^ -]+ --build \. --config "Release" --target "MyTarget" -[^ -]+ --build \. --config "Debug" -[^ -]+ --build \. --config "Debug" --target "MyTarget" -[^ -]+ --build \. --config "Release"$ diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-other.cmake b/Tests/RunCMake/build_command/CMP0061-OLD-other.cmake deleted file mode 100644 index 1542d8c16b..0000000000 --- a/Tests/RunCMake/build_command/CMP0061-OLD-other.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(SET CMP0061 OLD) -include(CMP0061Common.cmake) diff --git a/Tests/RunCMake/build_command/RunCMakeTest.cmake b/Tests/RunCMake/build_command/RunCMakeTest.cmake index 030db0b5c2..0e05bd9711 100644 --- a/Tests/RunCMake/build_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/build_command/RunCMakeTest.cmake @@ -9,10 +9,5 @@ run_cmake(BeforeProject) unset(RunCMake_TEST_OPTIONS) run_cmake(CMP0061-NEW) -if(RunCMake_GENERATOR MATCHES "Make") - run_cmake(CMP0061-OLD-make) -else() - run_cmake(CMP0061-OLD-other) -endif() run_cmake(ParallelLevel) diff --git a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-result.txt b/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-result.txt deleted file mode 100644 index 9cdf4a5ad1..0000000000 --- a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -(0|-1|255) diff --git a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt b/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt deleted file mode 100644 index 18710a30ba..0000000000 --- a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at [^ -]*/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD/test\.cmake:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -+(Error\(s\) when building project -)?ctest_build returned zero$ diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index af56ead3eb..f45a972351 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -33,17 +33,6 @@ else() endif() ]]) run_ctest(BuildFailure) - - if (RunCMake_GENERATOR MATCHES "Makefiles") - set(LANG NONE) - set(CASE_TEST_PREFIX_CODE [[ -cmake_policy(VERSION 3.2) -]]) - set(CASE_CMAKELISTS_SUFFIX_CODE [[ -add_custom_target(BuildFailure ALL COMMAND command-does-not-exist) -]]) - run_ctest(BuildFailure-CMP0061-OLD) - endif() endblock() function(run_BuildChangeId) From 36fffb673af2f8d4ed75e4d36c92c34e14723f67 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:33:30 -0500 Subject: [PATCH 10/15] CMP0062: Remove support for OLD behavior --- Help/policy/CMP0062.rst | 9 +++-- Source/cmInstallCommand.cxx | 40 ++++--------------- Source/cmPolicies.h | 2 +- Tests/RunCMake/install/CMP0062-NEW-stderr.txt | 1 - Tests/RunCMake/install/CMP0062-NEW.cmake | 3 -- Tests/RunCMake/install/CMP0062-OLD-result.txt | 1 - Tests/RunCMake/install/CMP0062-OLD-stderr.txt | 20 ---------- Tests/RunCMake/install/CMP0062-OLD.cmake | 6 --- .../RunCMake/install/CMP0062-WARN-result.txt | 1 - .../RunCMake/install/CMP0062-WARN-stderr.txt | 16 -------- Tests/RunCMake/install/CMP0062-WARN.cmake | 5 --- Tests/RunCMake/install/RunCMakeTest.cmake | 2 - 12 files changed, 14 insertions(+), 92 deletions(-) delete mode 100644 Tests/RunCMake/install/CMP0062-OLD-result.txt delete mode 100644 Tests/RunCMake/install/CMP0062-OLD-stderr.txt delete mode 100644 Tests/RunCMake/install/CMP0062-OLD.cmake delete mode 100644 Tests/RunCMake/install/CMP0062-WARN-result.txt delete mode 100644 Tests/RunCMake/install/CMP0062-WARN-stderr.txt delete mode 100644 Tests/RunCMake/install/CMP0062-WARN.cmake diff --git a/Help/policy/CMP0062.rst b/Help/policy/CMP0062.rst index e0cf71ba32..c785b466c3 100644 --- a/Help/policy/CMP0062.rst +++ b/Help/policy/CMP0062.rst @@ -1,6 +1,9 @@ CMP0062 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Disallow :command:`install` of :command:`export` result. @@ -24,7 +27,5 @@ an :command:`export()` command. The ``NEW`` behavior for this policy is not to allow installing the result of an :command:`export()` command. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 04634ab820..f747a7d56c 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1597,41 +1597,17 @@ bool HandleFilesMode(std::vector const& args, return false; } - cmPolicies::PolicyStatus policyStatus = - helper.Makefile->GetPolicyStatus(cmPolicies::CMP0062); - cmGlobalGenerator* gg = helper.Makefile->GetGlobalGenerator(); for (std::string const& file : filesVector) { if (gg->IsExportedTargetsFile(file)) { - const char* modal = nullptr; - std::ostringstream e; - MessageType messageType = MessageType::AUTHOR_WARNING; - - switch (policyStatus) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n"; - modal = "should"; - CM_FALLTHROUGH; - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - modal = "may"; - messageType = MessageType::FATAL_ERROR; - break; - } - if (modal) { - e << "The file\n " << file - << "\nwas generated by the export() " - "command. It " - << modal - << " not be installed with the " - "install() command. Use the install(EXPORT) mechanism " - "instead. See the cmake-packages(7) manual for more.\n"; - helper.Makefile->IssueMessage(messageType, e.str()); - if (messageType == MessageType::FATAL_ERROR) { - return false; - } - } + helper.Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("The file\n ", file, '\n', + "was generated by the export() command. " + "It may not be installed with the install() command. " + "Use the install(EXPORT) mechanism instead. " + "See the cmake-packages(7) manual for more.")); + return false; } } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f234d1582f..15d6449bca 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -182,7 +182,7 @@ class cmMakefile; "CTest does not by default tell make to ignore errors (-i).", 3, 3, \ 0, NEW) \ SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0063, \ "Honor visibility properties for all target types.", 3, 3, 0, WARN) \ SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, WARN) \ diff --git a/Tests/RunCMake/install/CMP0062-NEW-stderr.txt b/Tests/RunCMake/install/CMP0062-NEW-stderr.txt index b03f629e8f..570966faa1 100644 --- a/Tests/RunCMake/install/CMP0062-NEW-stderr.txt +++ b/Tests/RunCMake/install/CMP0062-NEW-stderr.txt @@ -6,6 +6,5 @@ CMake Error at CMP0062-NEW.cmake:[0-9]+ \(install\): was generated by the export\(\) command. It may not be installed with the install\(\) command. Use the install\(EXPORT\) mechanism instead. See the cmake-packages\(7\) manual for more. - Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/install/CMP0062-NEW.cmake b/Tests/RunCMake/install/CMP0062-NEW.cmake index 9e7a5fb82f..94e4d0b2ae 100644 --- a/Tests/RunCMake/install/CMP0062-NEW.cmake +++ b/Tests/RunCMake/install/CMP0062-NEW.cmake @@ -1,6 +1,3 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0062 NEW) - add_library(iface INTERFACE) export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/CMP0062-OLD-result.txt b/Tests/RunCMake/install/CMP0062-OLD-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt deleted file mode 100644 index 0a2981e941..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt +++ /dev/null @@ -1,20 +0,0 @@ -^CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -+ -CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0062 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/CMP0062-OLD.cmake b/Tests/RunCMake/install/CMP0062-OLD.cmake deleted file mode 100644 index 8874923b4c..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD.cmake +++ /dev/null @@ -1,6 +0,0 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0062 OLD) - -add_library(iface INTERFACE) -export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/CMP0062-WARN-result.txt b/Tests/RunCMake/install/CMP0062-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/install/CMP0062-WARN-stderr.txt b/Tests/RunCMake/install/CMP0062-WARN-stderr.txt deleted file mode 100644 index 12ae745733..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -CMake Warning \(dev\) at CMP0062-WARN.cmake:[0-9]+ \(install\): - Policy CMP0062 is not set: Disallow install\(\) of export\(\) result. Run - "cmake --help-policy CMP0062" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. - - The file - - .*Tests/RunCMake/install/CMP0062-WARN-build/exported.cmake - - was generated by the export\(\) command. It should not be installed with the - install\(\) command. Use the install\(EXPORT\) mechanism instead. See the - cmake-packages\(7\) manual for more. - -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/install/CMP0062-WARN.cmake b/Tests/RunCMake/install/CMP0062-WARN.cmake deleted file mode 100644 index 018f82275a..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN.cmake +++ /dev/null @@ -1,5 +0,0 @@ -cmake_policy(VERSION 3.2) - -add_library(iface INTERFACE) -export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 39c3373dd4..3a121c0b0e 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -88,9 +88,7 @@ run_cmake(EXPORT-NamelinkOnly) run_cmake(EXPORT-SeparateNamelink) run_cmake(EXPORT-TargetTwice) run_cmake(EXPORT-InterfaceLinkNoexist) -run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) -run_cmake(CMP0062-WARN) run_cmake(CMP0087-OLD) run_cmake(CMP0087-NEW) run_cmake(CMP0087-WARN) From ac1a9cb1608e1a4fad97595e7e149b09ab1aaa3d Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:40:21 -0500 Subject: [PATCH 11/15] CMP0063: Remove support for OLD behavior --- Help/policy/CMP0063.rst | 9 ++-- Help/prop_tgt/LANG_VISIBILITY_PRESET.rst | 4 +- Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst | 2 +- Source/cmLocalGenerator.cxx | 47 ++----------------- Source/cmLocalGenerator.h | 1 - Source/cmPolicies.h | 2 +- .../VisibilityPreset/CMP0063-NEW.cmake | 1 - .../VisibilityPreset/CMP0063-OLD-stderr.txt | 18 ------- .../VisibilityPreset/CMP0063-OLD.cmake | 8 ---- .../CMP0063-WARN-exe-stderr.txt | 23 --------- .../VisibilityPreset/CMP0063-WARN-exe.cmake | 11 ----- .../CMP0063-WARN-no-stderr.txt | 7 --- .../VisibilityPreset/CMP0063-WARN-no.cmake | 8 ---- .../CMP0063-WARN-obj-stderr.txt | 23 --------- .../VisibilityPreset/CMP0063-WARN-obj.cmake | 11 ----- .../CMP0063-WARN-sta-stderr.txt | 23 --------- .../VisibilityPreset/CMP0063-WARN-sta.cmake | 11 ----- .../RunCMake/VisibilityPreset/CMakeLists.txt | 3 -- .../VisibilityPreset/RunCMakeTest.cmake | 6 --- Tests/Visibility/CMakeLists.txt | 2 - 20 files changed, 12 insertions(+), 208 deletions(-) delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-OLD.cmake delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no.cmake delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt delete mode 100644 Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake diff --git a/Help/policy/CMP0063.rst b/Help/policy/CMP0063.rst index 1e1cbfaf33..1f00c20ee8 100644 --- a/Help/policy/CMP0063.rst +++ b/Help/policy/CMP0063.rst @@ -1,6 +1,9 @@ CMP0063 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Honor visibility properties for all target types. @@ -23,7 +26,5 @@ The ``NEW`` behavior for this policy is to honor the visibility properties for all target types. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Help/prop_tgt/LANG_VISIBILITY_PRESET.rst b/Help/prop_tgt/LANG_VISIBILITY_PRESET.rst index 5d34e207ef..638f753a3c 100644 --- a/Help/prop_tgt/LANG_VISIBILITY_PRESET.rst +++ b/Help/prop_tgt/LANG_VISIBILITY_PRESET.rst @@ -5,8 +5,8 @@ Value for symbol visibility compile flags The ``_VISIBILITY_PRESET`` property determines the value passed in a visibility related compile option, such as ``-fvisibility=`` for ````. -This property affects compilation in sources of all types of targets -(subject to policy :policy:`CMP0063`). +This property affects compilation in sources of all types of targets. +See policy :policy:`CMP0063`. This property is initialized by the value of the :variable:`CMAKE__VISIBILITY_PRESET` variable if it is set when a diff --git a/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst b/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst index adbbc7103f..4846139eb5 100644 --- a/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst +++ b/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst @@ -6,7 +6,7 @@ Whether to add a compile flag to hide symbols of inline functions The ``VISIBILITY_INLINES_HIDDEN`` property determines whether a flag for hiding symbols for inline functions, such as ``-fvisibility-inlines-hidden``, should be used when invoking the compiler. This property affects compilation -in sources of all types of targets (subject to policy :policy:`CMP0063`). +in sources of all types of targets. See policy :policy:`CMP0063`. This property is initialized by the value of the :variable:`CMAKE_VISIBILITY_INLINES_HIDDEN` variable if it diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 861210c4d5..5442f395a7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2426,8 +2426,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, static void AddVisibilityCompileOption(std::string& flags, cmGeneratorTarget const* target, cmLocalGenerator* lg, - const std::string& lang, - std::string* warnCMP0063) + const std::string& lang) { std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY"; cmValue opt = lg->GetMakefile()->GetDefinition(compileOption); @@ -2440,10 +2439,6 @@ static void AddVisibilityCompileOption(std::string& flags, if (!prop) { return; } - if (warnCMP0063) { - *warnCMP0063 += " " + flagDefine + "\n"; - return; - } if ((*prop != "hidden") && (*prop != "default") && (*prop != "protected") && (*prop != "internal")) { std::ostringstream e; @@ -2461,7 +2456,6 @@ static void AddVisibilityCompileOption(std::string& flags, static void AddInlineVisibilityCompileOption(std::string& flags, cmGeneratorTarget const* target, cmLocalGenerator* lg, - std::string* warnCMP0063, const std::string& lang) { std::string compileOption = @@ -2475,10 +2469,6 @@ static void AddInlineVisibilityCompileOption(std::string& flags, if (!prop) { return; } - if (warnCMP0063) { - *warnCMP0063 += " VISIBILITY_INLINES_HIDDEN\n"; - return; - } lg->AppendFlags(flags, *opt); } @@ -2489,41 +2479,10 @@ void cmLocalGenerator::AddVisibilityPresetFlags( return; } - std::string warnCMP0063; - std::string* pWarnCMP0063 = nullptr; - if (target->GetType() != cmStateEnums::SHARED_LIBRARY && - target->GetType() != cmStateEnums::MODULE_LIBRARY && - !target->IsExecutableWithExports()) { - switch (target->GetPolicyStatusCMP0063()) { - case cmPolicies::OLD: - return; - case cmPolicies::WARN: - pWarnCMP0063 = &warnCMP0063; - break; - default: - break; - } - } - - AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063); + AddVisibilityCompileOption(flags, target, this, lang); if (lang == "CXX" || lang == "OBJCXX") { - AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063, lang); - } - - if (!warnCMP0063.empty() && this->WarnCMP0063.insert(target).second) { - std::ostringstream w; - /* clang-format off */ - w << - cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n" - "Target \"" << target->GetName() << "\" of " - "type \"" << cmState::GetTargetTypeName(target->GetType()) << "\" " - "has the following visibility properties set for " << lang << ":\n" << - warnCMP0063 << - "For compatibility CMake is not honoring them for this target."; - /* clang-format on */ - target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage( - MessageType::AUTHOR_WARNING, w.str(), target->GetBacktrace()); + AddInlineVisibilityCompileOption(flags, target, this, lang); } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3382675775..afd2da8645 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -585,7 +585,6 @@ protected: GeneratorTargetMap GeneratorTargetSearchIndex; GeneratorTargetVector GeneratorTargets; - std::set WarnCMP0063; GeneratorTargetMap ImportedGeneratorTargets; GeneratorTargetVector OwnedImportedGeneratorTargets; std::map AliasTargets; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 15d6449bca..791073afb8 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -184,7 +184,7 @@ class cmMakefile; SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0, \ NEW) \ SELECT(POLICY, CMP0063, \ - "Honor visibility properties for all target types.", 3, 3, 0, WARN) \ + "Honor visibility properties for all target types.", 3, 3, 0, NEW) \ SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, WARN) \ SELECT(POLICY, CMP0065, \ "Do not add flags to export symbols from executables without " \ diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-NEW.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-NEW.cmake index 9d1ee40740..48f232dbdb 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-NEW.cmake +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-NEW.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0063 NEW) enable_language(CXX) # Ensure CMake would warn even if toolchain does not really have these flags. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt deleted file mode 100644 index 7837d23df2..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt +++ /dev/null @@ -1,18 +0,0 @@ -^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -+ -CMake Deprecation Warning at CMP0063-OLD.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0063 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/VisibilityPreset/CMP0063-OLD.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD.cmake deleted file mode 100644 index 8378209c97..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD.cmake +++ /dev/null @@ -1,8 +0,0 @@ -cmake_policy(SET CMP0063 OLD) -enable_language(CXX) - -# Ensure CMake would warn even if toolchain does not really have these flags. -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") - -include(CMP0063-Common.cmake) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt deleted file mode 100644 index dc45d508d8..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt +++ /dev/null @@ -1,23 +0,0 @@ -^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -+ -CMake Warning \(dev\) at CMP0063-WARN-exe.cmake:[0-9]+ \(add_executable\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "myexe" of type "EXECUTABLE" has the following visibility properties - set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake deleted file mode 100644 index cef1d75219..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -enable_language(CXX) - -# Ensure CMake warns even if toolchain does not really have these flags. -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") - -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) - -add_executable(myexe lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt deleted file mode 100644 index c59fe7bac5..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt +++ /dev/null @@ -1,7 +0,0 @@ -^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\.$ diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no.cmake deleted file mode 100644 index 2a9c9e543d..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -enable_language(CXX) - -# Ensure CMake does not warn even if toolchain really does have these flags. -unset(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN) -unset(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY) - -include(CMP0063-Common.cmake) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt deleted file mode 100644 index 96bd79275d..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt +++ /dev/null @@ -1,23 +0,0 @@ -^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -+ -CMake Warning \(dev\) at CMP0063-WARN-obj.cmake:[0-9]+ \(add_library\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "myobject" of type "OBJECT_LIBRARY" has the following visibility - properties set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake deleted file mode 100644 index 81d1c339bd..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -enable_language(CXX) - -# Ensure CMake warns even if toolchain does not really have these flags. -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") - -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) - -add_library(myobject OBJECT lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt deleted file mode 100644 index b945e309ea..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt +++ /dev/null @@ -1,23 +0,0 @@ -^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -+ -CMake Warning \(dev\) at CMP0063-WARN-sta.cmake:[0-9]+ \(add_library\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "mystatic" of type "STATIC_LIBRARY" has the following visibility - properties set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake deleted file mode 100644 index 132e076e27..0000000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -enable_language(CXX) - -# Ensure CMake warns even if toolchain does not really have these flags. -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") -set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") - -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) - -add_library(mystatic STATIC lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMakeLists.txt b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt index 69e023688a..bf2ef1506e 100644 --- a/Tests/RunCMake/VisibilityPreset/CMakeLists.txt +++ b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt @@ -1,6 +1,3 @@ cmake_minimum_required(VERSION 3.10) -if(RunCMake_TEST MATCHES "CMP0063-(OLD|WARN)") - cmake_policy(VERSION 3.2) # old enough to not set CMP0063 -endif() project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake index 133dbe1641..6b5541a3aa 100644 --- a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake +++ b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake @@ -1,10 +1,4 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) run_cmake(PropertyTypo) -run_cmake(CMP0063-OLD) -run_cmake(CMP0063-WARN-exe) -run_cmake(CMP0063-WARN-obj) -run_cmake(CMP0063-WARN-sta) -run_cmake(CMP0063-WARN-no) run_cmake(CMP0063-NEW) diff --git a/Tests/Visibility/CMakeLists.txt b/Tests/Visibility/CMakeLists.txt index 66f781cd52..efbe9fc9d3 100644 --- a/Tests/Visibility/CMakeLists.txt +++ b/Tests/Visibility/CMakeLists.txt @@ -1,6 +1,4 @@ cmake_minimum_required(VERSION 3.10) -cmake_policy(SET CMP0063 NEW) - project(Visibility) add_library(hidden1 SHARED hidden.c) From d88047c329aa0d3a4272c1e6d16e2781b4f6bf16 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:49:15 -0500 Subject: [PATCH 12/15] Remove compatibility with CMake versions older than 3.3 This compatibility has been deprecated since commit 3a4791548d (Deprecate compatibility with CMake versions older than 3.5, 2023-02-09, v3.27.0-rc1~508^2). The behavior itself has been deprecated since CMake 3.3. Issue: #26613 --- Help/command/DEPRECATED_POLICY_VERSIONS.txt | 4 ++-- Help/release/dev/remove-old-compatibility.rst | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmPolicies.cxx | 6 +++--- .../cmake_minimum_required/BeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/BeforeVersionRemoved.cmake | 2 +- .../PolicyBeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/PolicyBeforeVersionRemoved.cmake | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Help/command/DEPRECATED_POLICY_VERSIONS.txt b/Help/command/DEPRECATED_POLICY_VERSIONS.txt index e34e72ec33..effb09bf09 100644 --- a/Help/command/DEPRECATED_POLICY_VERSIONS.txt +++ b/Help/command/DEPRECATED_POLICY_VERSIONS.txt @@ -1,9 +1,9 @@ .. versionchanged:: 4.0 - Compatibility with versions of CMake older than 3.2 is removed. + Compatibility with versions of CMake older than 3.3 is removed. Calls to :command:`cmake_minimum_required(VERSION)` or :command:`cmake_policy(VERSION)` that do not specify at least - 3.2 as their policy version (optionally via ``...``) + 3.3 as their policy version (optionally via ``...``) will produce an error in CMake 4.0 and above. .. versionchanged:: 3.31 diff --git a/Help/release/dev/remove-old-compatibility.rst b/Help/release/dev/remove-old-compatibility.rst index 8d74e6702c..01cccd63c9 100644 --- a/Help/release/dev/remove-old-compatibility.rst +++ b/Help/release/dev/remove-old-compatibility.rst @@ -1,7 +1,7 @@ remove-old-compatibility ------------------------ -* Compatibility with versions of CMake older than 3.2 has been removed. +* Compatibility with versions of CMake older than 3.3 has been removed. Calls to :command:`cmake_minimum_required` or :command:`cmake_policy` that set the policy version to an older value now issue an error. Note that calls to those commands can still support older versions of diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4a019abddf..bcb44d0e57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1593,7 +1593,7 @@ void cmMakefile::Configure() this->SetCheckCMP0000(true); // Implicitly set the version for the user. - cmPolicies::ApplyPolicyVersion(this, 3, 2, 0, + cmPolicies::ApplyPolicyVersion(this, 3, 3, 0, cmPolicies::WarnCompat::Off); } } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 7c697b07d1..ba316ff9a1 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -295,16 +295,16 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, WarnCompat warnCompat) { // Error on policy versions for which support has been removed. - if (majorVer < 3 || (majorVer == 3 && minorVer < 2)) { + if (majorVer < 3 || (majorVer == 3 && minorVer < 3)) { if (IsFromLegacyInstallEXPORT(mf, majorVer, minorVer, patchVer)) { // Silently tolerate cmake_policy calls generated by install(EXPORT) // in CMake versions prior to 3.18. majorVer = 3; - minorVer = 2; + minorVer = 3; patchVer = 0; } else { mf->IssueMessage(MessageType::FATAL_ERROR, - "Compatibility with CMake < 3.2 has been removed " + "Compatibility with CMake < 3.3 has been removed " "from CMake.\n" ADVICE_UPDATE_VERSION_ARGUMENT); cmSystemTools::SetFatalErrorOccurred(); return false; diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt index 07c84e71ab..f51dca9d21 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at BeforeVersionRemoved\.cmake:1 \(cmake_minimum_required\): - Compatibility with CMake < 3\.2 has been removed from CMake\. + Compatibility with CMake < 3\.3 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake index c1fcf45cd7..319b1d9f2b 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.2) diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt index 9c14473a77..9f31b80282 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at PolicyBeforeVersionRemoved\.cmake:1 \(cmake_policy\): - Compatibility with CMake < 3\.2 has been removed from CMake\. + Compatibility with CMake < 3\.3 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake index 17e8290cef..33bafe83f5 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_policy(VERSION 3.1) +cmake_policy(VERSION 3.2) From d9dd38cccfc674f764aba42dde74b86b5f819837 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:50:18 -0500 Subject: [PATCH 13/15] CMP0064: Remove support for OLD behavior --- Help/policy/CMP0064.rst | 9 ++++--- Source/cmConditionEvaluator.cxx | 25 ------------------- Source/cmConditionEvaluator.h | 1 - Source/cmPolicies.h | 2 +- Tests/RunCMake/CMP0064/CMP0064-NEW.cmake | 2 -- Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt | 10 -------- Tests/RunCMake/CMP0064/CMP0064-OLD.cmake | 7 ------ .../RunCMake/CMP0064/CMP0064-WARN-stderr.txt | 10 -------- Tests/RunCMake/CMP0064/CMP0064-WARN.cmake | 7 ------ Tests/RunCMake/CMP0064/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0064/RunCMakeTest.cmake | 3 --- .../if/TestNameThatDoesNotExist.cmake | 1 - Tests/RunCMake/if/TestNameThatExists.cmake | 1 - 13 files changed, 7 insertions(+), 73 deletions(-) delete mode 100644 Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt delete mode 100644 Tests/RunCMake/CMP0064/CMP0064-OLD.cmake delete mode 100644 Tests/RunCMake/CMP0064/CMP0064-WARN-stderr.txt delete mode 100644 Tests/RunCMake/CMP0064/CMP0064-WARN.cmake diff --git a/Help/policy/CMP0064.rst b/Help/policy/CMP0064.rst index 4fd873f392..fca428b253 100644 --- a/Help/policy/CMP0064.rst +++ b/Help/policy/CMP0064.rst @@ -1,6 +1,9 @@ CMP0064 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.4 Recognize ``TEST`` as a operator for the :command:`if` command. @@ -12,7 +15,5 @@ The ``OLD`` behavior for this policy is to ignore the ``TEST`` operator. The ``NEW`` behavior is to interpret the ``TEST`` operator. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.4 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 555aeedb82..a9c6a86a60 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -218,7 +218,6 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt) : Makefile(makefile) , Backtrace(std::move(bt)) - , Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064)) , Policy139Status(makefile.GetPolicyStatus(cmPolicies::CMP0139)) { } @@ -426,26 +425,6 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, { for (auto args = newArgs.make2ArgsIterator(); args.current != newArgs.end(); args.advance(newArgs)) { - - auto policyCheck = [&, this](const cmPolicies::PolicyID id, - const cmPolicies::PolicyStatus status, - const cm::static_string_view kw) { - if (status == cmPolicies::WARN && this->IsKeyword(kw, *args.current)) { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(id) << "\n" - << kw - << " will be interpreted as an operator " - "when the policy is set to NEW. " - "Since the policy is not set the OLD behavior will be used."; - - this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - } - }; - - // NOTE Checking policies for warnings are not require an access to the - // next arg. Check them first! - policyCheck(cmPolicies::CMP0064, this->Policy64Status, keyTEST); - // NOTE Fail fast: All the predicates below require the next arg to be // valid if (args.next == newArgs.end()) { @@ -533,10 +512,6 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, } // does a test exist else if (this->IsKeyword(keyTEST, *args.current)) { - if (this->Policy64Status == cmPolicies::OLD || - this->Policy64Status == cmPolicies::WARN) { - continue; - } newArgs.ReduceOneArg( static_cast(this->Makefile.GetTest(args.next->GetValue())), args); diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index bd1edc5930..fe2063554c 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -66,6 +66,5 @@ private: cmMakefile& Makefile; cmListFileBacktrace Backtrace; - cmPolicies::PolicyStatus Policy64Status; cmPolicies::PolicyStatus Policy139Status; }; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 791073afb8..33e5db9639 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -185,7 +185,7 @@ class cmMakefile; NEW) \ SELECT(POLICY, CMP0063, \ "Honor visibility properties for all target types.", 3, 3, 0, NEW) \ - SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, WARN) \ + SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, NEW) \ SELECT(POLICY, CMP0065, \ "Do not add flags to export symbols from executables without " \ "the ENABLE_EXPORTS target property.", \ diff --git a/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake index cdf50e9cab..4657471e8b 100644 --- a/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake +++ b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0064 NEW) - if(NOT TEST TestThatDoesNotExist) message(STATUS "if NOT TestThatDoesNotExist is true") endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt b/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt deleted file mode 100644 index 987a50309e..0000000000 --- a/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0064-OLD.cmake:1 \(cmake_policy\): - The OLD behavior for policy CMP0064 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:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake b/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake deleted file mode 100644 index bffd3f3620..0000000000 --- a/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake +++ /dev/null @@ -1,7 +0,0 @@ -cmake_policy(SET CMP0064 OLD) - -if(TEST) - message(FATAL_ERROR "TEST was not recognized to be undefined") -else() - message(STATUS "TEST was treated as a variable") -endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-WARN-stderr.txt b/Tests/RunCMake/CMP0064/CMP0064-WARN-stderr.txt deleted file mode 100644 index 71f1ab7722..0000000000 --- a/Tests/RunCMake/CMP0064/CMP0064-WARN-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -CMake Warning \(dev\) at CMP0064-WARN.cmake:3 \(if\): - Policy CMP0064 is not set: Support new TEST if\(\) operator. Run "cmake - --help-policy CMP0064" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - TEST will be interpreted as an operator when the policy is set to NEW. - Since the policy is not set the OLD behavior will be used. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake b/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake deleted file mode 100644 index 8f26ec62b5..0000000000 --- a/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake +++ /dev/null @@ -1,7 +0,0 @@ - - -if(TEST) - message(FATAL_ERROR "TEST was not recognized to be undefined") -else() - message(STATUS "TEST was treated as a variable") -endif() diff --git a/Tests/RunCMake/CMP0064/CMakeLists.txt b/Tests/RunCMake/CMP0064/CMakeLists.txt index 74b3ff8de3..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0064/CMakeLists.txt +++ b/Tests/RunCMake/CMP0064/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0064/RunCMakeTest.cmake b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake index 4c68510eee..82de3689ec 100644 --- a/Tests/RunCMake/CMP0064/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake @@ -1,6 +1,3 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0064-OLD) -run_cmake(CMP0064-WARN) run_cmake(CMP0064-NEW) diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake index 74bc8b02fb..68ad6e3f43 100644 --- a/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0064 NEW) if(TEST TestThatDoesNotExist) message(FATAL_ERROR "if TestThatDoesNotExist is true") else() diff --git a/Tests/RunCMake/if/TestNameThatExists.cmake b/Tests/RunCMake/if/TestNameThatExists.cmake index 65c2b462c1..e03e1488cc 100644 --- a/Tests/RunCMake/if/TestNameThatExists.cmake +++ b/Tests/RunCMake/if/TestNameThatExists.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0064 NEW) add_test(NAME TestThatExists COMMAND ${CMAKE_COMMAND} -E echo "A CMake Test") if(TEST TestThatExists) message(STATUS "if TestThatExists is true") From fb1bd1d33023af5a0a2246fafb5ee4f4527b6892 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:56:18 -0500 Subject: [PATCH 14/15] CMP0065: Remove support for OLD behavior --- Help/command/try_compile.rst | 2 +- Help/policy/CMP0065.rst | 11 +++-- .../variable/CMAKE_POLICY_WARNING_CMPNNNN.rst | 4 +- Modules/Platform/AIX-GNU.cmake | 2 +- Modules/Platform/AIX-XL.cmake | 2 +- Source/cmCoreTryCompile.cxx | 7 --- Source/cmLocalGenerator.cxx | 46 ++++--------------- Source/cmLocalGenerator.h | 4 +- Source/cmMakefile.cxx | 8 ++-- .../cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmPolicies.h | 2 +- Tests/RunCMake/CMP0065/CMakeLists.txt | 2 +- Tests/RunCMake/CMP0065/OLDBad1.cmake | 4 -- Tests/RunCMake/CMP0065/OLDBad2.cmake | 4 -- Tests/RunCMake/CMP0065/RunCMakeTest.cmake | 5 -- Tests/RunCMake/CMP0065/WARN-OFF.cmake | 3 -- Tests/RunCMake/CMP0065/WARN-ON-stderr.txt | 10 ---- Tests/RunCMake/CMP0065/WARN-ON.cmake | 3 -- .../CMP0065/subproject/CMakeLists.txt | 16 +------ 19 files changed, 30 insertions(+), 107 deletions(-) delete mode 100644 Tests/RunCMake/CMP0065/OLDBad1.cmake delete mode 100644 Tests/RunCMake/CMP0065/OLDBad2.cmake delete mode 100644 Tests/RunCMake/CMP0065/WARN-OFF.cmake delete mode 100644 Tests/RunCMake/CMP0065/WARN-ON-stderr.txt delete mode 100644 Tests/RunCMake/CMP0065/WARN-ON.cmake diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 33d710e4a3..4da0d1481a 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -337,7 +337,7 @@ Other Behavior Settings Some policies are set automatically in the generated test project as needed to honor the state of the calling project: -* :policy:`CMP0065` +* :policy:`CMP0065` (in CMake versions prior to 4.0) * :policy:`CMP0083` * :policy:`CMP0091` * :policy:`CMP0104` diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst index 54034b165c..7d70899e1a 100644 --- a/Help/policy/CMP0065.rst +++ b/Help/policy/CMP0065.rst @@ -1,6 +1,9 @@ CMP0065 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.4 Do not add flags to export symbols from executables without @@ -21,11 +24,9 @@ flags when linking executables if the :prop_tgt:`ENABLE_EXPORTS` target property is set to ``True``. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.4 -.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default -.. include:: STANDARD_ADVICE.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: did *not* warn by default +.. include:: REMOVED_EPILOGUE.txt See documentation of the :variable:`CMAKE_POLICY_WARNING_CMP0065 >` -variable to control the warning. - -.. include:: DEPRECATED.txt +variable to control the warning in CMake versions before 4.0. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 62cc543b67..3a9605fb92 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -14,8 +14,8 @@ only for the policies that do not warn by default: policy :policy:`CMP0056` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0060`` controlled the warning for policy :policy:`CMP0060` in CMake versions before 4.0. -* ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for - policy :policy:`CMP0065`. +* ``CMAKE_POLICY_WARNING_CMP0065`` controlled the warning for + policy :policy:`CMP0065` in CMake versions before 4.0. * ``CMAKE_POLICY_WARNING_CMP0066`` controls the warning for policy :policy:`CMP0066`. * ``CMAKE_POLICY_WARNING_CMP0067`` controls the warning for diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index c9f01a6b48..459bc04820 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -12,7 +12,7 @@ macro(__aix_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath") - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) set(CMAKE_${lang}_VERBOSE_LINK_FLAG "-Wl,-v") diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index f7cab254e6..59eb2034a7 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -12,7 +12,7 @@ macro(__aix_compiler_xl lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath") - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ") set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ") diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 32df7812e9..fdebc4bc7d 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -847,13 +847,6 @@ cm::optional cmCoreTryCompile::TryCompileCode( fprintf(fout, "\n"); } - /* Set the appropriate policy information for ENABLE_EXPORTS */ - fprintf(fout, "cmake_policy(SET CMP0065 %s)\n", - this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) == - cmPolicies::NEW - ? "NEW" - : "OLD"); - /* Set the appropriate policy information for PIE link flags */ fprintf(fout, "cmake_policy(SET CMP0083 %s)\n", this->Makefile->GetPolicyStatus(cmPolicies::CMP0083) == diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5442f395a7..a8aa5cd972 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1629,10 +1629,10 @@ void cmLocalGenerator::GetTargetFlags( exeFlags += " "; } - std::string cmp0065Flags = - this->GetLinkLibsCMP0065(linkLanguage, *target); - if (!cmp0065Flags.empty()) { - exeFlags += cmp0065Flags; + std::string exeExportFlags = + this->GetExeExportFlags(linkLanguage, *target); + if (!exeExportFlags.empty()) { + exeFlags += exeExportFlags; exeFlags += " "; } @@ -1959,46 +1959,18 @@ void cmLocalGenerator::OutputLinkLibraries( linkLineComputer->ComputeLinkLibraries(cli, stdLibString, linkLibraries); } -std::string cmLocalGenerator::GetLinkLibsCMP0065( +std::string cmLocalGenerator::GetExeExportFlags( std::string const& linkLanguage, cmGeneratorTarget& tgt) const { std::string linkFlags; - // Flags to link an executable to shared libraries. + // Flags to export symbols from an executable. if (tgt.GetType() == cmStateEnums::EXECUTABLE && this->StateSnapshot.GetState()->GetGlobalPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS")) { - bool add_shlib_flags = false; - switch (tgt.GetPolicyStatusCMP0065()) { - case cmPolicies::WARN: - if (!tgt.GetPropertyAsBool("ENABLE_EXPORTS") && - this->Makefile->PolicyOptionalWarningEnabled( - "CMAKE_POLICY_WARNING_CMP0065")) { - std::ostringstream w; - /* clang-format off */ - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" - "For compatibility with older versions of CMake, " - "additional flags may be added to export symbols on all " - "executables regardless of their ENABLE_EXPORTS property."; - /* clang-format on */ - this->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); - } - CM_FALLTHROUGH; - case cmPolicies::OLD: - // OLD behavior is to always add the flags, except on AIX where - // we compute symbol exports if ENABLE_EXPORTS is on. - add_shlib_flags = - !(tgt.IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS")); - break; - case cmPolicies::NEW: - // NEW behavior is to only add the flags if ENABLE_EXPORTS is on, - // except on AIX where we compute symbol exports. - add_shlib_flags = - !tgt.IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS"); - break; - } - - if (add_shlib_flags) { + // Only add the flags if ENABLE_EXPORTS is on, + // except on AIX where we compute symbol exports. + if (!tgt.IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS")) { linkFlags = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_SHARED_LIBRARY_LINK_", linkLanguage, "_FLAGS")); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index afd2da8645..ff0429e636 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -123,8 +123,8 @@ public: cmGeneratorTarget const* target, std::string const& language); - std::string GetLinkLibsCMP0065(std::string const& linkLanguage, - cmGeneratorTarget& tgt) const; + std::string GetExeExportFlags(std::string const& linkLanguage, + cmGeneratorTarget& tgt) const; cmState* GetState() const; cmStateSnapshot GetStateSnapshot() const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bcb44d0e57..535b62fb1f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4015,10 +4015,10 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, !(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::CMP0136)) && + id == cmPolicies::CMP0083 || id == cmPolicies::CMP0091 || + id == cmPolicies::CMP0104 || id == cmPolicies::CMP0123 || + id == cmPolicies::CMP0126 || id == cmPolicies::CMP0128 || + id == cmPolicies::CMP0136)) && (!this->IsSet("CMAKE_WARN_DEPRECATED") || this->IsOn("CMAKE_WARN_DEPRECATED"))) { this->IssueMessage(MessageType::DEPRECATION_WARNING, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 3dacc62305..9fccbd1395 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -397,7 +397,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } this->LocalGenerator->AppendFlags(linkFlags, - this->LocalGenerator->GetLinkLibsCMP0065( + this->LocalGenerator->GetExeExportFlags( linkLanguage, *this->GeneratorTarget)); this->UseLWYU = this->LocalGenerator->AppendLWYUFlags( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 33e5db9639..9496fd92c2 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -189,7 +189,7 @@ class cmMakefile; SELECT(POLICY, CMP0065, \ "Do not add flags to export symbols from executables without " \ "the ENABLE_EXPORTS target property.", \ - 3, 4, 0, WARN) \ + 3, 4, 0, NEW) \ SELECT(POLICY, CMP0066, \ "Honor per-config flags in try_compile() source-file signature.", 3, \ 7, 0, WARN) \ diff --git a/Tests/RunCMake/CMP0065/CMakeLists.txt b/Tests/RunCMake/CMP0065/CMakeLists.txt index 74b3ff8de3..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0065/CMakeLists.txt +++ b/Tests/RunCMake/CMP0065/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0065/OLDBad1.cmake b/Tests/RunCMake/CMP0065/OLDBad1.cmake deleted file mode 100644 index 6d780b4a2f..0000000000 --- a/Tests/RunCMake/CMP0065/OLDBad1.cmake +++ /dev/null @@ -1,4 +0,0 @@ -enable_language(C) -include(BuildTargetInSubProject.cmake) - -BuildTargetInSubProject(TestPolicyCMP0065 FooOLDBad1 FALSE) diff --git a/Tests/RunCMake/CMP0065/OLDBad2.cmake b/Tests/RunCMake/CMP0065/OLDBad2.cmake deleted file mode 100644 index 7196473e18..0000000000 --- a/Tests/RunCMake/CMP0065/OLDBad2.cmake +++ /dev/null @@ -1,4 +0,0 @@ -enable_language(C) -include(BuildTargetInSubProject.cmake) - -BuildTargetInSubProject(TestPolicyCMP0065 FooOLDBad2 FALSE) diff --git a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake index 1ca4605a7e..54df5e34e0 100644 --- a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake @@ -1,12 +1,7 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(OLDBad1) if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX") # Tests with ENABLE_EXPORTS ON. For AIX we do not use the flags at all. - run_cmake(OLDBad2) run_cmake(NEWBad) endif() run_cmake(NEWGood) -run_cmake(WARN-OFF) -run_cmake(WARN-ON) diff --git a/Tests/RunCMake/CMP0065/WARN-OFF.cmake b/Tests/RunCMake/CMP0065/WARN-OFF.cmake deleted file mode 100644 index dbc9562373..0000000000 --- a/Tests/RunCMake/CMP0065/WARN-OFF.cmake +++ /dev/null @@ -1,3 +0,0 @@ - -enable_language(C) -add_executable(main subproject/main.c) diff --git a/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt b/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt deleted file mode 100644 index c31ec38d29..0000000000 --- a/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0065 is not set: Do not add flags to export symbols from - executables without the ENABLE_EXPORTS target property. Run "cmake - --help-policy CMP0065" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - For compatibility with older versions of CMake, additional flags may be - added to export symbols on all executables regardless of their - ENABLE_EXPORTS property. -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0065/WARN-ON.cmake b/Tests/RunCMake/CMP0065/WARN-ON.cmake deleted file mode 100644 index 6ed4a41440..0000000000 --- a/Tests/RunCMake/CMP0065/WARN-ON.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CMAKE_POLICY_WARNING_CMP0065 1) -enable_language(C) -add_executable(main subproject/main.c) diff --git a/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt b/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt index bed59601ce..7f19467219 100644 --- a/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt +++ b/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt @@ -1,22 +1,8 @@ -cmake_minimum_required(VERSION 3.3) - +cmake_minimum_required(VERSION 3.10) project(TestPolicyCMP0065 C) set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS BADFLAGS) -#---------------------------------------------------------------------- -cmake_policy(SET CMP0065 OLD) -add_executable(FooOLDBad1 main.c) - -#---------------------------------------------------------------------- -cmake_policy(SET CMP0065 OLD) -add_executable(FooOLDBad2 main.c) -set_target_properties(FooOLDBad2 PROPERTIES ENABLE_EXPORTS ON) - -#---------------------------------------------------------------------- -cmake_policy(SET CMP0065 NEW) add_executable(FooNEWGood main.c) -#---------------------------------------------------------------------- -cmake_policy(SET CMP0065 NEW) add_executable(FooNEWBad main.c) set_target_properties(FooNEWBad PROPERTIES ENABLE_EXPORTS ON) From 77f71ad4e27f36002f037704ace56de2bdef59e0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 14:22:53 -0500 Subject: [PATCH 15/15] Remove compatibility with CMake versions older than 3.5 This compatibility has been deprecated since commit 3a4791548d (Deprecate compatibility with CMake versions older than 3.5, 2023-02-09, v3.27.0-rc1~508^2). The behavior itself has been deprecated since CMake 3.5. Issue: #26613 --- Help/command/DEPRECATED_POLICY_VERSIONS.txt | 4 ++-- Help/release/dev/remove-old-compatibility.rst | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmPolicies.cxx | 6 +++--- .../cmake_minimum_required/BeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/BeforeVersionRemoved.cmake | 2 +- .../PolicyBeforeVersionRemoved-stderr.txt | 2 +- .../cmake_minimum_required/PolicyBeforeVersionRemoved.cmake | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Help/command/DEPRECATED_POLICY_VERSIONS.txt b/Help/command/DEPRECATED_POLICY_VERSIONS.txt index effb09bf09..1b9f0d4d6d 100644 --- a/Help/command/DEPRECATED_POLICY_VERSIONS.txt +++ b/Help/command/DEPRECATED_POLICY_VERSIONS.txt @@ -1,9 +1,9 @@ .. versionchanged:: 4.0 - Compatibility with versions of CMake older than 3.3 is removed. + Compatibility with versions of CMake older than 3.5 is removed. Calls to :command:`cmake_minimum_required(VERSION)` or :command:`cmake_policy(VERSION)` that do not specify at least - 3.3 as their policy version (optionally via ``...``) + 3.5 as their policy version (optionally via ``...``) will produce an error in CMake 4.0 and above. .. versionchanged:: 3.31 diff --git a/Help/release/dev/remove-old-compatibility.rst b/Help/release/dev/remove-old-compatibility.rst index 01cccd63c9..7c8c39ace0 100644 --- a/Help/release/dev/remove-old-compatibility.rst +++ b/Help/release/dev/remove-old-compatibility.rst @@ -1,7 +1,7 @@ remove-old-compatibility ------------------------ -* Compatibility with versions of CMake older than 3.3 has been removed. +* Compatibility with versions of CMake older than 3.5 has been removed. Calls to :command:`cmake_minimum_required` or :command:`cmake_policy` that set the policy version to an older value now issue an error. Note that calls to those commands can still support older versions of diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 535b62fb1f..581f2bb2d0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1593,7 +1593,7 @@ void cmMakefile::Configure() this->SetCheckCMP0000(true); // Implicitly set the version for the user. - cmPolicies::ApplyPolicyVersion(this, 3, 3, 0, + cmPolicies::ApplyPolicyVersion(this, 3, 5, 0, cmPolicies::WarnCompat::Off); } } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index ba316ff9a1..36f1072fab 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -295,16 +295,16 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, WarnCompat warnCompat) { // Error on policy versions for which support has been removed. - if (majorVer < 3 || (majorVer == 3 && minorVer < 3)) { + if (majorVer < 3 || (majorVer == 3 && minorVer < 5)) { if (IsFromLegacyInstallEXPORT(mf, majorVer, minorVer, patchVer)) { // Silently tolerate cmake_policy calls generated by install(EXPORT) // in CMake versions prior to 3.18. majorVer = 3; - minorVer = 3; + minorVer = 5; patchVer = 0; } else { mf->IssueMessage(MessageType::FATAL_ERROR, - "Compatibility with CMake < 3.3 has been removed " + "Compatibility with CMake < 3.5 has been removed " "from CMake.\n" ADVICE_UPDATE_VERSION_ARGUMENT); cmSystemTools::SetFatalErrorOccurred(); return false; diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt index f51dca9d21..62145e638b 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at BeforeVersionRemoved\.cmake:1 \(cmake_minimum_required\): - Compatibility with CMake < 3\.3 has been removed from CMake\. + Compatibility with CMake < 3\.5 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake index 319b1d9f2b..c530a1672e 100644 --- a/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.4) diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt index 9f31b80282..c9eba0fbd5 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at PolicyBeforeVersionRemoved\.cmake:1 \(cmake_policy\): - Compatibility with CMake < 3\.3 has been removed from CMake\. + Compatibility with CMake < 3\.5 has been removed from CMake\. Update the VERSION argument value\. Or, use the \.\.\. syntax to tell CMake that the project requires at least but has been updated diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake index 33bafe83f5..a282b776af 100644 --- a/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake @@ -1 +1 @@ -cmake_policy(VERSION 3.2) +cmake_policy(VERSION 3.4)