Merge topic 'custom-command-work-dir-genex'

98d59417b0 add_custom_{command,target}: Fix WORKING_DIRECTORY leading genex

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2559
This commit is contained in:
Brad King
2018-11-05 12:42:27 +00:00
committed by Kitware Robot
4 changed files with 8 additions and 15 deletions

View File

@@ -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()) {

View File

@@ -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,

View File

@@ -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);
}
}
}

View File

@@ -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)