MantisBT - CMake
View Issue Details
0014597CMakeCMakepublic2013-11-26 04:172016-06-10 14:31
tisi 
Kitware Robot 
normalmajoralways
closedmoved 
x86Windows7
CMake 2.8.12 
 
0014597: Ninja: several add_custom_command(Target ... POST_BUILD ...) may lead to a command which breaks the command line limit
We encountered the following problem with a project for an embedded microcontroller, but it is reproducable on normal x86 machines. We use the command add_custom_command(Target <Target> POST_BUILD <Commands>) to run severeal commands after linking (some hex-file manipulations like calculating crc32, moving of memory and so on).

In the past we used the makefile generator and our project worked fine, but we want to switch to ninja for some other reasons.

We found the following issue:
The ninja generator combines the linker command and all the add_custom_commands to one large command (all commands are combinded by &&, so linker-command && custom1 && custom2 && custom3 && ...), which breaks the command line limit of windows (8kB). I think the same issue would be true on linux with an higher limit (i think 32kb).

Is it possible to change the behavior of the generator to support something like that (e.g. intermediate targets for the add_custom_commands)? Right now we make a shell script and use only one add_custom_command, but its not nice that there is a different behavior between the make and the ninja build at all.
I've uploaded a file with a cmake project, which demonstrates that. You will need a c compiler, but it doesn't matter which one.

Just run
cmake -G "Ninja" <source_path> && ninja
on Windows and you should see the issue.
No tags attached.
zip AddCustomCommandDemo.zip (985) 2013-11-26 04:17
https://public.kitware.com/Bug/file/4967/AddCustomCommandDemo.zip
Issue History
2013-11-26 04:17tisiNew Issue
2013-11-26 04:17tisiFile Added: AddCustomCommandDemo.zip
2013-11-26 05:42Peter KuemmelAssigned To => Peter Kuemmel
2013-11-26 05:42Peter KuemmelStatusnew => assigned
2013-11-26 05:45Peter KuemmelNote Added: 0034562
2013-11-26 05:45Peter KuemmelStatusassigned => confirmed
2014-04-13 05:48Peter KuemmelAssigned ToPeter Kuemmel =>
2014-06-16 11:24Alexandre ChassanyNote Added: 0036204
2015-01-28 16:00Alexandre ChassanyNote Added: 0037855
2016-06-10 14:29Kitware RobotNote Added: 0042433
2016-06-10 14:29Kitware RobotStatusconfirmed => 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
(0034562)
Peter Kuemmel   
2013-11-26 05:45   
Thanks for the test case, I could reproduce it.

We already use "response files" for large single commands, but not when multiple commands are merged. I try to fix this.
(0036204)
Alexandre Chassany   
2014-06-16 11:24   
Hi,

I'd like to know if you have any update on this issue ? I also encounter this issue on a project and i'd like to know if you have any idea when a fix to this issue will be available ?

Thx
(0037855)
Alexandre Chassany   
2015-01-28 16:00   
Any update on this issue ? Any pointer where i can investigate ?

Thx
(0042433)
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.