Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake ExternalProject_Add and parallel builds

With the following CMakeLists.txt build script:

include( ExternalProject )
ExternalProject_Add( framework SOURCE_DIR ${framework_SOURCE}
                     PREFIX framework_build
                     INSTALL_DIR ${framework_DISTRIBUTION} )

    ...

add_library( ${PROJECT_NAME} SHARED ${BUILD_MANIFEST} )
add_dependencies( ${PROJECT_NAME} framework )

When I attempt to perform a parallel build (make -j5) it will occasionally fail due to a build artefact from the framework not being present. The order of the build, fixed by add_dependencies, is not being adhered to.

Have I misunderstood the documentation around add_dependencies?

Output from cmake --graphviz=graph.dot

enter image description here

like image 855
Ben Crowhurst Avatar asked Jul 04 '15 16:07

Ben Crowhurst


1 Answers

Ok, so an updated version of CMake has warned me that the framework dependency is not present. ExternalProject_Add and add_dependencies can not be used with each other, as ExternalProject_Add has not actually built and therefore registered the framework as a high-level target.

Note: Anyone encountering this problem in future. I've found another SO post by @matiu that resolved my issue.

like image 84
Ben Crowhurst Avatar answered Oct 03 '22 04:10

Ben Crowhurst