From 715f90bdd99b7343034551100aa6e70d24170d24 Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Mon, 10 Feb 2020 17:31:52 -0500 Subject: Tests: Perform minor cleanups in RunCMake.file test --- Tests/RunCMake/file/RunCMakeTest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 8d1b981..b9356eb 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -111,7 +111,7 @@ else() set(tf_1 "${RunCMake_TEST_BINARY_DIR}/test/1.txt") file(WRITE "${tf_1}" "1") - message(STATUS "GLOB-RerunCMake: first configuration...") + message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: first configuration...") run_cmake(GLOB-CONFIGURE_DEPENDS-RerunCMake) run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-build ${CMAKE_COMMAND} --build .) @@ -125,7 +125,7 @@ else() execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: remove first test file...") - file(REMOVE "${RunCMake_TEST_BINARY_DIR}/test/1.txt") + file(REMOVE "${tf_1}") run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .) run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .) -- cgit v0.12 From b620dc566de2b2f4c115c027151c34d3e08e255c Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Mon, 10 Feb 2020 17:30:17 -0500 Subject: file: Fix GLOB_RECURSE LIST_DIRECTORIES documentation regarding CMP0009 --- Help/command/file.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/command/file.rst b/Help/command/file.rst index b186177..df7d8ba 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -540,7 +540,7 @@ are only traversed if ``FOLLOW_SYMLINKS`` is given or policy By default ``GLOB_RECURSE`` omits directories from result list - setting ``LIST_DIRECTORIES`` to true adds directories to result list. If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to -``OLD`` then ``LIST_DIRECTORIES`` treats symlinks as directories. +``NEW`` then ``LIST_DIRECTORIES`` treats symlinks as directories. Examples of recursive globbing include:: -- cgit v0.12 From 818ec34bddf3c5f838d3a3087d00e3a94e62cba4 Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Mon, 10 Feb 2020 17:26:28 -0500 Subject: 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. --- Source/cmGlobVerificationManager.cxx | 2 ++ ...-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt | 1 + ...ONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt | 1 + .../GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt | 1 + .../file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake | 10 ++++++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 15 +++++++++++++++ 6 files changed, 30 insertions(+) create mode 100644 Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt create mode 100644 Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt create mode 100644 Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt create mode 100644 Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx index 4817773..9ac5cd5 100644 --- a/Source/cmGlobVerificationManager.cxx +++ b/Source/cmGlobVerificationManager.cxx @@ -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); diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt new file mode 100644 index 0000000..05c9a91 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt @@ -0,0 +1 @@ +test2/test_folder_symlink diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt new file mode 100644 index 0000000..05c9a91 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt @@ -0,0 +1 @@ +test2/test_folder_symlink diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt new file mode 100644 index 0000000..1fbac01 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt @@ -0,0 +1 @@ +.*Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake new file mode 100644 index 0000000..da40534 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake @@ -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}) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index b9356eb..f5461ad 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -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) -- cgit v0.12