MantisBT - CMake
View Issue Details
0013209CMakeCMakepublic2012-05-10 11:192012-10-01 13:22
wbu 
 
normalfeaturealways
closedsuspended 
GNU/LinuxSuse11.4
CMake 2.8.8 
 
0013209: automagical custom target generation to consolidate duplicate custom commands
When building a dynamic and static library from the same source and a custom command is involved, the custom command will be called twice at the same time with the same output, most likely leading to undefined behavior.

I really tried hard to get the custom command called with different output paths, like what is done with the object files when compiling. But i could not find a way to achieve this.

My current workaround is to add a dependency for the dynamic library to the static library, which is not really what i want.

Attached is a stripped down dummy project, that most likely fails to compile, because the C-code is doubled by calling the modify.sh in two processes at the same time.

tested with cmake 2.8.3 and 2.8.8
tar -xzf dummy.tar.gz
cd dummy
make
If this issue cannot be solved in cmake, it would be nice to add at an FAQ item for it.
No tags attached.
gz dummy.tar.gz (943) 2012-05-10 11:19
https://public.kitware.com/Bug/file/4325/dummy.tar.gz
Issue History
2012-05-10 11:19wbuNew Issue
2012-05-10 11:19wbuFile Added: dummy.tar.gz
2012-05-10 11:42Brad KingNote Added: 0029463
2012-05-10 11:42Brad KingAssigned To => Brad King
2012-05-10 11:42Brad KingStatusnew => resolved
2012-05-10 11:42Brad KingResolutionopen => not fixable
2012-05-10 11:54wbuNote Added: 0029464
2012-05-10 11:54wbuStatusresolved => feedback
2012-05-10 11:54wbuResolutionnot fixable => reopened
2012-05-10 12:05Brad KingNote Added: 0029465
2012-05-10 12:05Brad KingAssigned ToBrad King =>
2012-05-10 12:05Brad KingSeverityminor => feature
2012-05-10 12:05Brad KingStatusfeedback => resolved
2012-05-10 12:05Brad KingResolutionreopened => suspended
2012-05-10 12:05Brad KingSummaryrace condition with parallel build and custom command => automagical custom target generation to consolidate duplicate custom commands
2012-10-01 13:22David ColeNote Added: 0031125
2012-10-01 13:22David ColeStatusresolved => closed

Notes
(0029463)
Brad King   
2012-05-10 11:42   
FAQ added with explanation and solution:

http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_file_used_in_more_than_one_target_in_the_same_directory.3F [^]
(0029464)
wbu   
2012-05-10 11:54   
Is it really impossible to fix this issue? The second workaround looks like it could be done automatically by cmake.

It's really hard to catch such issues, because they happen by chance.
(0029465)
Brad King   
2012-05-10 12:05   
Custom commands *have* to be attached to targets because build systems like the VS IDE have no other place to put build rules at all.

Re 0013209:0029464: It might be possible to automatically identify groups of custom commands that are needed by multiple targets but it would require non-trivial analysis of all custom commands and all targets in a given directory. Then we would need a well-defined and unsurprising way to generate extra targets spontaneously to contain the commands. Furthermore it would have to be done in a backwards-compatible way so that build rules for existing projects do not change.

Marking as "suspended" until a volunteer comes to the developers list with a proposed design and time to implement it.
(0031125)
David Cole   
2012-10-01 13:22   
Closing resolved issues that have not been updated in more than 4 months.