[CMake] Problems with parallel builds

Denis Scherbakov denis_scherbakov at yahoo.com
Thu Nov 18 08:45:40 EST 2010


Hi, Marcel,

What I mean is that I have a huge source tree and many CMake files and there is a source file inside this tree that needs to be built two times, because there will be an executable using it (non-PIC) and a shared library (PIC). So I have to create two targets (say MYLIB and MYLIBpic) that depend on the same source: SET(MYPROJECT_SRCS MyFile.hh MyFile.cc)

MyFile.hh is generated by a ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...) SET_SOURCE_FILE_PROPERTIES(MyFile.hh GENERATED TRUE HEADER_FILE_ONLY TRUE)

When two targets MYLIB and MYLIBpic are build in parallel, they both try to generate MyFile.hh without checking that MyFile.hh is already being generated by someone else.

So sometimes I end up with MyFile.hh where each line appears two times. Sometimes, #endif appears in the middle of the file, etc.

Denis

--- On Thu, 11/18/10, Marcel Loose <loose at astron.nl> wrote:

> Hi Denis,
> 
> If you have two different build directories, which you need
> to have
> anyway when compiling with and without -fPIC, then you
> shouldn't have a
> problem, as long as you generate those header files in the
> build
> directory, which is IMHO the only sensible place to put
> generated files
> (your source tree might even be read-only!). Or maybe I
> completely
> misunderstood your question.
> 
> Best regards,
> Marcel Loose.


      


More information about the CMake mailing list