Commit 20612978 authored by Shane Parris's avatar Shane Parris
Browse files

Add tests for `file(GLOB)` CONFIGURE_DEPENDS flag

parent 3f4b81f5
.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
.*6bc141b40c0f851d20fa9a1fe5fbdae94acc5de0
.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
.*0c3ceab9daa7914fde7410c34cae4049e140aa51
.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake")
file(GLOB_RECURSE
CONTENT_LIST
CONFIGURE_DEPENDS
LIST_DIRECTORIES false
RELATIVE "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/test/*"
)
string(SHA1 CONTENT_LIST_HASH "${CONTENT_LIST}")
add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST_HASH})
.*CONFIGURE_DEPENDS is invalid for script and find package modes\.
^CMake Error: The glob expression
.* at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)
was already present in the glob cache but the directory
contents have changed during the configuration run.
Matching glob expressions:
CONTENT_LIST_1 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)
CONTENT_LIST_2 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)$
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/third")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "two")
file(GLOB_RECURSE CONTENT_LIST_1
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/test/*"
)
file(GLOB_RECURSE CONTENT_LIST_2
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/test/*"
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/third/three" "three")
file(GLOB_RECURSE CONTENT_LIST_3
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/test/*"
)
^CMake Error at GLOB-noexp-CONFIGURE_DEPENDS\.cmake:[0-9]+ \(file\):
file GLOB requires a glob expression after CONFIGURE_DEPENDS\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$
file(GLOB CONTENT_LIST CONFIGURE_DEPENDS)
^CMake Warning \(dev\) at GLOB-warn-CONFIGURE_DEPENDS-late\.cmake:[0-9]+ \(file\):
CONFIGURE_DEPENDS flag was given after a glob expression was already
evaluated\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.$
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "Hi, Mom!")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "Love you!")
file(GLOB CONTENT_LIST
"${CMAKE_CURRENT_BINARY_DIR}/test/first/*"
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/test/second/*"
)
^CMake Warning \(dev\):
The detected version of Ninja:
.*
is less than the version of Ninja required by CMake for adding restat
dependencies to the build\.ninja manifest regeneration target:
1\.8
Any pre-check scripts, such as those generated for file\(GLOB
CONFIGURE_DEPENDS\), will not be run by Ninja\.
This warning is for project developers\. Use -Wno-dev to suppress it\.$
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one")
file(GLOB_RECURSE CONTENT_LIST
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/test/*"
)
......@@ -43,10 +43,79 @@ run_cmake(GLOB-error-FOLLOW_SYMLINKS)
run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean)
run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg)
run_cmake(GLOB-error-RELATIVE-no-arg)
run_cmake(GLOB-error-CONFIGURE_DEPENDS-modified)
run_cmake(GLOB-noexp-CONFIGURE_DEPENDS)
run_cmake(GLOB-noexp-LIST_DIRECTORIES)
run_cmake(GLOB-noexp-RELATIVE)
run_cmake_command(GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE ${CMAKE_COMMAND} -P
${RunCMake_SOURCE_DIR}/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake)
if(NOT WIN32 OR CYGWIN)
run_cmake(GLOB_RECURSE-cyclic-recursion)
run_cmake(INSTALL-SYMLINK)
endif()
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Detect ninja version so we know what tests can be supported.
execute_process(
COMMAND "${RunCMake_MAKE_PROGRAM}" --version
OUTPUT_VARIABLE ninja_out
ERROR_VARIABLE ninja_out
RESULT_VARIABLE ninja_res
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+")
set(ninja_version "${ninja_out}")
message(STATUS "ninja version: ${ninja_version}")
else()
message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
endif()
if("${ninja_version}" VERSION_LESS 1.8)
message(STATUS "Ninja is too old for GLOB CONFIGURE_DEPENDS; expect a warning.")
endif()
endif()
if(RunCMake_GENERATOR STREQUAL "Ninja" AND "${ninja_version}" VERSION_LESS 1.8)
run_cmake(GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version)
else()
run_cmake(GLOB-warn-CONFIGURE_DEPENDS-late)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GLOB-CONFIGURE_DEPENDS-RerunCMake-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_DEFAULT_stderr ".*")
if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
RunCMake_GENERATOR STREQUAL "Watcom WMake")
set(fs_delay 3)
else()
set(fs_delay 1.125)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test")
set(tf_1 "${RunCMake_TEST_BINARY_DIR}/test/1.txt")
file(WRITE "${tf_1}" "1")
message(STATUS "GLOB-RerunCMake: first configuration...")
run_cmake(GLOB-CONFIGURE_DEPENDS-RerunCMake)
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-build ${CMAKE_COMMAND} --build .)
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay})
message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: add another file...")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test/sub")
set(tf_2 "${RunCMake_TEST_BINARY_DIR}/test/sub/2.txt")
file(WRITE "${tf_2}" "2")
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first ${CMAKE_COMMAND} --build .)
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .)
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")
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .)
run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)
unset(RunCMake_DEFAULT_stderr)
endif()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment