MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0012311 | CMake | CMake | public | 2011-06-30 03:52 | 2016-06-10 14:31 |
Reporter | Marcel Loose | ||||
Assigned To | Marcel Loose | ||||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | moved | ||
Platform | OS | OS Version | |||
Product Version | CMake 2.8.4 | ||||
Target Version | Fixed in Version | ||||
Summary | 0012311: add_custom_command documentation should warn against use in multiple independent targets | ||||
Description | When two or more targets depend on a source that is generated by a custom command, then the rule to create this source is executed more than once when doing a parallel build. This may even result in a corrupt source as can be demonstrated (see Steps to Reproduce) | ||||
Steps To Reproduce | 1. Create the following files: :::::::::::::: CMakeLists.txt :::::::::::::: cmake_minimum_required(VERSION 2.6) project(Parallel_Generated) add_custom_command(OUTPUT hello.cc COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/hello.txt -P ${CMAKE_SOURCE_DIR}/generate.cmake DEPENDS hello.txt ) set_source_files_properties(hello.cc PROPERTIES GENERATED TRUE) include_directories(${CMAKE_BINARY_DIR}) add_executable(one one.cc hello.cc) add_executable(two two.cc hello.cc) :::::::::::::: generate.cmake :::::::::::::: file(WRITE hello.cc " #include <iostream> void hello(const char* prefix) { ") file(STRINGS "${INFILE}" lines) foreach(line ${lines}) file(APPEND hello.cc " std::cout << prefix << \": ${line}\" << std::endl; ") endforeach(line) file(APPEND hello.cc " } ") :::::::::::::: hello.txt :::::::::::::: Hello World. I'm foo bar baz. :::::::::::::: one.cc :::::::::::::: extern void hello(const char*); int main() { hello("one"); return 0; } :::::::::::::: two.cc :::::::::::::: extern void hello(const char*); int main() { hello("two"); return 0; } 2. Create a build directory and run cmake from there. 3. Run the following bash-command line $ while true; do make clean; make -j2 || break; done You'll notice that for each build there are two lines "Generating ..." Sooner or later, after a few (re)builds, the build fail. Checking the generated source will explain why. | ||||
Additional Information | References: http://www.mail-archive.com/cmake@cmake.org/msg37021.html [^] http://www.mail-archive.com/cmake@cmake.org/msg36403.html [^] http://www.mail-archive.com/cmake@cmake.org/msg32782.html [^] | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2011-06-30 03:52 | Marcel Loose | New Issue | |||
2011-06-30 08:49 | Brad King | Note Added: 0026998 | |||
2011-06-30 08:49 | Brad King | Assigned To | => Brad King | ||
2011-06-30 08:49 | Brad King | Status | new => assigned | ||
2011-06-30 08:49 | Brad King | Summary | Parallel builds may fail when using add_custom_command => add_custom_command documentation should warn against use in multiple independent targets | ||
2011-06-30 08:51 | Brad King | Note Added: 0026999 | |||
2011-06-30 08:51 | Brad King | Status | assigned => resolved | ||
2011-06-30 08:51 | Brad King | Resolution | open => fixed | ||
2011-07-01 07:29 | Marcel Loose | Note Added: 0027001 | |||
2011-07-01 07:29 | Marcel Loose | Status | resolved => feedback | ||
2011-07-01 07:29 | Marcel Loose | Resolution | fixed => reopened | ||
2011-07-01 08:45 | Brad King | Note Added: 0027002 | |||
2011-07-01 08:45 | Brad King | Assigned To | Brad King => Marcel Loose | ||
2011-07-01 08:45 | Brad King | Status | feedback => backlog | ||
2011-07-01 09:31 | Marcel Loose | Note Added: 0027003 | |||
2011-07-01 09:35 | Brad King | Note Added: 0027004 | |||
2016-06-10 14:28 | Kitware Robot | Note Added: 0041856 | |||
2016-06-10 14:28 | Kitware Robot | Status | backlog => resolved | ||
2016-06-10 14:28 | Kitware Robot | Resolution | reopened => moved | ||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|