parralelise ExternalProject

Hello,
I would like to parallel compile with ExternalProject_add. I use MSVC to compile (VSCODE)

the -J N option doesn’t compile in parallel inside externalProject.I tried to switch -jN to the CMAKE_ARGS option, but it doesn’t seem to work either.

EX1 :
cmake --build build -J8

EX2:
set(lib_name zlib)
set(lib_name_install ${CMAKE_CURRENT_SOURCE_DIR}/install/${BUILDNAME}/${lib_name})
if(BUILD_WITH_ZLIB)
set(git_repo https://github.com/madler/zlib)
set(git_tag v1.2.11)
message("[INFO] beginning compilation ${lib_name}")
externalproject_add(
${lib_name}
GIT_REPOSITORY ${git_repo}
GIT_TAG ${git_tag}
GIT_CONFIG http.proxy=${MY_PROXY} advice.detachedHead=false
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${lib_name}
INSTALL_DIR ${lib_name_install}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${lib_name_install}
-j8
# PATCH_COMMAND “remove zconfig.h”
)

CMAKE_ARGS is passed to the configure step, so -j8 isn’t very useful there. I think you might have to replace BUILD_COMMAND. Note that for Makefiles, $(MAKE) is used to pass along job server information and Ninja is parallel by default. I think replacing BUILD_COMMAND is all that’s available today in master for the IDE generators.

is it possible to have the default build_command like that : BUILD_COMMAND ${BUILD_COMMAND} -j9

externalproject_add(
${lib_name}
GIT_REPOSITORY ${git_repo}
GIT_TAG ${git_tag}
GIT_CONFIG http.proxy=${MY_PROXY} advice.detachedHead=false
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${lib_name}
INSTALL_DIR ${lib_name_install}
BUILD_COMMAND ${BUILD_COMMAND} -j9
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${lib_name_install}_$<$CONFIG:Debug:Debug>
-DBUILD_TESTING=OFF
# PATCH_COMMAND “remove zconfig.h”
)

Not really, no. I think you can ask what the build command is once you make it, but I think that’s it without more hoops. Making a feature request for something like a BUILD_ARGS would be useful for tracking such an addition though.

I see CMake Issue 21599 for this.