Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jobserver unavailable when building external projects with CMake

I'm trying to build some external projects with CMake on linux using ExternalProject_add. However, they aren't respecting the make -j12 command, and are giving the warning:

‘warning: jobserver unavailable: using -j1. Add `+' to parent make rule.’

This slows my build painfully. Is there some way to build external projects in parallel? Here's an example project:

include(ExternalProject)
    ExternalProject_Add(
        ${TARGET_NAME}-ext
        URL ${CMAKE_CURRENT_SOURCE_DIR}/xerces-c-${VERSION_XERCESC}.tar.gz
        DOWNLOAD_DIR ${XERCESC_DIR}
        SOURCE_DIR ${XERCESC_DIR}/src
        PATCH_COMMAND chmod guo+rw ${CMAKE_CURRENT_SOURCE_DIR} -R
        CONFIGURE_COMMAND ./configure --prefix=${XERCESC_DIR} --disable-shared -q --disable-network --enable-transcoder-gnuiconv --enable-msgloader-inmemory
        BUILD_COMMAND make --silent
        INSTALL_COMMAND make install
        BUILD_IN_SOURCE 1
    )
like image 809
Nicolas Holthaus Avatar asked Oct 16 '15 13:10

Nicolas Holthaus


1 Answers

In order to allow the make commands to properly propagate to their children, you need to use $(MAKE) with parenthesis (not curly-braces) instead of make as your command, i.e.

BUILD_COMMAND $(MAKE) --silent
INSTALL_COMMAND $(MAKE) install

This is supported from CMake version 2.8.4 onward.

like image 86
Nicolas Holthaus Avatar answered Sep 21 '22 06:09

Nicolas Holthaus