ExternalProject: Problems with install stage
I'm using ExternalProject_Add to build the same source code with multiple configurations.
This is what my top level CMakeLists file looks like.
cmake_minimum_required(VERSION 3.19.0)
project(PROJ NONE)
if(${PROJECT_NAME}_BUILD_ONE_CONFIG)
enable_testing()
add_subdirectory(3rdparty)
add_subdirectory(main)
add_subdirectory(plugins)
else()
message("Configuring external project")
include(ExternalProject)
macro(setup TOOLCHAIN BUILD_TYPE)
ExternalProject_Add(${TOOLCHAIN}_${BUILD_TYPE}
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
CMAKE_ARGS
-DCMAKE_TOOLCHAIN_FILE=toolchains/${TOOLCHAIN}.cmake
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-D${PROJECT_NAME}_BUILD_ONE_CONFIG=ON
)
endmacro()
setup(windows_x86 Release)
setup(windows_x86 Debug)
setup(windows_x86_64 Release)
setup(windows_x86_64 Debug)
setup(linux_x86_64 Release)
setup(linux_x86_64 Debug)
setup(linux_aarch64 Release)
setup(linux_aarch64 Debug)
endif()
When invoking like such:
cmake.exe -GNinja -S D:\builds\ -B D:\builds\cmake-build
cmake.exe --build D:\builds\cmake-build
The installation step for each ExternalProject is invoked, even though I did not run
cmake.exe --install D:\builds\cmake-build
Then, if I go to the installation destination, and delete several files from any and/or all of the ExternalProject configurations, and run "ninja", nothing happens. The installation is not re-performed.
Running, e.g. "ninja linux_x86_64_Release" does nothing. Running "linux_x86_64_Release-prefix\src\linux_x86_64_Release-stamp\linux_x86_64_Release-install" does nothing.
I wish for:
- External projects properly detect that their installation artifacts aren't correct and re-install as necessary, when the top-level project runs "ninja install".
- External projects do not run their installation during the build step unless requested, and instead run installation during the top-level project's install step.
Edited by Brad King