MantisBT - CMake
View Issue Details
0014059CMake(No Category)public2013-04-03 11:092013-10-07 10:04
ashuang 
 
normalmajoralways
closednot fixable 
Ubuntu10.04 i386
CMake 2.8.9 
 
0014059: CMake double executes a custom command when multiple custom target depend on it
CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

add_custom_command(OUTPUT a.txt
    COMMAND touch a.txt
    COMMENT "Making a")

add_custom_target(b ALL COMMENT "Making b" DEPENDS a.txt)
add_custom_target(c ALL COMMENT "Making c" DEPENDS a.txt)
add_custom_target(d ALL COMMENT "Making d" DEPENDS a.txt)
Run:
$ cmake .
$ make -j 3
[ 16%] [ 33%] [ 50%] Making a
Making a
Making a
[ 66%] [ 83%] [100%] Making b
Making d
Making c
[100%] [100%] Built target b
Built target d
[100%] Built target c
I would expect to see only one instance of "Making a".

When I use this pattern with a more complex add_custom_command(), the output file gets corrupted because multiple processes are writing to the file at the same time.
No tags attached.
Issue History
2013-04-03 11:09ashuangNew Issue
2013-04-03 11:25Brad KingNote Added: 0032749
2013-04-03 11:25Brad KingStatusnew => resolved
2013-04-03 11:25Brad KingResolutionopen => not fixable
2013-10-07 10:04Robert MaynardNote Added: 0034024
2013-10-07 10:04Robert MaynardStatusresolved => closed

Notes
(0032749)
Brad King   
2013-04-03 11:25   
http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_file_used_in_more_than_one_target_in_the_same_directory.3F [^]
(0034024)
Robert Maynard   
2013-10-07 10:04   
Closing resolved issues that have not been updated in more than 4 months.