[Cmake-commits] CMake branch, master, updated. v3.12.2-763-gcac09cc
Kitware Robot
kwrobot at kitware.com
Fri Sep 28 11:25:04 EDT 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via cac09cc52ccba9f3435e4d7cc227d15b6a009855 (commit)
via f158ac19e1e52362b04ff08c309ac3cf8e429bb7 (commit)
from 4e98203c6c318f7c2caf4c31b2c2863772eef57b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cac09cc52ccba9f3435e4d7cc227d15b6a009855
commit cac09cc52ccba9f3435e4d7cc227d15b6a009855
Merge: 4e98203 f158ac1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 28 15:16:47 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 28 11:17:09 2018 -0400
Merge topic 'customcommandworkingdirectory'
f158ac19e1 add_custom_{command,target}: WORKING_DIRECTORY generator expressions
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !2409
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f158ac19e1e52362b04ff08c309ac3cf8e429bb7
commit f158ac19e1e52362b04ff08c309ac3cf8e429bb7
Author: Jon Chronopoulos <patches at crondog.com>
AuthorDate: Sat Sep 22 17:00:28 2018 +1000
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Sep 28 11:15:33 2018 -0400
add_custom_{command,target}: WORKING_DIRECTORY generator expressions
This teaches add_custom_command and add_custom_target WORKING_DIRECTORY
about generator expressions
Fixes: #14089
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index 5f74c54..71fe494 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -182,6 +182,9 @@ The options are:
If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory.
+ Arguments to ``WORKING_DIRECTORY`` may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
``DEPFILE``
Specify a ``.d`` depfile for the :generator:`Ninja` generator.
A ``.d`` file holds dependencies usually emitted by the custom
diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst
index bd61c8b..a6b2f77 100644
--- a/Help/command/add_custom_target.rst
+++ b/Help/command/add_custom_target.rst
@@ -121,3 +121,6 @@ The options are:
Execute the command with the given current working directory.
If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory.
+
+ Arguments to ``WORKING_DIRECTORY`` may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/release/dev/custom_command-working_directory-genex.rst b/Help/release/dev/custom_command-working_directory-genex.rst
new file mode 100644
index 0000000..ae06202
--- /dev/null
+++ b/Help/release/dev/custom_command-working_directory-genex.rst
@@ -0,0 +1,5 @@
+custom_command-working_directory-genex
+--------------------------------------
+
+* The :command:`add_custom_command` and :command:`add_custom_target` commands
+ learned to support generator expressions in ``WORKING_DIRECTORY`` options.
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 6c9f9d6..5bbae17 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -64,6 +64,13 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
}
this->Depends.insert(this->Depends.end(), result.begin(), result.end());
}
+
+ const std::string& workingdirectory = this->CC.GetWorkingDirectory();
+ if (!workingdirectory.empty()) {
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ this->GE->Parse(workingdirectory);
+ this->WorkingDirectory = cge->Evaluate(this->LG, this->Config);
+ }
}
cmCustomCommandGenerator::~cmCustomCommandGenerator()
@@ -186,7 +193,7 @@ const char* cmCustomCommandGenerator::GetComment() const
std::string cmCustomCommandGenerator::GetWorkingDirectory() const
{
- return this->CC.GetWorkingDirectory();
+ return this->WorkingDirectory;
}
std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 34fd653..b7e2a39 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -23,6 +23,7 @@ class cmCustomCommandGenerator
cmGeneratorExpression* GE;
cmCustomCommandLines CommandLines;
std::vector<std::string> Depends;
+ std::string WorkingDirectory;
const char* GetCrossCompilingEmulator(unsigned int c) const;
const char* GetArgv0Location(unsigned int c) const;
diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
index 4975feb..5495a9b 100644
--- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
+++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
@@ -42,3 +42,23 @@ add_custom_target(
)
add_dependencies(working2 Custom2)
+
+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>/"
+ COMMENT "custom command"
+)
+
+add_executable(workinggenex "${TestWorkingDir_BINARY_DIR}/genex/working.c"
+ "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c")
+
+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>/"
+)
+
+add_dependencies(workinggenex CustomGenex)
-----------------------------------------------------------------------
Summary of changes:
Help/command/add_custom_command.rst | 3 +++
Help/command/add_custom_target.rst | 3 +++
.../dev/custom_command-working_directory-genex.rst | 5 +++++
Source/cmCustomCommandGenerator.cxx | 9 ++++++++-
Source/cmCustomCommandGenerator.h | 1 +
Tests/CustomCommandWorkingDirectory/CMakeLists.txt | 20 ++++++++++++++++++++
6 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 Help/release/dev/custom_command-working_directory-genex.rst
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list