ExternalProject is just a sequence of steps to perform. So you may use two instances of it:
- ExternalProject_Add() call to be built at main project's configuration stage. E.g., as described in that question:
other_project/CMakeLists.txt:
project(other_project)
include(ExternalProject)
ExternalProject_Add(<project_name> <options...>
BUILD_COMMAND "" # Disable build step.
INSTALL_COMMAND "" # Disable install step too.
)
CMakeLists.txt:
# The first external project will be built at *configure stage*
execute_process(
COMMAND ${CMAKE_COMMAND} --build . ${CMAKE_SOURCE_DIR}/other_project
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/other_project
)
- ExternalProject_Add() call to be built at main project's build stage.
CMakeLists.txt:
# The second external project will be built at *build stage*
ExternalProject_Add(<project_name> <options...>
CONFIGURE_COMMAND "" # Disable configure step. But other steps will be generated.
)
By using same <options> for both ExternalProject_Add()
calls we achieve "preemption" of both external projects created: build and follow steps of the second project will use result of configure step of the first one.
ExternalProject
is just a sequence of steps. So you may use oneExternalProject_Add()
call for being built at main project's configuration stage (e.g., as described in that question), and secondExternalProject_Add()
call for being build at main's project build stage. But I don't understand how configured project may be used viafind_package()
: normally this requires project to be installed. – Ordinarilyfind_package(... CONFIG)
. – Circuitous*Config.cmake
from build tree may work in some cases. But only installed variant of this file is garanteed to work: the file may include other.cmake
files, which layout in build and install trees may differ. – Ordinarily