Is there a way to make an external dependency depend of two others external dependencies of a project ?
Here is my situation
- core depdends on boost_program_options and on quetzal
- quetzal depends on gdal and boost_filesystem and boost_unit_test_framework
How to orchestrate these dependencies ? I have been trying the following approach:
The root CMakelist.txt
contains:
list(APPEND BOOST_COMPONENTS_REQUIRED program_options)
add_subdirectory(external/upstream)
ExternalProject_Add(
${PROJECT_NAME}_core
DEPENDS
boost_external
gdal_external
quetzal_external
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/FTD_core
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_LIBRARY_PATH:PATH=${STAGED_INSTALL_PREFIX}
# Forward externals to the core project
-DCMAKE_INCLUDE_PATH:PATH=${BOOST_INCLUDEDIR}
-DCMAKE_LIBRARY_PATH:PATH=${BOOST_LIBRARYDIR}
-DCMAKE_INCLUDE_PATH:PATH=${GDAL_INCLUDE_DIR}
-DCMAKE_LIBRARY_PATH:PATH=${GDAL_LIBRARY}
-DCMAKE_INCLUDE_PATH:PATH=${QUETZAL_INCLUDE_DIR}
BUILD_ALWAYS
1
INSTALL_COMMAND
""
)
The external/upstream/quetzal/CMakeLists.txt
contains:
list(APPEND BOOST_COMPONENTS_REQUIRED unit_test_framework filesystem)
include(ExternalProject)
ExternalProject_Add(quetzal_external
DEPENDS
boost_external
gdal_external
GIT_REPOSITORY https://github.com/Becheler/quetzal.git
GIT_TAG master
CMAKE_ARGS
-DCMAKE_LIBRARY_PATH:PATH=${STAGED_INSTALL_PREFIX}
-DCMAKE_INCLUDE_PATH:PATH=${BOOST_INCLUDEDIR}
-DCMAKE_LIBRARY_PATH:PATH=${BOOST_LIBRARYDIR}
-DCMAKE_INCLUDE_PATH:PATH=${GDAL_INCLUDE_DIR}
-DCMAKE_LIBRARY_PATH:PATH=${GDAL_LIBRARY}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}
-DBUILD_TESTS=Off
UPDATE_COMMAND ""
)
external/upstream/boost/CMakeLists.txt
and external/upstream/gdal/CMakeLists.txt
seem to behave adequately. But for some reason external/upstream/quetzal/CMakeLists.txt
finds the system boost installation (1.71), when I want it to find the locally built boost installation (1.65).
I think something is wrong with my way to forward the boost dependency to the quetzal dependency, but I don't even know if the general approach is correct or not.