ExternalProject_Add: steps may execute multiple times in parallel build
Consider following CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(proj LANGUAGES)
include(ExternalProject)
ExternalProject_Add(proj
SOURCE_DIR "."
CONFIGURE_COMMAND
COMMAND ${CMAKE_COMMAND} -E echo "Running CONFIGURE_COMMAND"
BUILD_COMMAND
COMMAND ${CMAKE_COMMAND} -E echo "Running BUILD_COMMAND"
INSTALL_COMMAND
COMMAND ${CMAKE_COMMAND} -E echo "Running INSTALL_COMMAND"
)
ExternalProject_Add_StepTargets(proj build install)
add_custom_target(root_target)
add_dependencies(root_target proj-build proj-install)
The main point is that root_target
depends on both exposed StepTargets, proj-build
and proj-install
.
When I build this project (on Linux):
cmake .. && cmake --build . --target root_target -- -j
On Windows:
cmake -G "Visual Studio 14 2015" .. && cmake --build . --target root_target -- /m:8
I get multiple "Running CONFIGURE_COMMAND" and/or "Running BUILD_COMMAND" messages, meaning that CMake calls some COMMANDs multiple times in parallel, which may potentially break the build.
Is this a bug or did I miss something in the documentation?
My CMake version is 3.13.0-rc3.