mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
* Fix MPI Fortran configuration for HDF5Examples (#6205) When building Fortran parallel examples standalone without MPI wrappers, the compiler cannot find mpi.mod because MPI_Fortran_INCLUDE_DIRS is not populated. * Use MPI::MPI_Fortran imported target instead of raw MPI variables Replace manual MPI_Fortran_LIBRARIES, MPI_Fortran_LINK_FLAGS, and MPI_Fortran_INCLUDE_DIRS usage with the MPI::MPI_Fortran imported target, which transitively carries all include dirs, compile flags, and link flags. This eliminates the CMAKE_Fortran_EXE_LINKER_FLAGS hack and the manual target_include_directories in H5PAR.
27 lines
953 B
CMake
27 lines
953 B
CMake
cmake_minimum_required (VERSION 3.26)
|
|
PROJECT (HDF5Examples_F90 Fortran)
|
|
|
|
# Parallel IO usage requires MPI to be linked and included
|
|
if (H5_HAVE_PARALLEL)
|
|
find_package(MPI REQUIRED COMPONENTS Fortran)
|
|
# Use imported target — carries include dirs, compile flags, and link flags transitively
|
|
list(APPEND H5EXAMPLE_LINK_Fortran_LIBS MPI::MPI_Fortran)
|
|
endif ()
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# Build the Fortran Examples
|
|
#-----------------------------------------------------------------------------
|
|
add_subdirectory (${PROJECT_SOURCE_DIR}/TUTR)
|
|
add_subdirectory (${PROJECT_SOURCE_DIR}/H5D)
|
|
add_subdirectory (${PROJECT_SOURCE_DIR}/H5G)
|
|
add_subdirectory (${PROJECT_SOURCE_DIR}/H5T)
|
|
|
|
if (H5_HAVE_PARALLEL AND HDF5_PROVIDES_PARALLEL)
|
|
add_subdirectory (${PROJECT_SOURCE_DIR}/H5PAR)
|
|
endif ()
|
|
|
|
#-- Add High Level Examples
|
|
if (H5EXAMPLE_BUILD_HL AND HDF5_PROVIDES_HL_LIB)
|
|
add_subdirectory (HL)
|
|
endif ()
|