Skip to content

Commit a157b2d

Browse files
committed
Nested Superbuild Support
Dependent projects might have the same dependencies and build as a superbuild as well.
1 parent c04fe38 commit a157b2d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

CMakeLists.txt

+16-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ endif()
255255

256256

257257
# external library: nlohmann-json (required)
258-
if(openPMD_USE_INTERNAL_JSON)
258+
if(TARGET nlohmann_json::nlohmann_json)
259+
# nothing to do, target already exists in the superbuild
260+
message(STATUS "nlohmann_json::nlohmann_json target already imported")
261+
elseif(openPMD_USE_INTERNAL_JSON)
259262
set(JSON_BuildTests OFF CACHE INTERNAL "NLohmann JSON option defiend internally by openPMD")
260263
set(JSON_Install OFF CACHE INTERNAL "NLohmann JSON option defiend internally by openPMD") # only used PRIVATE
261264

@@ -285,7 +288,10 @@ target_link_libraries(openPMD::thirdparty::nlohmann_json
285288
INTERFACE nlohmann_json::nlohmann_json)
286289

287290
# external library: toml11
288-
if(openPMD_USE_INTERNAL_TOML11)
291+
if(TARGET toml11::toml11)
292+
# nothing to do, target already exists in the superbuild
293+
message(STATUS "toml11::toml11 target already imported")
294+
elseif(openPMD_USE_INTERNAL_TOML11)
289295
set(toml11_INSTALL OFF CACHE INTERNAL "toml11 option defined internally by openPMD")
290296

291297
# Git fetcher
@@ -440,7 +446,10 @@ else()
440446
set(openPMD_HAVE_PYTHON FALSE)
441447
endif()
442448
if(Python_FOUND)
443-
if(openPMD_USE_INTERNAL_PYBIND11)
449+
if(TARGET pybind11::module)
450+
# nothing to do, target already exists in the superbuild
451+
message(STATUS "pybind11::module target already imported")
452+
elseif(openPMD_USE_INTERNAL_PYBIND11)
444453
# Git fetcher
445454
set(openPMD_pybind11_repo "https://github.com/pybind/pybind11.git"
446455
CACHE STRING
@@ -589,7 +598,10 @@ target_include_directories(openPMD PUBLIC
589598

590599
# Catch2 for unit tests
591600
if(openPMD_BUILD_TESTING)
592-
if(openPMD_USE_INTERNAL_CATCH)
601+
if(TARGET Catch2::Catch2)
602+
# nothing to do, target already exists in the superbuild
603+
message(STATUS "Catch2::Catch2 target already imported")
604+
elseif(openPMD_USE_INTERNAL_CATCH)
593605
# Git fetcher
594606
set(openPMD_catch_repo "https://github.com/catchorg/Catch2.git"
595607
CACHE STRING

0 commit comments

Comments
 (0)