From the main CMakeLists.txt, set the environment variable containing the common root path for loading and building external projects, for example:
set (ENV EXTERNAL_PROJ_DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/externalProjects")
for use as root folders for downloading and creating dependencies. You can install (and use) it in your main project and read this value from your first dependency (one that also depends on your second dependency).
In practice, this applies to the project associated with your comments, you set EXTERNAL_PROJ_DOWNLOAD_DIR IN Khronos, and then for the link to PortAudio in the 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 can also use set (ENV EXTERNAL_PROJ_BINARY_DIR "${CMAKE_BINARY_DIR}/externalProjects") if you want to activate the source assembly.
I suggest using an environment variable because I don't know if the cache variable from Khronos to tritium will be displayed ...
See the documentation for set and env .
Antonio
source share