summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-04 13:34:09 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-04 13:34:27 (GMT)
commite485dca1e80e2e32848b0770040971fb5b5c103f (patch)
treedd02cbdda0760ececa4855d37bf7ed6816eeef0e
parentca4bb89f276e244b5b56d1988cd659d30df1ca5a (diff)
downloadCMake-e485dca1e80e2e32848b0770040971fb5b5c103f.zip
CMake-e485dca1e80e2e32848b0770040971fb5b5c103f.tar.gz
CMake-e485dca1e80e2e32848b0770040971fb5b5c103f.tar.bz2
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.
-rw-r--r--Tests/CMakeLists.txt18
-rw-r--r--Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in11
-rw-r--r--Tests/RunCMake/ctest_build/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/ctest_build/SubdirTarget-check.cmake4
4 files changed, 16 insertions, 29 deletions
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()