diff options
Diffstat (limited to 'Tests/RunCMake')
7 files changed, 68 insertions, 2 deletions
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 16f39d9..ff676a6 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -9,5 +9,6 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.c 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 9d7922f..790da54 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,4 +1,8 @@ -add_library(bar STATIC bar.cpp) +project(ExcludeFromAllSub NONE) + +add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp) + +add_library(zot STATIC zot.cpp) add_library(foo STATIC foo.cpp) target_include_directories(foo PUBLIC .) 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 56a8abd..433c032 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -9,13 +9,17 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) "${subinc_lib}" "${main_exe}" ) - if(NOT EXISTS "${file}") + 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}") 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 e9ba92f..951e03c 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -34,6 +34,26 @@ run_cmake(ExcludeFromAll) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake-check-file ExcludeFromAll/check.cmake) 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) |