1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 02:17:27 +08:00

CMP0009: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-11-07 15:13:48 -05:00
parent 43ef139567
commit 77f8c374f3
7 changed files with 8 additions and 56 deletions

View File

@@ -1,6 +1,9 @@
CMP0009
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
FILE GLOB_RECURSE calls should not follow symlinks by default.
In CMake 2.6.1 and below, :command:`file(GLOB_RECURSE)` calls would follow
@@ -15,7 +18,5 @@ to follow the symlinks by default, but only if ``FOLLOW_SYMLINKS`` is given
as an additional argument to the ``FILE`` command.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.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

View File

@@ -869,10 +869,7 @@ macro(_ExternalData_arg_series)
endmacro()
function(_ExternalData_arg_find_files glob pattern regex)
cmake_policy(PUSH)
cmake_policy(SET CMP0009 NEW)
file(${glob} globbed RELATIVE "${top_src}" "${top_src}/${pattern}*")
cmake_policy(POP)
set(externals_count -1)
foreach(entry IN LISTS globbed)
if("x${entry}" MATCHES "^x(.*)(\\.(${_ExternalData_REGEX_EXT}))$")

View File

@@ -677,28 +677,14 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
i++;
cmsys::Glob g;
g.SetRecurse(recurse);
bool explicitFollowSymlinks = false;
cmPolicies::PolicyStatus policyStatus =
status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0009);
if (recurse) {
switch (policyStatus) {
case cmPolicies::NEW:
g.RecurseThroughSymlinksOff();
break;
case cmPolicies::WARN:
CM_FALLTHROUGH;
case cmPolicies::OLD:
g.RecurseThroughSymlinksOn();
break;
}
}
cmake* cm = status.GetMakefile().GetCMakeInstance();
std::vector<std::string> files;
bool configureDepends = false;
bool warnConfigureLate = false;
bool warnFollowedSymlinks = false;
const cmake::WorkingMode workingMode = cm->GetWorkingMode();
while (i != args.end()) {
if (*i == "LIST_DIRECTORIES") {
@@ -722,7 +708,6 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
} else if (*i == "FOLLOW_SYMLINKS") {
++i; // skip FOLLOW_SYMLINKS
if (recurse) {
explicitFollowSymlinks = true;
g.RecurseThroughSymlinksOn();
if (i == args.end()) {
status.SetError(
@@ -805,11 +790,6 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
}
}
if (recurse && !explicitFollowSymlinks &&
g.GetFollowedSymlinkCount() != 0) {
warnFollowedSymlinks = true;
}
std::vector<std::string>& foundFiles = g.GetFiles();
cm::append(files, foundFiles);
@@ -834,24 +814,6 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
}
}
switch (policyStatus) {
case cmPolicies::NEW:
// Correct behavior, yay!
break;
case cmPolicies::OLD:
// Probably not really the expected behavior, but the author explicitly
// asked for the old behavior... no warning.
case cmPolicies::WARN:
// Possibly unexpected old behavior *and* we actually traversed
// symlinks without being explicitly asked to: warn the author.
if (warnFollowedSymlinks) {
status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
}
break;
}
std::sort(files.begin(), files.end());
files.erase(std::unique(files.begin(), files.end()), files.end());
status.GetMakefile().AddDefinition(variable, cmList::to_string(files));

View File

@@ -42,8 +42,6 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path,
<< cmVersion::GetMajorVersion() << "."
<< cmVersion::GetMinorVersion() << "\n";
verifyScriptFile << "cmake_policy(SET CMP0009 NEW)\n";
for (auto const& i : this->Cache) {
CacheEntryKey k = std::get<0>(i);
CacheEntryValue v = std::get<1>(i);

View File

@@ -42,7 +42,7 @@ class cmMakefile;
6, 1, NEW) \
SELECT(POLICY, CMP0009, \
"FILE GLOB_RECURSE calls should not follow symlinks by default.", 2, \
6, 2, WARN) \
6, 2, NEW) \
SELECT(POLICY, CMP0010, "Bad variable reference syntax is an error.", 2, 6, \
3, WARN) \
SELECT(POLICY, CMP0011, \

View File

@@ -70,12 +70,7 @@ function(getMissingShlibsErrorExtra FILE RESULT_VAR)
if(err_)
set(error_extra " Extra: Could not unpack package content: '${err}'")
else()
cmake_policy(PUSH)
# Tell file(GLOB_RECURSE) not to follow directory symlinks
# even if the project does not set this policy to NEW.
cmake_policy(SET CMP0009 NEW)
file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*")
cmake_policy(POP)
# get file info so that we can determine if file is executable or not
foreach(FILE_ IN LISTS FILE_PATHS_)

View File

@@ -1,4 +1,3 @@
cmake_policy(SET CMP0009 NEW)
message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake")
file(GLOB_RECURSE
CONTENT_LIST