summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmLocalNinjaGenerator.cxx6
-rw-r--r--Tests/CustomCommand/CMakeLists.txt4
-rw-r--r--Tests/CustomCommand/empty_command.cxx4
3 files changed, 13 insertions, 1 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index b035f70a9b..5a747e5fdd 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -557,9 +557,13 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
std::string launcher = this->MakeCustomLauncher(ccg);
for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
+ std::string c = ccg.GetCommand(i);
+ if (c.empty()) {
+ continue;
+ }
cmdLines.push_back(launcher +
this->ConvertToOutputFormat(
- ccg.GetCommand(i),
+ c,
gg->IsMultiConfig() ? cmOutputConverter::NINJAMULTI
: cmOutputConverter::SHELL));
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index c1a7a57684..80545c483a 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -582,3 +582,7 @@ set_target_properties(mac_fw PROPERTIES
)
add_custom_command(OUTPUT mac_fw.txt COMMAND ${CMAKE_COMMAND} -E touch mac_fw.txt DEPENDS mac_fw)
add_custom_target(drive_mac_fw ALL DEPENDS mac_fw.txt)
+
+# Test empty COMMANDs are ommited
+add_executable(empty_command empty_command.cxx)
+add_custom_command(TARGET empty_command POST_BUILD COMMAND $<0:date>)
diff --git a/Tests/CustomCommand/empty_command.cxx b/Tests/CustomCommand/empty_command.cxx
new file mode 100644
index 0000000000..f8b643afbf
--- /dev/null
+++ b/Tests/CustomCommand/empty_command.cxx
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}