CMP0052: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-12-06 11:44:45 -05:00
parent e4fddc8e37
commit f0b1ca4d70
17 changed files with 29 additions and 158 deletions

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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) \

View File

@@ -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 <min> value\. Or, use the <min>\.\.\.<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> 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.$

View File

@@ -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.

View File

@@ -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.

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 <min> value\. Or, use the <min>\.\.\.<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> 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.$

View File

@@ -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.