mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
cmake: Fix --build <relative-dir> for VS generators (#15609)
The VS >= 10 generators need to parse the .sln file from the build directory to locate targets in subdirectories. This occurs after we change the working directory to the build tree. If a relative directory other than "." was given then we would change to it and also refer to the .sln file location with it. Fix this by converting the build tree to a full path always. This will also give a more informative error message when the directory does not exist.
This commit is contained in:
parent
7195ec92b2
commit
90ad087ab9
@ -420,7 +420,7 @@ static int do_build(int ac, char const* const* av)
|
|||||||
switch (doing)
|
switch (doing)
|
||||||
{
|
{
|
||||||
case DoingDir:
|
case DoingDir:
|
||||||
dir = av[i];
|
dir = cmSystemTools::CollapseFullPath(av[i]);
|
||||||
doing = DoingNone;
|
doing = DoingNone;
|
||||||
break;
|
break;
|
||||||
case DoingTarget:
|
case DoingTarget:
|
||||||
|
1
Tests/RunCMake/CommandLine/BuildDir.cmake
Normal file
1
Tests/RunCMake/CommandLine/BuildDir.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(BuildDir)
|
5
Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt
Normal file
5
Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
add_custom_command(
|
||||||
|
OUTPUT output.txt
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
|
||||||
|
)
|
||||||
|
add_custom_target(CustomTarget ALL DEPENDS output.txt)
|
@ -28,9 +28,24 @@ run_cmake_command(build-no-cache
|
|||||||
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR})
|
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR})
|
||||||
run_cmake_command(build-no-generator
|
run_cmake_command(build-no-generator
|
||||||
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-no-generator)
|
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-no-generator)
|
||||||
|
run_cmake_command(build-bad-dir
|
||||||
|
${CMAKE_COMMAND} --build dir-does-not-exist)
|
||||||
run_cmake_command(build-bad-generator
|
run_cmake_command(build-bad-generator
|
||||||
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
|
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
|
||||||
|
|
||||||
|
function(run_BuildDir)
|
||||||
|
# Use a single build tree for a few tests without cleaning.
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build)
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
|
||||||
|
run_cmake(BuildDir)
|
||||||
|
run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir ..
|
||||||
|
${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget)
|
||||||
|
endfunction()
|
||||||
|
run_BuildDir()
|
||||||
|
|
||||||
if(RunCMake_GENERATOR STREQUAL "Ninja")
|
if(RunCMake_GENERATOR STREQUAL "Ninja")
|
||||||
# Use a single build tree for a few tests without cleaning.
|
# Use a single build tree for a few tests without cleaning.
|
||||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
|
||||||
|
1
Tests/RunCMake/CommandLine/build-bad-dir-result.txt
Normal file
1
Tests/RunCMake/CommandLine/build-bad-dir-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
2
Tests/RunCMake/CommandLine/build-bad-dir-stderr.txt
Normal file
2
Tests/RunCMake/CommandLine/build-bad-dir-stderr.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
^Error: [^
|
||||||
|
]+/Tests/RunCMake/CommandLine/build-bad-dir-build/dir-does-not-exist is not a directory$
|
Loading…
Reference in New Issue
Block a user