From f0b1ca4d708049413b5957786f59e80ab54a12ea Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 6 Dec 2024 11:44:45 -0500 Subject: [PATCH] CMP0052: Remove support for OLD behavior --- Help/policy/CMP0052.rst | 9 ++-- Source/cmExportInstallFileGenerator.cxx | 39 ++------------ Source/cmPolicies.h | 2 +- .../BinInInstallPrefix-CMP0052-NEW-result.txt | 1 - .../BinInInstallPrefix-CMP0052-OLD-result.txt | 1 - .../BinInInstallPrefix-CMP0052-OLD-stderr.txt | 16 ------ ...BinInInstallPrefix-CMP0052-WARN-result.txt | 1 - ...MP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt | 20 -------- ...tallPrefix-stderr_INCLUDE_DIRECTORIES.txt} | 2 +- Tests/RunCMake/IfacePaths/CMakeLists.txt | 6 +-- Tests/RunCMake/IfacePaths/RunCMakeTest.cmake | 51 +++++++------------ .../SrcInInstallPrefix-CMP0052-NEW-result.txt | 1 - .../SrcInInstallPrefix-CMP0052-OLD-result.txt | 1 - .../SrcInInstallPrefix-CMP0052-OLD-stderr.txt | 16 ------ ...SrcInInstallPrefix-CMP0052-WARN-result.txt | 1 - ...MP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt | 20 -------- ...tallPrefix-stderr_INCLUDE_DIRECTORIES.txt} | 0 17 files changed, 29 insertions(+), 158 deletions(-) delete mode 100644 Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt delete mode 100644 Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt rename Tests/RunCMake/IfacePaths/{BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt => BinInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt} (89%) delete mode 100644 Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt delete mode 100644 Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-result.txt delete mode 100644 Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt rename Tests/RunCMake/IfacePaths/{SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt => SrcInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt} (100%) diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst index c710262024..c4cd981862 100644 --- a/Help/policy/CMP0052.rst +++ b/Help/policy/CMP0052.rst @@ -1,6 +1,9 @@ CMP0052 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.1 Reject source and build dirs in installed @@ -22,7 +25,5 @@ directory. The ``NEW`` behavior for this policy is to issue an error if such a directory is used. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.1 -.. |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/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index e00636c1d7..437da7aead 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -19,7 +19,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" -#include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -456,43 +455,11 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs( bool inSource = isSubDirectory(li, topSourceDir); if (isSubDirectory(li, installDir)) { // The include directory is inside the install tree. If the - // install tree is not inside the source tree or build tree then + // install tree is inside the source tree or build tree then do not // fall through to the checks below that the include directory is not // also inside the source tree or build tree. - bool shouldContinue = - (!inBinary || isSubDirectory(installDir, topBinaryDir)) && - (!inSource || isSubDirectory(installDir, topSourceDir)); - - if (prop == "INTERFACE_INCLUDE_DIRECTORIES") { - if (!shouldContinue) { - switch (target->GetPolicyStatusCMP0052()) { - case cmPolicies::WARN: { - std::ostringstream s; - s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n"; - s << "Directory:\n \"" << li - << "\"\nin " - "INTERFACE_INCLUDE_DIRECTORIES of target \"" - << target->GetName() - << "\" is a subdirectory of the install " - "directory:\n \"" - << installDir - << "\"\nhowever it is also " - "a subdirectory of the " - << (inBinary ? "build" : "source") << " tree:\n \"" - << (inBinary ? topBinaryDir : topSourceDir) << "\"\n"; - target->GetLocalGenerator()->IssueMessage( - MessageType::AUTHOR_WARNING, s.str()); - CM_FALLTHROUGH; - } - case cmPolicies::OLD: - shouldContinue = true; - break; - case cmPolicies::NEW: - break; - } - } - } - if (shouldContinue) { + if ((!inBinary || isSubDirectory(installDir, topBinaryDir)) && + (!inSource || isSubDirectory(installDir, topSourceDir))) { continue; } } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index d546aa6417..f5d7d41e83 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -155,7 +155,7 @@ class cmMakefile; SELECT(POLICY, CMP0052, \ "Reject source and build dirs in installed " \ "INTERFACE_INCLUDE_DIRECTORIES.", \ - 3, 1, 0, WARN) \ + 3, 1, 0, NEW) \ SELECT(POLICY, CMP0053, \ "Simplify variable reference and escape sequence evaluation.", 3, 1, \ 0, WARN) \ diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt deleted file mode 100644 index a08f80fb9e..0000000000 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): - 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 CMakeLists.txt:[0-9]+ \(cmake_minimum_required\): - The OLD behavior for policy CMP0052 will be removed from a future version - of CMake\. - - The cmake-policies\(7\) manual explains that the OLD behaviors of all - policies are deprecated and that a policy should be set to OLD only under - specific short-term circumstances. Projects should be ported to the NEW - behavior and not rely on setting a policy to OLD.$ diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt deleted file mode 100644 index eb4d56d5e5..0000000000 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt +++ /dev/null @@ -1,20 +0,0 @@ -CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0052 is not set: Reject source and build dirs in installed - INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for - policy details. Use the cmake_policy command to set the policy and - suppress this warning. - - Directory: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo" - - in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory - of the install directory: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix" - - however it is also a subdirectory of the build tree: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-WARN-build" - -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt similarity index 89% rename from Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt rename to Tests/RunCMake/IfacePaths/BinInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt index d5c480d79b..e6e57678e7 100644 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt +++ b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt @@ -1,6 +1,6 @@ CMake Error in CMakeLists.txt: Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo" + ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-build/foo" which is prefixed in the build directory. diff --git a/Tests/RunCMake/IfacePaths/CMakeLists.txt b/Tests/RunCMake/IfacePaths/CMakeLists.txt index 5ee2bef6c3..0dc68ee6a5 100644 --- a/Tests/RunCMake/IfacePaths/CMakeLists.txt +++ b/Tests/RunCMake/IfacePaths/CMakeLists.txt @@ -1,8 +1,4 @@ -if(RunCMake_TEST MATCHES "-CMP0052") - cmake_minimum_required(VERSION 3.0) # old enough to not set CMP0052 -else() - cmake_minimum_required(VERSION 3.10) -endif() +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) if(NOT TEST_FILE) set(TEST_FILE ${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake index c84e95e00a..a02bbfe24d 100644 --- a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake +++ b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake @@ -68,40 +68,25 @@ configure_file( COPYONLY ) -foreach(policyStatus NEW OLD "") - if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES) - if (NOT "${policyStatus}" STREQUAL "") - set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus}) - else() - unset(policyOption) - set(policyStatus WARN) - endif() - set(policySuffix -CMP0052-${policyStatus}) - endif() - set(RunCMake_TEST_OPTIONS - "--install-prefix ${RunCMake_BINARY_DIR}/prefix" ${policyOption} - "-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake" - ) - # Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run - # the test suite in-source properly. Otherwise the install directory would be - # a subdirectory or the source directory, which is allowed and tested separately - # below. - set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src") - set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix${policySuffix}-build") - run_cmake(BinInInstallPrefix${policySuffix}) - unset(RunCMake_TEST_BINARY_DIR) +set(RunCMake_TEST_OPTIONS + "--install-prefix ${RunCMake_BINARY_DIR}/prefix" ${policyOption} + "-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake" + ) +# Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run +# the test suite in-source properly. Otherwise the install directory would be +# a subdirectory or the source directory, which is allowed and tested separately +# below. +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix-build") +run_cmake(BinInInstallPrefix) +unset(RunCMake_TEST_BINARY_DIR) - set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption} - "-DTEST_FILE=${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake" - ) - run_cmake(SrcInInstallPrefix${policySuffix}) - unset(RunCMake_TEST_SOURCE_DIR) - - if (NOT TEST_PROP STREQUAL INCLUDE_DIRECTORIES) - break() - endif() -endforeach() +set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption} + "-DTEST_FILE=${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake" + ) +run_cmake(SrcInInstallPrefix) +unset(RunCMake_TEST_SOURCE_DIR) set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix") run_cmake(InstallPrefixInInterface) diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt deleted file mode 100644 index 38acbdd8b1..0000000000 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): - 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 CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): - The OLD behavior for policy CMP0052 will be removed from a future version - of CMake\. - - The cmake-policies\(7\) manual explains that the OLD behaviors of all - policies are deprecated and that a policy should be set to OLD only under - specific short-term circumstances. Projects should be ported to the NEW - behavior and not rely on setting a policy to OLD.$ diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt deleted file mode 100644 index fd6e3726db..0000000000 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt +++ /dev/null @@ -1,20 +0,0 @@ -CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0052 is not set: Reject source and build dirs in installed - INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for - policy details. Use the cmake_policy command to set the policy and - suppress this warning. - - Directory: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/src/foo" - - in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory - of the install directory: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix" - - however it is also a subdirectory of the source tree: - - ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/src" - -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt similarity index 100% rename from Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt rename to Tests/RunCMake/IfacePaths/SrcInInstallPrefix-stderr_INCLUDE_DIRECTORIES.txt