MantisBT - CMake
View Issue Details
0015612CMakeCMakepublic2015-06-12 06:382016-06-10 14:31
tim blechmann 
Kitware Robot 
normalmajoralways
closedmoved 
Windows
CMake 3.2.1 
 
0015612: ninja generator: "The command line is too long"
i'm adding many POST_BUILD steps via add_custom_command. at one point, ninja builds fail with "The command line is too long""

apparently cmLocalNinjaGenerator::BuildCommandLine simply concatenates various commands via " && " without checking, whether the command line is too long.
No tags attached.
Issue History
2015-06-12 06:38tim blechmannNew Issue
2015-06-15 09:13Brad KingNote Added: 0038924
2015-09-09 09:21tim blechmannNote Added: 0039374
2016-05-17 06:30Martin AnkerlNote Added: 0041067
2016-05-18 04:23Martin AnkerlNote Added: 0041071
2016-05-18 08:59Brad KingNote Added: 0041072
2016-06-10 14:29Kitware RobotNote Added: 0042793
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0038924)
Brad King   
2015-06-15 09:13   
Corresponding mailing list thread:

 Custom commands with Ninja on Windows
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/13434 [^]
(0039374)
tim blechmann   
2015-09-09 09:21   
i'm also seeing this with normal targets (c++ object file rules), if there are many include paths
(0041067)
Martin Ankerl   
2016-05-17 06:30   
I have just signed up here to report this bug as well. Windows has a limit of 8191 characters, see here: https://support.microsoft.com/en-us/kb/830473 [^]

In a target we have lots of custom commands to copy files, and this generates a very long command which does not work.
(0041071)
Martin Ankerl   
2016-05-18 04:23   
I had a look at how best to solve this. A solution would be to use a response file (rspfile and rspfile_content), but it is currently not possible to have multiple lines in the response file. So ninja needs to be extended to be usable like this.

Another solution is to output a build target for each custom command, and add dependencies to these custom commands.

E.g. instead of

----------------
build CMakeFiles\copy_czmq_3.0.2.util: CUSTOM_COMMAND
  COMMAND = cmd.exe /C "cd /D C:\dev\ras_robvis\vc140_x64_ninja && "c:\Program Files (x86)\CMake\bin\cmake.exe" -E copy_if_different "C:/dev/ras_robvis/src/ext/lib_czmq/3.0.2/vc140_x64/czmq.dll" "C:/dev/ras_robvis/vc140_x64_ninja/bin/./czmq.dll" && cd /D C:\dev\ras_robvis\vc140_x64_ninja && "c:\Program Files (x86)\CMake\bin\cmake.exe" -E copy_if_different "C:/dev/ras_robvis/src/ext/lib_czmq/3.0.2/vc140_x64/czmqd.dll" "C:/dev/ras_robvis/vc140_x64_ninja/bin/./czmqd.dll""
  DESC = Running utility command for copy_czmq_3.0.2
  restat = 1
build copy_czmq_3.0.2: phony CMakeFiles\copy_czmq_3.0.2.util
----------------


output this:
----------------
build CMakeFiles\copy_czmq_3.0.2.util.1: CUSTOM_COMMAND
  COMMAND = cmd.exe /C "cd /D C:\dev\ras_robvis\vc140_x64_ninja && "c:\Program Files (x86)\CMake\bin\cmake.exe" -E copy_if_different "C:/dev/ras_robvis/src/ext/lib_czmq/3.0.2/vc140_x64/czmq.dll" "C:/dev/ras_robvis/vc140_x64_ninja/bin/./czmq.dll""
  restat = 1

build CMakeFiles\copy_czmq_3.0.2.util.2: CUSTOM_COMMAND
  COMMAND = cmd.exe /C "cd /D C:\dev\ras_robvis\vc140_x64_ninja && "c:\Program Files (x86)\CMake\bin\cmake.exe" -E copy_if_different "C:/dev/ras_robvis/src/ext/lib_czmq/3.0.2/vc140_x64/czmqd.dll" "C:/dev/ras_robvis/vc140_x64_ninja/bin/./czmqd.dll""
  restat = 1

build CMakeFiles\copy_czmq_3.0.2.util: phony | CMakeFiles\copy_czmq_3.0.2.util.1 CMakeFiles\copy_czmq_3.0.2.util.2
  DESC = Running utility command for copy_czmq_3.0.2

build copy_czmq_3.0.2: phony CMakeFiles\copy_czmq_3.0.2.util
----------------
(0041072)
Brad King   
2016-05-18 08:59   
Re 0015612:0041071: Please see discussion in the thread linked in 0015612:0038924. If you are interested in working on this please join the dev list:

 https://cmake.org/mailman/listinfo/cmake-developers [^]

and raise it for discussion there.
(0042793)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.