diff options
author | Brad King <brad.king@kitware.com> | 2015-01-27 16:22:06 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-01-27 16:22:06 (GMT) |
commit | 33daec1ae96752817a268fdca2518032cb9453f8 (patch) | |
tree | 1f141e723d0c08c7fe12d79e2ca8fa84098ff6cd /Tests/RunCMake/try_compile | |
parent | 34ce0dd22f1c2091c5870e25677b100f753c44a0 (diff) | |
parent | 7f2dc8dc54fa6486423477dd673725bc40d3fdeb (diff) | |
download | CMake-33daec1ae96752817a268fdca2518032cb9453f8.zip CMake-33daec1ae96752817a268fdca2518032cb9453f8.tar.gz CMake-33daec1ae96752817a268fdca2518032cb9453f8.tar.bz2 |
Merge topic 'test-rerun-cmake'
7f2dc8dc configure_file: Test that CMake re-runs on input change or output missing
daf95a38 try_compile: Test that CMake re-runs on input change
Diffstat (limited to 'Tests/RunCMake/try_compile')
8 files changed, 56 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt new file mode 100644 index 0000000..e600b9b --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt @@ -0,0 +1 @@ +^ninja: no work to do\.$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt new file mode 100644 index 0000000..b0438f5 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt @@ -0,0 +1,5 @@ +Running CMake on RerunCMake +FALSE +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt new file mode 100644 index 0000000..88e54b1 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt @@ -0,0 +1,2 @@ +^Running CMake on RerunCMake +FALSE$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt new file mode 100644 index 0000000..9c78b26 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake-stderr.txt b/Tests/RunCMake/try_compile/RerunCMake-stderr.txt new file mode 100644 index 0000000..45d305a --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-stderr.txt @@ -0,0 +1,2 @@ +^Running CMake on RerunCMake +TRUE$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-stdout.txt new file mode 100644 index 0000000..9c78b26 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake.cmake b/Tests/RunCMake/try_compile/RerunCMake.cmake new file mode 100644 index 0000000..5a9f1d4 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake.cmake @@ -0,0 +1,7 @@ +message("Running CMake on RerunCMake") # write to stderr if cmake reruns +enable_language(C) +try_compile(res + "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${CMAKE_CURRENT_BINARY_DIR}/TryCompileInput.c" + ) +message("${res}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 06096b2..6cdbafa 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -17,3 +17,36 @@ run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) run_cmake(CMP0056) + +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(in_tc "${RunCMake_TEST_BINARY_DIR}/TryCompileInput.c") + file(WRITE "${in_tc}" "int main(void) { return 0; }\n") + + # Older Ninja keeps all rerun output on stdout + set(ninja "") + if(RunCMake_GENERATOR STREQUAL "Ninja") + execute_process(COMMAND ${RunCMake_MAKE_PROGRAM} --version + OUTPUT_VARIABLE ninja_version OUTPUT_STRIP_TRAILING_WHITESPACE) + if(ninja_version VERSION_LESS 1.5) + set(ninja -ninja-no-console) + endif() + endif() + + message(STATUS "RerunCMake: first configuration...") + run_cmake(RerunCMake) + run_cmake_command(RerunCMake-nowork${ninja} ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution + message(STATUS "RerunCMake: modify try_compile input...") + file(WRITE "${in_tc}" "does-not-compile\n") + run_cmake_command(RerunCMake-rerun${ninja} ${CMAKE_COMMAND} --build .) + run_cmake_command(RerunCMake-nowork${ninja} ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() |