On 07-Oct-14 18:00, Bill Hoffman wrote:
On 10/7/2014 2:19 AM, Ruslan Baratov via CMake wrote:
Hi,

I have a problem with parallel build of project with custom command.
Custom command generates two files and depends on generator script. For
optimization purpose first file created only when not exists. This lead
to conflict, even if I "protect" custom command with a custom target and
set explicit dependencies:

Can you give an example?
Yes, I leave a links at the end of the previous message:

CMakeLists.txt: http://pastebin.com/dspw4j1S
generate.cmake: http://pastebin.com/XNS6hPRX

add_dependencies should be what you use.
Have it:

add_custom_target(
    Generate
    ...
)
add_library(Alib "${A}")
add_library(Blib "${B}")
add_dependencies(Alib Generate)
add_dependencies(Blib Generate)

Tested on Ubuntu with Makefile generator:
 > cmake -H. -B_builds
 > cmake --build _builds -- -j4 # First build OK
 > touch generate.cmake
 > cmake --build _builds -- -j4 # Second build. Unexpected `Script run`

I'm expecting 1 message `Script run`, but I have 5 messages. If I modify `generate.cmake` script so it always write the file then everything works fine.

Ruslo
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to