[CMake] Betr.: Re: Parallel make & custom command
Marcel Loose
loose at astron.nl
Wed Jun 29 15:55:24 EDT 2011
--
Marcel Loose
Senior Software Engineer, Computing Group R&D, Astron, the Netherlands
>>> Michael Wild 29-06-11 20:47 >>>
On 06/29/2011 05:22 PM, Marcel Loose wrote:
> Hi all,
>
> I'm having a problem with a parallel 'make' where one or more sources
> are generated by a custom command.
>
> The situation is as follows. There are a couple of targets
(executables)
> that depend on the same source file being generated by a custom
> command.
>
> I notice that, when doing a parallel build, the custom command is
> executed multiple times, thereby potentially overwriting or corrupting
> the same file that's generated in different threads.
>
> My feeling is that this is caused by the fact that CMake generates a
> build.cmake file for each target separately. Hence, when doing a
> parallel build, these build.cmake files are also processed in
parallel.
>
> Am I correct in this assumption? And if so, what's the proper solution
> for this problem?
>
> Best regards,
> Marcel Loose.
>
Yes, I've seen this issue too. The only way I can think of fixing this
is by having a single custom target which depends on the generated
files, and then have the executables using the generated sources depend
on that custom target. This way you force the custom target to be run
first before the other targets, thus avoiding the custom commands
generating the sources from running multiple times.
Michael
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
After I had posted my question I realized that this issue has come up
quite recently on the mailing list in a thread that I started -- see
http://www.mail-archive.com/cmake@cmake.org/msg36362.html. Although the
original question was related to building mulitple targets in parallel,
Michael Hertling showed that CMake inherently has problems with parallel
builds when custom targets/commands come into play.
So maybe I should open an isse for this?
Best regards,
Marcel Loose.
More information about the CMake
mailing list