diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-04-04 12:09:48 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2021-04-06 12:36:31 (GMT) |
commit | cd48433e96820c5e1d219696bb48174843e9c15b (patch) | |
tree | 8d2ded4457a48ad920b31b5fdbbf7d70e684f9f8 /Modules/FindHDF5.cmake | |
parent | 78287ec0af1eb5f968df09c8b4321dd56510a429 (diff) | |
download | CMake-cd48433e96820c5e1d219696bb48174843e9c15b.zip CMake-cd48433e96820c5e1d219696bb48174843e9c15b.tar.gz CMake-cd48433e96820c5e1d219696bb48174843e9c15b.tar.bz2 |
FindHDF5: add compiler-specific module search paths
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r-- | Modules/FindHDF5.cmake | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 7eec6de..e335355 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -865,8 +865,21 @@ if( NOT HDF5_FOUND ) list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_LIBRARIES}) # find the HDF5 include directories + set(_hdf5_inc_extra_paths) + set(_hdf5_inc_extra_suffixes) if("${_lang}" STREQUAL "Fortran") set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod) + + # Add library-based search paths for Fortran modules. + if (NOT _hdf5_main_library STREQUAL "") + # gfortran module directory + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + get_filename_component(_hdf5_library_dir "${_hdf5_main_library}" DIRECTORY) + list(APPEND _hdf5_inc_extra_paths "${_hdf5_library_dir}") + unset(_hdf5_library_dir) + list(APPEND _hdf5_inc_extra_suffixes gfortran/modules) + endif () + endif () elseif("${_lang}" STREQUAL "CXX") set(HDF5_INCLUDE_FILENAME H5Cpp.h) else() @@ -877,11 +890,13 @@ if( NOT HDF5_FOUND ) find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} + PATHS $ENV{HOME}/.local/include ${_hdf5_inc_extra_paths} + PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} ${_hdf5_inc_extra_suffixes} ${_HDF5_SEARCH_OPTS} ) mark_as_advanced(HDF5_${_lang}_INCLUDE_DIR) + unset(_hdf5_inc_extra_paths) + unset(_hdf5_inc_extra_suffixes) # set the _DIRS variable as this is what the user will normally use set(HDF5_${_lang}_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) |