ctest_build: Pass projectDir to GenerateBuildCommand
This allows the ctest_build command's TARGET option to name a target in a subdirectory and still build properly with msbuild. Add test case covering use of ctest_build() with such a TARGET.
This commit is contained in:
parent
a6c0299c40
commit
ac9a5f4d94
|
@ -130,10 +130,11 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
|
|||
cmakeBuildConfiguration = config;
|
||||
}
|
||||
|
||||
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
|
||||
std::string buildCommand
|
||||
= this->GlobalGenerator->
|
||||
GenerateBuildCommand(cmakeMakeProgram,
|
||||
cmakeProjectName, 0,
|
||||
cmakeProjectName, dir.c_str(),
|
||||
cmakeBuildAdditionalFlags, cmakeBuildTarget,
|
||||
cmakeBuildConfiguration, true, false);
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
|
|
|
@ -1660,6 +1660,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
|
|||
# -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
|
||||
# )
|
||||
|
||||
# A test for ctest_build() with targets in subdirectories
|
||||
if(CMAKE_TEST_GENERATOR_TOOLSET)
|
||||
set(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION "-T;${CMAKE_TEST_GENERATOR_TOOLSET};")
|
||||
else()
|
||||
set(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION)
|
||||
endif()
|
||||
configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
|
||||
"${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
|
||||
unset(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION)
|
||||
add_test(CTest.BuildCommand.ProjectInSubdir
|
||||
${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake"
|
||||
-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
|
||||
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
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
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_TEST_GENERATOR@")
|
||||
set(CTEST_PROJECT_NAME "VSProjectInSubdir")
|
||||
set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
|
||||
|
||||
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
|
||||
ctest_start(Experimental)
|
||||
ctest_configure(OPTIONS "@CMAKE_TEST_GENERATOR_TOOLSET_SELECTION@-DCMAKE_MAKE_PROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@")
|
||||
ctest_build(TARGET test)
|
Loading…
Reference in New Issue