On Wed, 2011-06-29 at 20:46 +0200, Michael Wild wrote: > 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
Seems my webmail client completely screwed up the topic threading :-( Here's my reply again, hopefully now placed properly. Sorry for the noise. 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. _______________________________________________ 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