From e9bf8ec849eb215993bc3883fac061da251d538b Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Mar 2016 10:52:37 -0400 Subject: [PATCH] Ninja: Add test for `$subdir/all` targets --- Tests/RunCMake/Ninja/RunCMakeTest.cmake | 16 ++++++++++++++++ Tests/RunCMake/Ninja/SubDir-build-stdout.txt | 1 + Tests/RunCMake/Ninja/SubDir.cmake | 2 ++ Tests/RunCMake/Ninja/SubDir/CMakeLists.txt | 2 ++ 4 files changed, 21 insertions(+) create mode 100644 Tests/RunCMake/Ninja/SubDir-build-stdout.txt create mode 100644 Tests/RunCMake/Ninja/SubDir.cmake create mode 100644 Tests/RunCMake/Ninja/SubDir/CMakeLists.txt diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 64f97bcd6..4e068882d 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -16,3 +16,19 @@ run_CMP0058(WARN-no) run_CMP0058(WARN-by) run_CMP0058(NEW-no) run_CMP0058(NEW-by) + +function(run_SubDir) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SubDir-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(SubDir) + if(WIN32) + set(SubDir_all [[SubDir\all]]) + else() + set(SubDir_all [[SubDir/all]]) + endif() + run_cmake_command(SubDir-build ${CMAKE_COMMAND} --build . --target ${SubDir_all}) +endfunction() +run_SubDir() diff --git a/Tests/RunCMake/Ninja/SubDir-build-stdout.txt b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt new file mode 100644 index 000000000..e4b466286 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt @@ -0,0 +1 @@ +Building InAll diff --git a/Tests/RunCMake/Ninja/SubDir.cmake b/Tests/RunCMake/Ninja/SubDir.cmake new file mode 100644 index 000000000..7224ec344 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir.cmake @@ -0,0 +1,2 @@ +add_subdirectory(SubDir) +add_custom_target(TopFail ALL COMMAND does_not_exist) diff --git a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt new file mode 100644 index 000000000..73ae4317f --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_custom_target(SubFail COMMAND does_not_exist) +add_custom_target(InAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building InAll")