[cmake-developers] [CMake 0014059]: CMake double executes a custom command when multiple custom target depend on it

Mantis Bug Tracker mantis at public.kitware.com
Wed Apr 3 11:09:51 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14059 
====================================================================== 
Reported By:                ashuang
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14059
Category:                   (No Category)
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-04-03 11:09 EDT
Last Modified:              2013-04-03 11:09 EDT
====================================================================== 
Summary:                    CMake double executes a custom command when multiple
custom target depend on it
Description: 
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)


Steps to Reproduce: 
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


Additional Information: 
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.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-04-03 11:09 ashuang        New Issue                                    
======================================================================




More information about the cmake-developers mailing list