diff options
Diffstat (limited to 'Tests/RunCMake/BuildDepends')
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe.step1.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe.step2.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 34 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/check.cmake | 37 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/main.c | 1 |
10 files changed, 124 insertions, 0 deletions
diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake new file mode 100644 index 0000000..ef33012 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake @@ -0,0 +1,19 @@ +enable_language(C) + +add_executable(main main.c ${CMAKE_CURRENT_BINARY_DIR}/test.manifest) + +if(MSVC AND NOT MSVC_VERSION LESS 1400) + set(EXTRA_CHECK [[ +file(STRINGS "$<TARGET_FILE:main>" content REGEX "name=\"Kitware.CMake.C-Exe-Manifest-step[0-9]\"") +if(NOT "${content}" MATCHES "name=\"Kitware.CMake.C-Exe-Manifest-step${check_step}\"") + set(RunCMake_TEST_FAILED "Binary has no manifest with name=\"Kitware.CMake.C-Exe-Manifest-step${check_step}\":\n ${content}") +endif() +]]) +endif() + +file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/test.manifest\" + ) +${EXTRA_CHECK} +") diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake new file mode 100644 index 0000000..c0b939d --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake @@ -0,0 +1,6 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/test.manifest" [[ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" version="1.0.0.0" + name="Kitware.CMake.C-Exe-Manifest-step1"/> +</assembly> +]]) diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake new file mode 100644 index 0000000..a75bf21 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake @@ -0,0 +1,6 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/test.manifest" [[ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" version="1.0.0.0" + name="Kitware.CMake.C-Exe-Manifest-step2"/> +</assembly> +]]) diff --git a/Tests/RunCMake/BuildDepends/C-Exe.cmake b/Tests/RunCMake/BuildDepends/C-Exe.cmake new file mode 100644 index 0000000..5057ca9 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c) + +file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\" + ) +set(check_exes + \"$<TARGET_FILE:main>\" + ) +") diff --git a/Tests/RunCMake/BuildDepends/C-Exe.step1.cmake b/Tests/RunCMake/BuildDepends/C-Exe.step1.cmake new file mode 100644 index 0000000..08e2949 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c" [[ +int main(void) { return 1; } +]]) diff --git a/Tests/RunCMake/BuildDepends/C-Exe.step2.cmake b/Tests/RunCMake/BuildDepends/C-Exe.step2.cmake new file mode 100644 index 0000000..ee4530c --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c" [[ +int main(void) { return 2; } +]]) diff --git a/Tests/RunCMake/BuildDepends/CMakeLists.txt b/Tests/RunCMake/BuildDepends/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake new file mode 100644 index 0000000..8782ba9 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -0,0 +1,34 @@ +include(RunCMake) + +function(run_BuildDepends CASE) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + include(${RunCMake_SOURCE_DIR}/${CASE}.step1.cmake OPTIONAL) + run_cmake(${CASE}) + set(RunCMake-check-file check.cmake) + set(check_step 1) + run_cmake_command(${CASE}-build1 ${CMAKE_COMMAND} --build . --config Debug) + if(run_BuildDepends_skip_step_2) + return() + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution + include(${RunCMake_SOURCE_DIR}/${CASE}.step2.cmake OPTIONAL) + set(check_step 2) + run_cmake_command(${CASE}-build2 ${CMAKE_COMMAND} --build . --config Debug) +endfunction() + +run_BuildDepends(C-Exe) +if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode") + if(RunCMake_GENERATOR MATCHES "Visual Studio 10") + # VS 10 forgets to re-link when a manifest changes + set(run_BuildDepends_skip_step_2 1) + endif() + run_BuildDepends(C-Exe-Manifest) + unset(run_BuildDepends_skip_step_2) +endif() diff --git a/Tests/RunCMake/BuildDepends/check.cmake b/Tests/RunCMake/BuildDepends/check.cmake new file mode 100644 index 0000000..26a9eb6 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/check.cmake @@ -0,0 +1,37 @@ +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + if(RunCMake_TEST_FAILED) + return() + endif() + foreach(exe IN LISTS check_exes) + execute_process(COMMAND ${exe} RESULT_VARIABLE res) + if(NOT res EQUAL ${check_step}) + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED} + '${exe}' returned '${res}' but expected '${check_step}' +") + endif() + endforeach() + foreach(p IN LISTS check_pairs) + if("${p}" MATCHES "^(.*)\\|(.*)$") + set(lhs "${CMAKE_MATCH_1}") + set(rhs "${CMAKE_MATCH_2}") + if(NOT EXISTS "${lhs}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED} + '${lhs}' missing +") + elseif(NOT EXISTS "${rhs}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED} + '${rhs}' missing +") + elseif(NOT "${lhs}" IS_NEWER_THAN "${rhs}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED} + '${lhs}' is not newer than '${rhs}' +") + endif() + endif() + endforeach() +else() + set(RunCMake_TEST_FAILED " + '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing +") +endif() diff --git a/Tests/RunCMake/BuildDepends/main.c b/Tests/RunCMake/BuildDepends/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } |