summaryrefslogtreecommitdiff
path: root/Tests/CommandLength
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@dundee.ac.uk>2017-12-14 16:09:02 +0000
committerBrad King <brad.king@kitware.com>2018-02-06 13:24:46 -0500
commit22e8b3af041f49842aeafa2d97129f422404d7de (patch)
tree3d2c76d931789a162114d38023faeeea1cc90760 /Tests/CommandLength
parentf7c08c333b3ccd86134f73a8a3df5bf59c53bdd8 (diff)
downloadcmake-22e8b3af041f49842aeafa2d97129f422404d7de.tar.gz
Ninja: Generate scripts for long custom command sequences
Ninja runs just one command line for every build statement, so the Ninja generator needs to `&&`-chain multiple commands together into one long string. For long custom command sequences this can exceed the maximum command-line length for the operating system. In such cases, write the commands out to a script instead, and then run the script from Ninja's one command line. Co-Author: Brad King <brad.king@kitware.com> Fixes: #15612
Diffstat (limited to 'Tests/CommandLength')
-rw-r--r--Tests/CommandLength/CMakeLists.txt17
-rw-r--r--Tests/CommandLength/test.c4
2 files changed, 21 insertions, 0 deletions
diff --git a/Tests/CommandLength/CMakeLists.txt b/Tests/CommandLength/CMakeLists.txt
new file mode 100644
index 0000000000..68360518b4
--- /dev/null
+++ b/Tests/CommandLength/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.10)
+project(CommandLength C)
+
+add_executable(CommandLength test.c)
+add_custom_command(TARGET CommandLength POST_BUILD VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E make_directory log)
+
+set(msg "xxxx $$$$ yyyy")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+foreach(i RANGE 1 1000)
+ add_custom_command(TARGET CommandLength POST_BUILD VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E echo "${i} ${msg}" > log/${i}
+ )
+endforeach()
diff --git a/Tests/CommandLength/test.c b/Tests/CommandLength/test.c
new file mode 100644
index 0000000000..f8b643afbf
--- /dev/null
+++ b/Tests/CommandLength/test.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}