diff options
author | Brad King <brad.king@kitware.com> | 2019-09-30 14:26:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-09-30 14:27:15 (GMT) |
commit | 8aa5f6ba446dd8ff817e54979f466b8a247f967a (patch) | |
tree | 73ac7f0c03a2f1f7c3c2b115d301f21b205e8ef0 /Tests/RunCMake | |
parent | 9b03baee308d78db119554def6e34fd9db9683ac (diff) | |
parent | dce58afd30b781bd99a1af5c6860583577d58a1f (diff) | |
download | CMake-8aa5f6ba446dd8ff817e54979f466b8a247f967a.zip CMake-8aa5f6ba446dd8ff817e54979f466b8a247f967a.tar.gz CMake-8aa5f6ba446dd8ff817e54979f466b8a247f967a.tar.bz2 |
Merge topic 'fix-EXCLUDE_FROM_ALL-subdir-all'
dce58afd30 Merge branch 'backport-3.15-fix-EXCLUDE_FROM_ALL-subdir-all'
013d7dd484 Help: Mention 3.14.7 EXCLUDE_FROM_ALL fix in 3.15.4 release note
61103c0bac Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all'
1fe4501592 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.15.4
05d7ca14e9 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all'
62d45d91e8 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.14.7
b3b1c7bf3a Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL
156b56480a Makefiles: Revert "Make build root targets ... recursive"
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3863
Diffstat (limited to 'Tests/RunCMake')
9 files changed, 120 insertions, 66 deletions
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 568bdf8..da4d1e5 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -92,9 +92,12 @@ function(run_cmake test) set(maybe_input_file "") endif() if(RunCMake_TEST_COMMAND) + if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + endif() execute_process( COMMAND ${RunCMake_TEST_COMMAND} - WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake index f686005..ff676a6 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -4,3 +4,11 @@ add_subdirectory(ExcludeFromAll EXCLUDE_FROM_ALL) add_executable(main main.cpp) target_link_libraries(main PRIVATE foo) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(main_exe \"$<TARGET_FILE:main>\") +set(foo_lib \"$<TARGET_FILE:foo>\") +set(bar_lib \"$<TARGET_FILE:bar>\") +set(zot_lib \"$<TARGET_FILE:zot>\") +set(subinc_lib \"$<TARGET_FILE:subinc>\") +") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index 9e6462b..790da54 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,20 +1,11 @@ -add_library(bar STATIC bar.cpp) +project(ExcludeFromAllSub NONE) -add_library(foo STATIC foo.cpp) - -add_library(baz STATIC foo.cpp) -set_target_properties(baz PROPERTIES EXCLUDE_FROM_ALL OFF) - -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/main.txt" - CONTENT "$<TARGET_FILE_NAME:main>") +add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp) -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/bar.txt" - CONTENT "$<TARGET_FILE_NAME:bar>") - -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/baz.txt" - CONTENT "$<TARGET_FILE_NAME:baz>") +add_library(zot STATIC zot.cpp) +add_library(foo STATIC foo.cpp) target_include_directories(foo PUBLIC .) + +add_library(subinc STATIC subinc.cpp) +set_target_properties(subinc PROPERTIES EXCLUDE_FROM_ALL OFF) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake new file mode 100644 index 0000000..297ad1e --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake @@ -0,0 +1,32 @@ +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + if(RunCMake_TEST_FAILED) + return() + endif() + + foreach(file + "${foo_lib}" + "${subinc_lib}" + "${zot_lib}" + ) + if(NOT EXISTS "${file}") + set(RunCMake_TEST_FAILED + "Artifact should exist but is missing:\n ${file}") + return() + endif() + endforeach() + foreach(file + "${main_exe}" + "${bar_lib}" + ) + if(EXISTS "${file}") + set(RunCMake_TEST_FAILED + "Artifact should be missing but exists:\n ${file}") + return() + endif() + endforeach() +else() + set(RunCMake_TEST_FAILED " + '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing +") +endif() diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake index 14ec482..433c032 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -1,44 +1,35 @@ -# Use globbing to check if exes / libs were built because determining -# exactly where these files will live inside a CMake -P script is -# pretty challenging. - -file(READ "${RunCMake_TEST_BINARY_DIR}/main.txt" main_exe) -file(READ "${RunCMake_TEST_BINARY_DIR}/bar.txt" bar_lib) -file(READ "${RunCMake_TEST_BINARY_DIR}/baz.txt" baz_lib) - -set(found_main FALSE) -file(GLOB_RECURSE files - LIST_DIRECTORIES FALSE - RELATIVE "${RunCMake_TEST_BINARY_DIR}" - "${RunCMake_TEST_BINARY_DIR}/*") -foreach (file IN LISTS files) - if (file MATCHES "${main_exe}") - set(found_main TRUE) +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + if(RunCMake_TEST_FAILED) + return() endif() -endforeach() -if (NOT found_main) - set(RunCMake_TEST_FAILED "'main' missing from ${RunCMake_TEST_BINARY_DIR}") -endif() -set(found_bar FALSE) -set(found_baz FALSE) -file(GLOB_RECURSE files - LIST_DIRECTORIES FALSE - RELATIVE "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll" - "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll/*") -foreach (file IN LISTS files) - if (file MATCHES "${bar_lib}") - set(found_bar TRUE) - endif() - if (file MATCHES "${baz_lib}") - set(found_baz TRUE) - endif() -endforeach() -if (found_bar) - set(RunCMake_TEST_FAILED - "'bar' was not excluded from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") -endif() -if (NOT found_baz) - set(RunCMake_TEST_FAILED - "'baz' missing from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") + foreach(file + "${foo_lib}" + "${subinc_lib}" + "${main_exe}" + ) + if(EXISTS "${file}") + # Remove for next step of test. + file(REMOVE "${file}") + else() + set(RunCMake_TEST_FAILED + "Artifact should exist but is missing:\n ${file}") + return() + endif() + endforeach() + foreach(file + "${zot_lib}" + "${bar_lib}" + ) + if(EXISTS "${file}") + set(RunCMake_TEST_FAILED + "Artifact should be missing but exists:\n ${file}") + return() + endif() + endforeach() +else() + set(RunCMake_TEST_FAILED " + '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing +") endif() diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp new file mode 100644 index 0000000..e9faacd --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp @@ -0,0 +1,4 @@ +int subinc() +{ + return 0; +} diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp new file mode 100644 index 0000000..ba7e966 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp @@ -0,0 +1,4 @@ +int zot() +{ + return 0; +} diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 781e483..951e03c 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -27,14 +27,34 @@ run_cmake_install(CMP0082-OLD -DCMP0082_VALUE=OLD) run_cmake_install(CMP0082-NEW -DCMP0082_VALUE=NEW) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) -set(RunCMake_TEST_NO_CLEAN 1) - -file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") -file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - +if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) +endif() run_cmake(ExcludeFromAll) +set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake-check-file ExcludeFromAll/check.cmake) -run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) - -unset(RunCMake_TEST_BINARY_DIR) +run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build . --config Debug) +if(RunCMake_GENERATOR STREQUAL "Ninja") + if(WIN32) + set(slash [[\]]) + else() + set(slash [[/]]) + endif() + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build . --target "ExcludeFromAll${slash}all") +elseif(RunCMake_GENERATOR MATCHES "Make") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub "${RunCMake_MAKE_PROGRAM}") +elseif(RunCMake_GENERATOR MATCHES "^Visual Studio [1-9][0-9]") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build ExcludeFromAll --config Debug) +elseif(RunCMake_GENERATOR STREQUAL "Xcode") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub xcodebuild -configuration Debug) +endif() +unset(RunCMake-check-file) unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_OPTIONS) +unset(RunCMake_TEST_BINARY_DIR) |