[CMake] Shared intermediary files

Michael Hertling mhertling at online.de
Wed Feb 22 17:03:47 EST 2012


On 02/20/2012 10:07 PM, Kevin Schmidt wrote:
> Hello,
>   I'm in the process of converting over a large, monolithic tree with many libraries from a custom build solution over to cmake.  So far, we've loved it.  I am wondering about others' solutions to a problem we have encountered.
> 
> We have more than a few cases of generated source files - for example, Qt moc files.   These all get dumped into CMAKE_CURRENT_BINARY_DIR.  Now, the libraries we have build both static & shared, and have the same source files.  In Visual Studio, this generates two projects in the solution.  It seems that these do not share dependencies.  Occasionally, this means that both libraries try to write to the generated source file at the same time, which generates a (false) build failure.
> 
> What do others do?  Am I misunderstanding something?
> Kevin

How do you generate the source files? Supposedly, you're using custom
commands, right? At least, QT4_WRAP_CPP() does. If so, you probably
walk right into a quite common trap - from the documentation of
ADD_CUSTOM_COMMAND():

"Do not list the output in more than one independent target that
may build in parallel or the two instances of the rule may conflict
(instead use add_custom_target to drive the command and make the other
targets depend on that one)."

If your issue isn't related to custom commands, could you provide more
detailed information how you generate the source files in question?

Regards,

Michael


More information about the CMake mailing list