file: GLOB_RECURSE VerifyGlobs.cmake should have CMP0009 set to new

In certain cases, rebuilds with CMake using the CONFIGURE_DEPENDS flag
with GLOB_RECURSE could result in a reconfigure loop due to CMP0009 not
being propogated to the generated VerifyGlobs.cmake script.

During the inital configuration phase, RecurseThroughSymlinksOn() is
called for recursive glob operations either by having the CMP0009 status
not set to NEW or by explicitly providing the FOLLOW_SYMLINKS flag. At
the end when the VerifyGlobs script is created, the FOLLOW_SYMLINKS flag
is written according to the final resolved form through a call to
GetRecurseThroughSymlinks(). Thus, setting CMP0009 to NEW in the
generated file is safe and allows correct behavior whether or not the
end user sets the policy status to NEW or OLD.
This commit is contained in:
Shane Parris
2020-02-10 17:26:28 -05:00
committed by Brad King
parent b620dc566d
commit 818ec34bdd
6 changed files with 30 additions and 0 deletions

View File

@@ -38,6 +38,8 @@ 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

@@ -0,0 +1 @@
test2/test_folder_symlink

View File

@@ -0,0 +1 @@
test2/test_folder_symlink

View File

@@ -0,0 +1 @@
.*Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake

View File

@@ -0,0 +1,10 @@
cmake_policy(SET CMP0009 NEW)
message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake")
file(GLOB_RECURSE
CONTENT_LIST
CONFIGURE_DEPENDS
LIST_DIRECTORIES false
RELATIVE "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/test2/*"
)
add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST})

View File

@@ -129,6 +129,21 @@ else()
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .)
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .)
if(NOT WIN32 OR CYGWIN)
message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: link the first test directory into a new directory...")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test2")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${RunCMake_TEST_BINARY_DIR}/test" "${RunCMake_TEST_BINARY_DIR}/test2/test_folder_symlink")
message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: first configuration...")
run_cmake(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake)
run_cmake_command(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build ${CMAKE_COMMAND} --build .)
message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: add another file in the linked directory...")
set(tf_3 "${RunCMake_TEST_BINARY_DIR}/test/3.txt")
file(WRITE "${tf_3}" "3")
run_cmake_command(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild ${CMAKE_COMMAND} --build .)
endif()
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)
unset(RunCMake_DEFAULT_stderr)