[CMake] Generating multiple targets in parallel generates common prerequisites twice

Rolf Eike Beer eike at sf-mail.de
Wed Jan 8 04:00:21 EST 2014


Am 08.01.2014 09:42, schrieb Martin Apel:
> Hi all,
> 
> I hope this question hasn't been asked before, I haven't found
> anything useful in the archive.
> 
> Assume I have the following small CMakeLists.txt file:
> 
> CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
> PROJECT(testCMakeDeps)
> 
> ADD_LIBRARY(foo SHARED foo.cpp)
> ADD_LIBRARY(bar SHARED bar.cpp)
> 
> ADD_EXECUTABLE(test test.cpp)
> TARGET_LINK_LIBRARIES(test foo bar)
> 
> ADD_EXECUTABLE(test2 test2.cpp)
> TARGET_LINK_LIBRARIES(test2 foo bar)
> 
> This creates two executables, which both depend on the same two shared
> libraries. When generating a Makefile for this on Linux,
> one can start the compilation process via 'make -j2 test test2', i.e.
> name two separate targets on the command line.
> However CMake seems to generate a Makefile, which does not work
> correctly in this case. The shared libraries are generated twice.
> This seems to be a CMake issue, not a Make issue, I can write a
> Makefile by hand, which works correctly in this case.
> Is there any way around the duplicate generation (which sometimes
> fails, because the same libraries may be generated simultaneously)?

Could you please try a CMake version from the next branch, I think that 
this has been fixed recently.

Eike


More information about the CMake mailing list