From e485dca1e80e2e32848b0770040971fb5b5c103f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 4 Feb 2022 08:34:09 -0500 Subject: Tests: Move CTest.BuildCommand.ProjectInSubdir into RunCMake.ctest_build The former duplicates code that is now part of the infrastructure in the latter. The latter can also explicitly verify the results. --- Tests/CMakeLists.txt | 18 ------------------ .../CTestBuildCommandProjectInSubdir.cmake.in | 11 ----------- Tests/RunCMake/ctest_build/RunCMakeTest.cmake | 12 ++++++++++++ Tests/RunCMake/ctest_build/SubdirTarget-check.cmake | 4 ++++ 4 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in create mode 100644 Tests/RunCMake/ctest_build/SubdirTarget-check.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6946ffb..fa6cd96 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2562,24 +2562,6 @@ if(BUILD_TESTING) # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" # ) - # A test for ctest_build() with targets in subdirectories - set(ctest_configure_options) - if(CMAKE_GENERATOR_PLATFORM) - list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM}) - endif() - if(CMAKE_GENERATOR_TOOLSET) - list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET}) - endif() - if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) - list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) - endif() - configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY) - unset(ctest_configure_options) - add_test(CTest.BuildCommand.ProjectInSubdir - ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested") - set(CTEST_TEST_UPDATE 1) if(CTEST_TEST_UPDATE) # Test CTest Update with Subversion diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in deleted file mode 100644 index 0f56781..0000000 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.10) - -set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir") -set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested") -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") - -ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) -ctest_start(Experimental) -ctest_configure(OPTIONS "@ctest_configure_options@") -ctest_build(TARGET test) diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index 511cd71..e94a55d 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -49,6 +49,18 @@ function(run_BuildChangeId) endfunction() run_BuildChangeId() +function(run_SubdirTarget) + set(CASE_CMAKELISTS_SUFFIX_CODE [=[ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/subdir/CMakeLists.txt [[ +add_custom_target(target_in_subdir COMMAND ${CMAKE_COMMAND} -E touch target_in_subdir.out VERBATIM) +]]) +add_subdirectory(subdir) +]=]) + set(CASE_CTEST_BUILD_ARGS TARGET target_in_subdir) + run_ctest(SubdirTarget) +endfunction() +run_SubdirTarget() + set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE) set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}") run_ctest(BuildCommandFailure) diff --git a/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake new file mode 100644 index 0000000..81d21ec --- /dev/null +++ b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake @@ -0,0 +1,4 @@ +set(expected_file "${RunCMake_TEST_BINARY_DIR}/subdir/target_in_subdir.out") +if(NOT EXISTS "${expected_file}") + set(RunCMake_TEST_FAILED "Expected build output file not found:\n ${expected_file}") +endif() -- cgit v0.12