mirror of
https://github.com/reactos/CMake.git
synced 2025-02-17 10:10:19 +00:00
add_custom_{command,target}: Fix WORKING_DIRECTORY leading genex
Since commit v3.13.0-rc1~39^2 (add_custom_{command,target}: WORKING_DIRECTORY generator expressions, 2018-09-22) the `WORKING_DIRECTORY` option accepts generator expressions. Fix support for the case of a leading generator expression by deferring conversion to an absolute path until after evaluation of the generator expression. Fixes: #18543
This commit is contained in:
parent
44cc305ac1
commit
98d59417b0
@ -318,12 +318,6 @@ bool cmAddCustomCommandCommand::InitialPass(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert working directory to a full path.
|
||||
if (!working.empty()) {
|
||||
const std::string& build_dir = this->Makefile->GetCurrentBinaryDirectory();
|
||||
working = cmSystemTools::CollapseFullPath(working, build_dir);
|
||||
}
|
||||
|
||||
// Choose which mode of the command to use.
|
||||
bool escapeOldStyle = !verbatim;
|
||||
if (source.empty() && output.empty()) {
|
||||
|
@ -181,13 +181,6 @@ bool cmAddCustomTargetCommand::InitialPass(
|
||||
}
|
||||
}
|
||||
|
||||
// Convert working directory to a full path.
|
||||
if (!working_directory.empty()) {
|
||||
const std::string& build_dir = this->Makefile->GetCurrentBinaryDirectory();
|
||||
working_directory =
|
||||
cmSystemTools::CollapseFullPath(working_directory, build_dir);
|
||||
}
|
||||
|
||||
if (commandLines.empty() && !byproducts.empty()) {
|
||||
this->Makefile->IssueMessage(
|
||||
cmake::FATAL_ERROR,
|
||||
|
@ -70,6 +70,12 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
this->GE->Parse(workingdirectory);
|
||||
this->WorkingDirectory = cge->Evaluate(this->LG, this->Config);
|
||||
// Convert working directory to a full path.
|
||||
if (!this->WorkingDirectory.empty()) {
|
||||
std::string const& build_dir = this->LG->GetCurrentBinaryDirectory();
|
||||
this->WorkingDirectory =
|
||||
cmSystemTools::CollapseFullPath(this->WorkingDirectory, build_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ file(MAKE_DIRECTORY ${TestWorkingDir_BINARY_DIR}/genex)
|
||||
add_custom_command(
|
||||
OUTPUT "${TestWorkingDir_BINARY_DIR}/genex/working.c"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${TestWorkingDir_SOURCE_DIR}/working.c.in" "${TestWorkingDir_BINARY_DIR}/genex/working.c"
|
||||
WORKING_DIRECTORY "${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
|
||||
WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
|
||||
COMMENT "custom command"
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ add_custom_target(
|
||||
CustomGenex ALL
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${TestWorkingDir_SOURCE_DIR}/customTarget.c" "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c"
|
||||
BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c"
|
||||
WORKING_DIRECTORY "${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
|
||||
WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
|
||||
)
|
||||
|
||||
add_dependencies(workinggenex CustomGenex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user