Files
CMake/Tests/CommandLength/CMakeLists.txt
Roger Leigh 22e8b3af04 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
2018-02-06 13:24:46 -05:00

18 lines
504 B
CMake

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