[CMake] Transitive library dependencies with parallel builds

Number Cruncher number.cruncher at ntlworld.com
Wed Feb 29 11:35:36 EST 2012


Do transitive dependencies reduce number of jobs that can be compiled in 
parallel?

If I have two libraries A and B, with an executable C, whose 
dependencies are described by:

   add_library(A ${A_SRC})

   add_library(B ${B_SRC})
   target_link_libraries(B A)

   add_executable(C ${C_SRC})
   target_link_libraries(C B)

I understand that when *linking* C, the transitive dependency A will be 
added. However, if I build C in parallel "make -j N", will CMake build 
libraries A and B simultaneously, or fully compile and link A before 
starting compilation of B? I.e. just because the link steps are serial 
dependencies, are the compilation steps? Would it be faster to do:

   add_library(A ${A_SRC})

   add_library(B ${B_SRC})

   add_executable(C ${C_SRC})
   target_link_libraries(C B A)

Thanks.


More information about the CMake mailing list