Skip to content

Commit 4a040bb

Browse files
Explicitly specify ADIOS2 components in openPMDConfig.cmake (#1693)
* Explicitly specify ADIOS2 components in openPMDConfig.cmake When including openPMD in downstream CMake and that CMake script contains Fortran, ADIOS2 will automatically detect that. But since we do not reexport the ADIOS2 headers, we only need the components that openPMD explicitly uses: CXX and MPI. * Same in CMakeLists.txt
1 parent 67c95fc commit 4a040bb

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,20 +360,24 @@ if(openPMD_HDF5_STATUS)
360360
endif()
361361

362362
# external library: ADIOS2 (optional)
363+
set(openPMD_REQUIRED_ADIOS2_COMPONENTS CXX)
364+
if(openPMD_HAVE_MPI)
365+
list(APPEND openPMD_REQUIRED_ADIOS2_COMPONENTS MPI)
366+
endif()
363367
if(openPMD_USE_ADIOS2 STREQUAL AUTO)
364-
find_package(ADIOS2 2.7.0 CONFIG)
368+
find_package(ADIOS2 2.7.0 CONFIG COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
365369
if(ADIOS2_FOUND)
366370
set(openPMD_HAVE_ADIOS2 TRUE)
367371
else()
368372
set(openPMD_HAVE_ADIOS2 FALSE)
369373
endif()
370374
elseif(openPMD_USE_ADIOS2)
371-
find_package(ADIOS2 2.7.0 REQUIRED CONFIG)
375+
find_package(ADIOS2 2.7.0 REQUIRED CONFIG COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
372376
set(openPMD_HAVE_ADIOS2 TRUE)
373377
else()
374378
set(openPMD_HAVE_ADIOS2 FALSE)
375379
endif()
376-
# TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON
380+
unset(openPMD_REQUIRED_ADIOS2_COMPONENTS)
377381

378382
# external library: pybind11 (optional)
379383
include(${openPMD_SOURCE_DIR}/cmake/dependencies/pybind11.cmake)

openPMDConfig.cmake.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ set(openPMD_HDF5_FOUND ${openPMD_HAVE_HDF5})
3131

3232
set(openPMD_HAVE_ADIOS2 @openPMD_HAVE_ADIOS2@)
3333
if(openPMD_HAVE_ADIOS2)
34-
find_dependency(ADIOS2)
34+
set(openPMD_REQUIRED_ADIOS2_COMPONENTS CXX)
35+
if(openPMD_HAVE_MPI)
36+
LIST(APPEND openPMD_REQUIRED_ADIOS2_COMPONENTS MPI)
37+
endif()
38+
find_dependency(ADIOS2 COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
39+
unset(openPMD_REQUIRED_ADIOS2_COMPONENTS)
3540
endif()
3641
set(openPMD_ADIOS2_FOUND ${openPMD_HAVE_ADIOS2})
3742

0 commit comments

Comments
 (0)