[CMake] ExternalProject_Add, dependencies and Make
Ben Pope
benpope81 at gmail.com
Thu Jul 4 03:08:13 EDT 2013
On 04/07/13 04:15, Brad King wrote:
> On 07/02/2013 11:59 PM, Ben Pope wrote:
>> I've got a number of libraries I depend on, I use ExternalProject_Add to
>> ./configure and build them, I set the DEPENDS field to another
>> ExternalProject_Add target.
>
> We do this commonly and use "make -j" to build multiple external
> projects in parallel subject to their dependencies. The DEPENDS
> option should say "bring the dependency completely up to date
> before starting to build the dependent".
>
> Can you post an example CMakeLists.txt, along with the cmake and
> make command lines you use to build it?
Yeah, I figured out what caused it and how to fix it:
*****
cmake_minimum_required (VERSION 2.8)
project(parallel_build_test)
include (ExternalProject)
ExternalProject_Add(parallel
DOWNLOAD_COMMAND sleep 1
CONFIGURE_COMMAND sleep 1
BUILD_COMMAND sleep 1
INSTALL_COMMAND touch parallel
)
ExternalProject_Add(depends1
DOWNLOAD_COMMAND sleep 1
CONFIGURE_COMMAND sleep 1
BUILD_COMMAND sleep 1
INSTALL_COMMAND touch depends1
DEPENDS parallel
)
ExternalProject_Add(project1
DOWNLOAD_COMMAND sleep 1
CONFIGURE_COMMAND sleep 1
BUILD_COMMAND sleep 1
INSTALL_COMMAND touch project1
DEPENDS depends1
)
ExternalProject_Add(depends2
DOWNLOAD_COMMAND sleep 1
CONFIGURE_COMMAND sleep 1
BUILD_COMMAND sleep 1
INSTALL_COMMAND touch depends2
DEPENDS parallel
)
ExternalProject_Add(project2
DOWNLOAD_COMMAND sleep 1
CONFIGURE_COMMAND sleep 1
BUILD_COMMAND sleep 1
INSTALL_COMMAND touch project2
DEPENDS depends2
)
add_custom_target(build_stuff
DEPENDS project1 project2
)
*****
make -j project1 project2 # BROKEN (also reaches 158% complete :P)
make -j build_stuff # fine
The only problem now is that the output is interleaved, I might see
something like:
[ 78%] [ 78%] [ 80%] [ 80%] [ 80%] [ 81%] Building....
But I guess that's for performance reasons?
Ben
More information about the CMake
mailing list