[Cmake-commits] CMake branch, master, updated. v3.11.1-795-gc299920
Kitware Robot
kwrobot at kitware.com
Tue May 15 09:55:06 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 c29992078f2d8683228030f847948a902ac9173b (commit)
via 6e594916592e5f8f17b387546d79e484ac092b9e (commit)
from d793b482d914e0d8706b901dceeb1b5f0c405413 (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=c29992078f2d8683228030f847948a902ac9173b
commit c29992078f2d8683228030f847948a902ac9173b
Merge: d793b48 6e59491
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue May 15 13:54:01 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue May 15 09:54:08 2018 -0400
Merge topic 'custom-command-expand-empty'
6e59491659 add_custom_{command,target}: Fix crash on empty expanded command
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !2074
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e594916592e5f8f17b387546d79e484ac092b9e
commit 6e594916592e5f8f17b387546d79e484ac092b9e
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon May 14 11:49:02 2018 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon May 14 11:54:27 2018 -0400
add_custom_{command,target}: Fix crash on empty expanded command
Our custom command generation logic assumes that all command lines have
at least `argv0`. In `add_custom_{command,target}` we already check
that at least a `COMMAND` was given, but using `COMMAND_EXPAND_LISTS` in
combination with a generator expression that expands to an empty string
may produce an empty command line. In this case simply add an empty
string as a command to maintain our internal invariant.
Fixes: #17993
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 136cf39..6c9f9d6 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -40,6 +40,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
argv.push_back(std::move(parsed_arg));
}
}
+
+ // Later code assumes at least one entry exists, but expanding
+ // lists on an empty command may have left this empty.
+ // FIXME: Should we define behavior for removing empty commands?
+ if (argv.empty()) {
+ argv.push_back(std::string());
+ }
+
this->CommandLines.push_back(std::move(argv));
}
diff --git a/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
new file mode 100644
index 0000000..bc899a4
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
@@ -0,0 +1 @@
+add_custom_target(EmptyCustom COMMAND "" COMMAND_EXPAND_LISTS)
diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
index 6c4e91b..2caed03 100644
--- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
@@ -1,5 +1,6 @@
include(RunCMake)
+run_cmake(CommandExpandsEmpty)
run_cmake(NoArguments)
run_cmake(BadTargetName)
run_cmake(ByproductsNoCommand)
-----------------------------------------------------------------------
Summary of changes:
Source/cmCustomCommandGenerator.cxx | 8 ++++++++
Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake | 1 +
Tests/RunCMake/add_custom_target/RunCMakeTest.cmake | 1 +
3 files changed, 10 insertions(+)
create mode 100644 Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list