@@ -125,6 +125,11 @@ elseif(openPMD_USE_JSON)
125125else ()
126126 set (openPMD_HAVE_JSON FALSE )
127127endif ()
128+ if (openPMD_USE_JSON)
129+ add_library (openPMD::thirdparty::nlohmann_json INTERFACE IMPORTED )
130+ target_link_libraries (openPMD::thirdparty::nlohmann_json
131+ INTERFACE nlohmann_json::nlohmann_json )
132+ endif ()
128133
129134# external library: HDF5 (optional)
130135if (openPMD_USE_HDF5 STREQUAL AUTO)
@@ -265,6 +270,11 @@ elseif(openPMD_USE_PYTHON)
265270else ()
266271 set (openPMD_HAVE_PYTHON FALSE )
267272endif ()
273+ if (openPMD_HAVE_PYTHON)
274+ add_library (openPMD::thirdparty::pybind11 INTERFACE IMPORTED )
275+ target_link_libraries (openPMD::thirdparty::pybind11
276+ INTERFACE pybind11::pybind11 )
277+ endif ()
268278
269279
270280# Targets #####################################################################
@@ -330,26 +340,31 @@ target_include_directories(openPMD PUBLIC
330340)
331341
332342# C++11 std::variant (C++17 stdlib preview)
343+ add_library (openPMD::thirdparty::mpark_variant INTERFACE IMPORTED )
333344if (openPMD_USE_INTERNAL_VARIANT)
334- target_include_directories (openPMD SYSTEM PUBLIC
345+ target_include_directories (openPMD::thirdparty::mpark_variant SYSTEM INTERFACE
335346 $<BUILD_INTERFACE :${openPMD_SOURCE_DIR} /share /openPMD /thirdParty /variant /include >
336347 )
337348 message (STATUS "MPark.Variant: Using INTERNAL version 1.3.0" )
338349else ()
339350 find_package (mpark_variant 1.3.0 REQUIRED )
340- target_link_libraries (openPMD PUBLIC mpark_variant )
351+ target_link_libraries (openPMD::thirdparty::mpark_variant
352+ INTERFACE mpark_variant )
341353 message (STATUS "MPark.Variant: Found version ${mpark_variant_VERSION} " )
342354endif ()
343355
344356# Catch2 for unit tests
345357if (BUILD_TESTING)
358+ add_library (openPMD::thirdparty::Catch2 INTERFACE IMPORTED )
346359 if (openPMD_USE_INTERNAL_CATCH)
347- target_include_directories (openPMD SYSTEM PUBLIC
360+ target_include_directories (openPMD::thirdparty::Catch2 SYSTEM INTERFACE
348361 $<BUILD_INTERFACE :${openPMD_SOURCE_DIR} /share /openPMD /thirdParty /catch2 /include >
349362 )
350363 message (STATUS "Catch2: Using INTERNAL version 2.3.0" )
351364 else ()
352365 find_package (Catch2 2.3.0 CONFIG REQUIRED )
366+ target_link_libraries (openPMD::thirdparty::Catch2
367+ INTERFACE Catch2::Catch2 )
353368 message (STATUS "Catch2: Found version ${Catch2_VERSION} " )
354369 endif ()
355370endif ()
@@ -366,7 +381,7 @@ endif()
366381
367382# JSON Backend
368383if (openPMD_HAVE_JSON)
369- target_link_libraries (openPMD SYSTEM PRIVATE nlohmann_json ::nlohmann_json )
384+ target_link_libraries (openPMD PRIVATE openPMD::thirdparty ::nlohmann_json )
370385 target_compile_definitions (openPMD PUBLIC "-DopenPMD_HAVE_JSON=1" )
371386else ()
372387 target_compile_definitions (openPMD PUBLIC "-DopenPMD_HAVE_JSON=0" )
@@ -395,15 +410,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
395410 target_compile_options (openPMD.ADIOS1.Serial PUBLIC "/bigobj" )
396411 target_compile_options (openPMD.ADIOS1.Parallel PUBLIC "/bigobj" )
397412endif ()
398- if (openPMD_USE_INTERNAL_VARIANT)
399- target_include_directories (openPMD.ADIOS1.Serial SYSTEM PUBLIC
400- $<BUILD_INTERFACE :${openPMD_SOURCE_DIR} /share /openPMD /thirdParty /variant /include >)
401- target_include_directories (openPMD.ADIOS1.Parallel SYSTEM PUBLIC
402- $<BUILD_INTERFACE :${openPMD_SOURCE_DIR} /share /openPMD /thirdParty /variant /include >)
403- else ()
404- target_link_libraries (openPMD.ADIOS1.Serial PUBLIC mpark_variant )
405- target_link_libraries (openPMD.ADIOS1.Parallel PUBLIC mpark_variant )
406- endif ()
413+ target_link_libraries (openPMD.ADIOS1.Serial PUBLIC openPMD::thirdparty::mpark_variant )
414+ target_link_libraries (openPMD.ADIOS1.Parallel PUBLIC openPMD::thirdparty::mpark_variant )
407415
408416target_include_directories (openPMD.ADIOS1.Serial SYSTEM PRIVATE
409417 ${openPMD_SOURCE_DIR} /include )
@@ -613,9 +621,7 @@ if(BUILD_TESTING)
613621 target_compile_definitions (${testname} Tests PUBLIC "-DopenPMD_HAVE_ADIOS2=1" )
614622 endif ()
615623 target_link_libraries (${testname} Tests PRIVATE openPMD )
616- if (TARGET Catch2::Catch2)
617- target_link_libraries (${testname} Tests PRIVATE Catch2::Catch2 )
618- endif ()
624+ target_link_libraries (${testname} Tests PRIVATE openPMD::thirdparty::Catch2 )
619625 endforeach ()
620626endif ()
621627
0 commit comments