Skip to content

Commit

Permalink
Explicitly specify ADIOS2 components in openPMDConfig.cmake (#1693)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
franzpoeschel authored Nov 8, 2024
1 parent 67c95fc commit 4a040bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,20 +360,24 @@ if(openPMD_HDF5_STATUS)
endif()

# external library: ADIOS2 (optional)
set(openPMD_REQUIRED_ADIOS2_COMPONENTS CXX)
if(openPMD_HAVE_MPI)
list(APPEND openPMD_REQUIRED_ADIOS2_COMPONENTS MPI)
endif()
if(openPMD_USE_ADIOS2 STREQUAL AUTO)
find_package(ADIOS2 2.7.0 CONFIG)
find_package(ADIOS2 2.7.0 CONFIG COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
if(ADIOS2_FOUND)
set(openPMD_HAVE_ADIOS2 TRUE)
else()
set(openPMD_HAVE_ADIOS2 FALSE)
endif()
elseif(openPMD_USE_ADIOS2)
find_package(ADIOS2 2.7.0 REQUIRED CONFIG)
find_package(ADIOS2 2.7.0 REQUIRED CONFIG COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
set(openPMD_HAVE_ADIOS2 TRUE)
else()
set(openPMD_HAVE_ADIOS2 FALSE)
endif()
# TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON
unset(openPMD_REQUIRED_ADIOS2_COMPONENTS)

# external library: pybind11 (optional)
include(${openPMD_SOURCE_DIR}/cmake/dependencies/pybind11.cmake)
Expand Down
7 changes: 6 additions & 1 deletion openPMDConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ set(openPMD_HDF5_FOUND ${openPMD_HAVE_HDF5})

set(openPMD_HAVE_ADIOS2 @openPMD_HAVE_ADIOS2@)
if(openPMD_HAVE_ADIOS2)
find_dependency(ADIOS2)
set(openPMD_REQUIRED_ADIOS2_COMPONENTS CXX)
if(openPMD_HAVE_MPI)
LIST(APPEND openPMD_REQUIRED_ADIOS2_COMPONENTS MPI)
endif()
find_dependency(ADIOS2 COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS})
unset(openPMD_REQUIRED_ADIOS2_COMPONENTS)
endif()
set(openPMD_ADIOS2_FOUND ${openPMD_HAVE_ADIOS2})

Expand Down

0 comments on commit 4a040bb

Please sign in to comment.