mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 07:11:52 +08:00
file: Fix CONFIGURE output relative path
In commit a6fee09484
(file: Add CONFIGURE subcommand, 2020-03-06,
v3.18.0-rc1~584^2) we accidentally treated relative path outputs
with respect to the current working directory. Treat them with
respect to the current binary directory instead.
Fixes: #20885
This commit is contained in:
@@ -508,8 +508,7 @@ The arguments are:
|
|||||||
|
|
||||||
``OUTPUT <output-file>``
|
``OUTPUT <output-file>``
|
||||||
Specify the output file name to generate. A relative path is treated with
|
Specify the output file name to generate. A relative path is treated with
|
||||||
respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`. See policy
|
respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`.
|
||||||
:policy:`CMP0070`.
|
|
||||||
``<output-file>`` does not support generator expressions.
|
``<output-file>`` does not support generator expressions.
|
||||||
|
|
||||||
``CONTENT <content>``
|
``CONTENT <content>``
|
||||||
|
@@ -2862,7 +2862,8 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
// Check for generator expressions
|
// Check for generator expressions
|
||||||
const std::string input = args[4];
|
const std::string input = args[4];
|
||||||
std::string outputFile = args[2];
|
std::string outputFile = cmSystemTools::CollapseFullPath(
|
||||||
|
args[2], status.GetMakefile().GetCurrentBinaryDirectory());
|
||||||
|
|
||||||
std::string::size_type pos = input.find_first_of("<>");
|
std::string::size_type pos = input.find_first_of("<>");
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
|
@@ -7,3 +7,4 @@ run_cmake(DirOutput)
|
|||||||
run_cmake(NewLineStyle-NoArg)
|
run_cmake(NewLineStyle-NoArg)
|
||||||
run_cmake(NewLineStyle-ValidArg)
|
run_cmake(NewLineStyle-ValidArg)
|
||||||
run_cmake(NewLineStyle-WrongArg)
|
run_cmake(NewLineStyle-WrongArg)
|
||||||
|
run_cmake(SubDir)
|
||||||
|
4
Tests/RunCMake/File_Configure/SubDir-check.cmake
Normal file
4
Tests/RunCMake/File_Configure/SubDir-check.cmake
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
set(expected "${RunCMake_TEST_BINARY_DIR}/SubDir/out.txt")
|
||||||
|
if(NOT EXISTS "${expected}")
|
||||||
|
set(RunCMake_TEST_FAILED "Expected file not created:\n ${expected}")
|
||||||
|
endif()
|
1
Tests/RunCMake/File_Configure/SubDir.cmake
Normal file
1
Tests/RunCMake/File_Configure/SubDir.cmake
Normal file
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(SubDir)
|
1
Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt
Normal file
1
Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
file(CONFIGURE OUTPUT out.txt CONTENT "")
|
Reference in New Issue
Block a user