使用CMake构建外部项目时,jobserver不可用 [英] jobserver unavailable when building external projects with CMake
问题描述
我正在尝试使用ExternalProject_add
在Linux上使用CMake构建一些外部项目.但是,他们不遵守make -j12
命令,并发出警告:
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
)
推荐答案
为了允许make
命令正确传播到其子级,您需要在括号中使用$(MAKE)
(而不是大括号),而不是按照命令进行操作,即
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
从CMake 2.8.4版开始支持此功能.
This is supported from CMake version 2.8.4 onward.
这篇关于使用CMake构建外部项目时,jobserver不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!