mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 05:39:57 -05:00
Merge topic 'FindHDF5-find-fortran-modules-automatically'
cd48433e96FindHDF5: add compiler-specific module search paths78287ec0afFindHDF5: track the "main" library for each language3654068e80FindHDF5: find include directories after the library Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5977
This commit is contained in:
+48
-19
@@ -811,25 +811,8 @@ if( NOT HDF5_FOUND )
|
||||
endif()
|
||||
|
||||
foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS)
|
||||
# find the HDF5 include directories
|
||||
if("${_lang}" STREQUAL "Fortran")
|
||||
set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod)
|
||||
elseif("${_lang}" STREQUAL "CXX")
|
||||
set(HDF5_INCLUDE_FILENAME H5Cpp.h)
|
||||
else()
|
||||
set(HDF5_INCLUDE_FILENAME hdf5.h)
|
||||
endif()
|
||||
|
||||
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}
|
||||
${_HDF5_SEARCH_OPTS}
|
||||
)
|
||||
mark_as_advanced(HDF5_${_lang}_INCLUDE_DIR)
|
||||
# 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})
|
||||
# The "main" library.
|
||||
set(_hdf5_main_library "")
|
||||
|
||||
# find the HDF5 libraries
|
||||
foreach(LIB IN LISTS HDF5_${_lang}_LIBRARY_NAMES)
|
||||
@@ -861,6 +844,15 @@ if( NOT HDF5_FOUND )
|
||||
${_HDF5_SEARCH_OPTS}
|
||||
)
|
||||
|
||||
# Set the "main" library if not already set.
|
||||
if (NOT _hdf5_main_library)
|
||||
if (HDF5_${LIB}_LIBRARY_RELEASE)
|
||||
set(_hdf5_main_library "${HDF5_${LIB}_LIBRARY_RELEASE}")
|
||||
elseif (HDF5_${LIB}_LIBRARY_DEBUG)
|
||||
set(_hdf5_main_library "${HDF5_${LIB}_LIBRARY_DEBUG}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
select_library_configurations( HDF5_${LIB} )
|
||||
list(APPEND HDF5_${_lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY})
|
||||
endforeach()
|
||||
@@ -872,6 +864,43 @@ if( NOT HDF5_FOUND )
|
||||
# required libraries.
|
||||
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()
|
||||
set(HDF5_INCLUDE_FILENAME hdf5.h)
|
||||
endif()
|
||||
|
||||
unset(_hdf5_main_library)
|
||||
|
||||
find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME}
|
||||
HINTS ${HDF5_ROOT}
|
||||
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})
|
||||
|
||||
if(HDF5_FIND_HL)
|
||||
foreach(LIB IN LISTS HDF5_${_lang}_HL_LIBRARY_NAMES)
|
||||
if(HDF5_USE_STATIC_LIBRARIES)
|
||||
|
||||
Reference in New Issue
Block a user