From 53155f640b8fee58d36c407586db7c0a81f341a4 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 5 Sep 2024 12:52:09 -0700 Subject: [PATCH] Nested Superbuild Support Dependent projects might have the same dependencies and build as a superbuild as well. --- CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a7aa81d0b..1bd0ea23c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,7 +255,9 @@ endif() # external library: nlohmann-json (required) -if(openPMD_USE_INTERNAL_JSON) +if(TARGET nlohmann_json::nlohmann_json) + # nothing to do, target already exists in the superbuild +elseif(openPMD_USE_INTERNAL_JSON) set(JSON_BuildTests OFF CACHE INTERNAL "NLohmann JSON option defiend internally by openPMD") set(JSON_Install OFF CACHE INTERNAL "NLohmann JSON option defiend internally by openPMD") # only used PRIVATE @@ -285,7 +287,9 @@ target_link_libraries(openPMD::thirdparty::nlohmann_json INTERFACE nlohmann_json::nlohmann_json) # external library: toml11 -if(openPMD_USE_INTERNAL_TOML11) +if(TARGET toml11::toml11) + # nothing to do, target already exists in the superbuild +elseif(openPMD_USE_INTERNAL_TOML11) set(toml11_INSTALL OFF CACHE INTERNAL "toml11 option defined internally by openPMD") # Git fetcher @@ -440,7 +444,9 @@ else() set(openPMD_HAVE_PYTHON FALSE) endif() if(Python_FOUND) - if(openPMD_USE_INTERNAL_PYBIND11) + if(TARGET pybind11::module) + # nothing to do, target already exists in the superbuild + elseif(openPMD_USE_INTERNAL_PYBIND11) # Git fetcher set(openPMD_pybind11_repo "https://github.com/pybind/pybind11.git" CACHE STRING @@ -589,7 +595,9 @@ target_include_directories(openPMD PUBLIC # Catch2 for unit tests if(openPMD_BUILD_TESTING) - if(openPMD_USE_INTERNAL_CATCH) + if(TARGET Catch2::Catch2) + # nothing to do, target already exists in the superbuild + elseif(openPMD_USE_INTERNAL_CATCH) # Git fetcher set(openPMD_catch_repo "https://github.com/catchorg/Catch2.git" CACHE STRING