Skip to content

Commit

Permalink
Fix MPI support
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Jun 11, 2024
1 parent 15188ba commit 8345692
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ set(Wannier90_MPI ${WANNIER90_WITH_MPI})
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
if (WANNIER90_MPI)
find_package(MPI REQUIRED)
find_package(MPI REQUIRED COMPONENTS Fortran)
if (NOT MPI_Fortran_HAVE_F08_MODULE)
message(SEND_ERROR "mpi_f08 module is required for building Wannier90 with MPI")
endif ()
endif ()

#[=============================================================================[
Expand Down
16 changes: 16 additions & 0 deletions cmake/Wannier90Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@
## Define basic variables
set(Wannier90_MPI @WANNIER90_MPI@)

## Include dependencies
include(CMakeFindDependencyMacro)
if (Wannier90_MPI)
# Note: In the future the MPI support can be converted to an (optional) package component.
# This would however require a breaking change in the library definition
find_dependency(MPI COMPONENTS Fortran)
if (NOT MPI_Fortran_FOUND OR NOT MPI_Fortran_HAVE_F08_MODULE)
message(WARNING
"Wannier90 was built and packaged with MPI, but the system does not have compatible MPI support.\n"
"This is an issue with the packager of Wannier90."
)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif ()
endif ()

## Parse find_package request
include(${CMAKE_CURRENT_LIST_DIR}/Wannier90Targets.cmake)
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ target_sources(Wannier90_lib
${CMAKE_Fortran_MODULE_DIRECTORY}/w90_library.mod
)
if (WANNIER90_MPI)
target_link_libraries(Wannier90_lib PRIVATE MPI::MPI_Fortran)
target_link_libraries(Wannier90_lib PUBLIC MPI::MPI_Fortran)
target_compile_definitions(Wannier90_lib PRIVATE
MPI08 MPI
)
endif ()

add_subdirectory(postw90)
Expand Down

0 comments on commit 8345692

Please sign in to comment.