From the main CMakeLists.txt, set an environment variable containing a common root path for downloading and building external projects, for example:
set (ENV EXTERNAL_PROJ_DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/externalProjects")
to be used as root folders for the download and the builds of the dependencies. You can set (and use) it in your main project, and read this value from within your first dependency (the one that also depends to your second dependency).
Seen it in practice applied to the project linked in your comments, you'll set EXTERNAL_PROJ_DOWNLOAD_DIR
IN Khronos, and then to link to PortAudio in both Khronos and tritium projects you will have:
find_package(PortAudio)
if (${PORTAUDIO_FOUND})
include_directories(${PORTAUDIO_INCLUDE_DIRS})
else ()
ExternalProject_Add(
PortAudio
GIT_REPOSITORY "https://github.com/syb0rg/PortAudio2.git"
SOURCE_DIR "$ENV{EXTERNAL_PROJ_DOWNLOAD_DIR}/PortAudio"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(PortAudio SOURCE_DIR)
ExternalProject_Get_Property(PortAudio BINARY_DIR)
set(PORTAUDIO_SOURCE_DIR ${SOURCE_DIR})
set(PORTAUDIO_BINARY_DIR ${BINARY_DIR})
set(PORTAUDIO_LIBRARIES ${PORTAUDIO_SOURCE_DIR}/libportaudio_static.a)
set(DEPENDENCIES ${DEPENDENCIES} PortAudio)
include_directories(${PORTAUDIO_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${PORTAUDIO_LIBRARIES})
You could also use set (ENV EXTERNAL_PROJ_BINARY_DIR "${CMAKE_BINARY_DIR}/externalProjects")
if you wanted to activate the out of source build.
I suggest to use an environment variable because I don't know if a cache variable set from Khronos would be visible in tritium...
See documentation for set and env.
ExternalProject
commands? I would first of all try to put a common DOWNLOAD_DIR and BUILD_DIR – PuerperiumPortAudio
is likeDependency_2
,tritium
is likeDependency_1
, andKhronos
is likeMainProject
. – Lindsy.c
files? Or the mainCMakeLists.txt
– LindsyExternalProject
use is. – Lindsy"${CMAKE_SOURCE_DIR}/externalProjects"
and"${CMAKE_BINARY_DIR}/externalProjects"
to be used as root folders for the download and the builds of the dependencies). You can set (and use) it in Khronos, and read this value from tritium. See docs set env. I don't know if a cache variable set from Khronos would be visible in tritium... – Puerperium