From c63dfb0fd3345ecb33014612f94d3959f147be03 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Fri, 29 Jul 2022 07:20:11 -0500 Subject: fortran module folder from GH#1411 #1922 (#1943) --- config/cmake_ext_mod/HDFMacros.cmake | 5 ++++- config/libhdf5.fpc.in | 16 ++++++++++++++++ configure.ac | 9 +++++++++ fortran/src/CMakeLists.txt | 11 ++++++----- fortran/src/Makefile.am | 8 ++++---- fortran/src/h5fc.in | 3 ++- hl/fortran/src/CMakeLists.txt | 11 ++++++----- hl/fortran/src/Makefile.am | 8 ++++---- release_docs/INSTALL_CMake.txt | 12 ++++++++++++ release_docs/RELEASE.txt | 16 +++++++++++++++- 10 files changed, 78 insertions(+), 21 deletions(-) create mode 100644 config/libhdf5.fpc.in diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index 260fd55..6f517bd 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -344,6 +344,9 @@ macro (HDF_DIR_PATHS package_prefix) if (NOT ${package_prefix}_INSTALL_INCLUDE_DIR) set (${package_prefix}_INSTALL_INCLUDE_DIR include) endif () + if (NOT ${package_prefix}_INSTALL_MODULE_DIR) + set (${package_prefix}_INSTALL_MODULE_DIR mod) + endif () if (NOT ${package_prefix}_INSTALL_DATA_DIR) if (NOT MSVC) if (APPLE) @@ -412,7 +415,7 @@ macro (HDF_DIR_PATHS package_prefix) ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries." ) set (CMAKE_Fortran_MODULE_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all fortran modules." + ${PROJECT_BINARY_DIR}/mod CACHE PATH "Single Directory for all fortran modules." ) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) diff --git a/config/libhdf5.fpc.in b/config/libhdf5.fpc.in new file mode 100644 index 0000000..c28c2f9 --- /dev/null +++ b/config/libhdf5.fpc.in @@ -0,0 +1,16 @@ +prefix=@_PKG_CONFIG_PREFIX@ +exec_prefix=@_PKG_CONFIG_EXEC_PREFIX@ +libdir=@_PKG_CONFIG_LIBDIR@ +includedir=@_PKG_CONFIG_INCLUDEDIR@ +moddir=@_PKG_CONFIG_MODULEDIR@ + +Name: @_PKG_CONFIG_LIBNAME@ +Description: HDF5 (Hierarchical Data Format 5) Software Library +Version: @_PKG_CONFIG_VERSION@ + +Cflags: -I${includedir} +Fflags: -I${moddir} +Libs: -L${libdir} @_PKG_CONFIG_SH_LIBS@ +Requires: @_PKG_CONFIG_REQUIRES@ +Libs.private: @_PKG_CONFIG_LIBS_PRIVATE@ @_PKG_CONFIG_LIBS@ +Requires.private: @_PKG_CONFIG_REQUIRES_PRIVATE@ diff --git a/configure.ac b/configure.ac index dd4f8c8..d59409b 100644 --- a/configure.ac +++ b/configure.ac @@ -160,6 +160,8 @@ AM_JNIFLAGS="${AM_JNIFLAGS}" AM_JAVACFLAGS="${AM_JAVACFLAGS}" AM_JAVAFLAGS="${AM_JAVAFLAGS}" AM_LDFLAGS="${AM_LDFLAGS}" + +## Flags passed in by the user CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" FCFLAGS="${FCFLAGS}" @@ -615,6 +617,13 @@ if test "X$HDF_FORTRAN" = "Xyes"; then AC_PROG_FC([PAC_FC_SEARCH_LIST],) AC_F9X_MODS + ## Allow setting the fortran module install dir + AC_ARG_WITH([fmoddir], + [AS_HELP_STRING([--with-fmoddir=DIR], [Fortran module install directory])], + [fmoddir=$withval], + [fmoddir="\${includedir}"]) + AC_SUBST([fmoddir], [$fmoddir]) + ## Change to the Fortran 90 language AC_LANG_PUSH(Fortran) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index bf64b55..b3a3b7f 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -319,7 +319,7 @@ if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES}) target_include_directories (${HDF5_F90_LIB_TARGET} PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE "$/include/static>" + INTERFACE "$/${HDF5_INSTALL_MODULE_DIR}/static>" ) target_compile_options(${HDF5_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIB_TARGET} @@ -353,7 +353,7 @@ if (BUILD_SHARED_LIBS) add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) target_include_directories (${HDF5_F90_LIBSH_TARGET} PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE "$/include/shared>" + INTERFACE "$/${HDF5_INSTALL_MODULE_DIR}/shared>" ) target_compile_options(${HDF5_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIBSH_TARGET} @@ -445,7 +445,7 @@ if (NOT ONLY_SHARED_LIBS) FILES ${mod_files} DESTINATION - ${HDF5_INSTALL_INCLUDE_DIR}/static + ${HDF5_INSTALL_MODULE_DIR}/static COMPONENT fortheaders ) @@ -487,7 +487,7 @@ if (BUILD_SHARED_LIBS) FILES ${modsh_files} DESTINATION - ${HDF5_INSTALL_INCLUDE_DIR}/shared + ${HDF5_INSTALL_MODULE_DIR}/shared COMPONENT fortheaders ) @@ -536,6 +536,7 @@ set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_MODULEDIR \${prefix}/mod) set (_PKG_CONFIG_LIBNAME "${HDF5_F90_LIB_CORENAME}") set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") @@ -552,7 +553,7 @@ set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF_CONFIG_DIR}/libhdf5.fpc.in ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_F90_LIB_CORENAME}.pc @ONLY ) diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index 20dcedf..9cb4315 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -22,7 +22,7 @@ include $(top_srcdir)/config/lt_vers.am # Include src directory in both Fortran and C flags (C compiler is used # for linking). AM_CPPFLAGS+=-I$(top_srcdir)/src -AM_FCFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/fortran/src +AM_FCFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/fortran/src $(F9XMODFLAG)$(fmoddir) AM_FCLIBS=$(LIBHDF5) @@ -72,15 +72,15 @@ clean-local: install-data-local: @if test -n "$(F9XMODEXT)" && test "X$(F9XMODEXT)" != "Xo"; then \ - $(CP) $(top_builddir)/$(subdir)/*.$(F9XMODEXT) $(DESTDIR)$(includedir)/. ; \ + $(CP) $(top_builddir)/$(subdir)/*.$(F9XMODEXT) $(DESTDIR)$(fmoddir)/. ; \ fi $(CP) $(top_builddir)/$(subdir)/H5f90i_gen.h $(DESTDIR)$(includedir)/. $(CP) $(top_srcdir)/fortran/src/H5f90i.h $(DESTDIR)$(includedir)/. uninstall-local: @if test -n "$(F9XMODEXT)" -a "X$(F9XMODEXT)" != "Xo"; then \ - if test -f "$(includedir)/hdf5.$(F9XMODEXT)" -o -f "$(includedir)/HDF5.$(F9XMODEXT)"; then \ - set -x; $(RM) $(DESTDIR)$(includedir)/*.$(F9XMODEXT); \ + if test -f "$(fmoddir)/hdf5.$(F9XMODEXT)" -o -f "$(fmoddir)/HDF5.$(F9XMODEXT)"; then \ + set -x; $(RM) $(DESTDIR)$(fmoddir)/*.$(F9XMODEXT); \ fi; \ fi; \ $(RM) $(DESTDIR)$(bindir)/$(H5FC_NAME) diff --git a/fortran/src/h5fc.in b/fortran/src/h5fc.in index 79401f8..d9fc1f5 100644 --- a/fortran/src/h5fc.in +++ b/fortran/src/h5fc.in @@ -26,6 +26,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" includedir="@includedir@" +fmoddir="@fmoddir@" HL="@HL@" ############################################################################ @@ -278,7 +279,7 @@ done # It's possible that there isn't a modules flag... fmodules="" if test -n "$F9XMODFLAG"; then - fmodules="${F9XMODFLAG}${includedir}" + fmodules="${F9XMODFLAG}${fmoddir}" fi if test "x$do_compile" = "xyes"; then diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 973299f..4413424 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -173,7 +173,7 @@ if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES}) target_include_directories (${HDF5_HL_F90_LIB_TARGET} PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE "$/include/static>" + INTERFACE "$/${HDF5_INSTALL_MODULE_DIR}/static>" ) target_compile_options(${HDF5_HL_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIB_TARGET} @@ -200,7 +200,7 @@ if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) target_include_directories (${HDF5_HL_F90_LIBSH_TARGET} PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE "$/include/shared>" + INTERFACE "$/${HDF5_INSTALL_MODULE_DIR}/shared>" ) target_compile_options(${HDF5_HL_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIBSH_TARGET} @@ -249,7 +249,7 @@ if (NOT ONLY_SHARED_LIBS) FILES ${mod_files} DESTINATION - ${HDF5_INSTALL_INCLUDE_DIR}/static + ${HDF5_INSTALL_MODULE_DIR}/static COMPONENT fortheaders ) @@ -277,7 +277,7 @@ if (BUILD_SHARED_LIBS) FILES ${modsh_files} DESTINATION - ${HDF5_INSTALL_INCLUDE_DIR}/shared + ${HDF5_INSTALL_MODULE_DIR}/shared COMPONENT fortheaders ) @@ -326,6 +326,7 @@ set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_MODULEDIR \${prefix}/mod) set (_PKG_CONFIG_LIBNAME "${HDF5_HL_F90_LIB_CORENAME}") set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") @@ -342,7 +343,7 @@ set (_PKG_CONFIG_REQUIRES "${HDF5_F90_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_F90_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF_CONFIG_DIR}/libhdf5.fpc.in ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_F90_LIB_CORENAME}.pc @ONLY ) diff --git a/hl/fortran/src/Makefile.am b/hl/fortran/src/Makefile.am index d1ca804..ca4ea64 100644 --- a/hl/fortran/src/Makefile.am +++ b/hl/fortran/src/Makefile.am @@ -22,7 +22,7 @@ include $(top_srcdir)/config/lt_vers.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src -AM_FCFLAGS+=-I$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/src +AM_FCFLAGS+=-I$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/src $(F9XMODFLAG)$(fmoddir) # Our main target, the high-level fortran library lib_LTLIBRARIES=libhdf5hl_fortran.la @@ -78,13 +78,13 @@ clean-local: install-data-local: @if test -n "$(F9XMODEXT)" && test "X$(F9XMODEXT)" != "Xo"; then \ - $(CP) $(top_builddir)/$(subdir)/*.$(F9XMODEXT) $(DESTDIR)$(includedir)/. ; \ + $(CP) $(top_builddir)/$(subdir)/*.$(F9XMODEXT) $(DESTDIR)$(fmoddir)/. ; \ fi uninstall-local: @if test -n "$(F9XMODEXT)" -a "X$(F9XMODEXT)" != "Xo"; then \ - if test -f "$(includedir)/hdf5.$(F9XMODEXT)" -o -f "$(DESTDIR)$(includedir)/HDF5.$(F9XMODEXT)"; then \ - set -x; $(RM) $(includedir)/*.$(F9XMODEXT); \ + if test -f "$(fmoddir)/hdf5.$(F9XMODEXT)" -o -f "$(DESTDIR)$(fmoddir)/HDF5.$(F9XMODEXT)"; then \ + set -x; $(RM) $(fmoddir)/*.$(F9XMODEXT); \ fi; \ fi $(RM) $(DESTDIR)$(libdir)/libhdf5_hl_fortran* diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index 684e3c4..3587510 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -742,6 +742,18 @@ HDF5_BUILD_HL_LIB "Build HIGH Level HDF5 Library" ON HDF5_BUILD_TOOLS "Build HDF5 Tools" ON HDF5_BUILD_HL_TOOLS "Build HIGH Level HDF5 Tools" ON +---------------- HDF5 Folder Build Options --------------------- +Defaults relative to $ +HDF5_INSTALL_BIN_DIR "bin" +HDF5_INSTALL_LIB_DIR "lib" +HDF5_INSTALL_INCLUDE_DIR "include" +HDF5_INSTALL_MODULE_DIR "mod" +HDF5_INSTALL_CMAKE_DIR "cmake" +if (MSVC) + HDF5_INSTALL_DATA_DIR "." +else () + HDF5_INSTALL_DATA_DIR "share" + ---------------- HDF5 Advanced Options --------------------- ONLY_SHARED_LIBS "Only Build Shared Libraries" OFF ALLOW_UNSUPPORTED "Allow unsupported combinations of configure options" OFF diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 75f56bc..08cec29 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -49,7 +49,21 @@ New Features Configuration: ------------- - - + - Correct the usage of CMAKE_Fortran_MODULE_DIRECTORY and where to + install Fortran mod files. + + The Fortran modules files, ending in .mod are files describing a + Fortran 90 (and above) module API and ABI. These are not like C + header files describing an API, they are compiler dependent and + arch dependent, and not easily readable by a human being. They are + nevertheless searched for in the includes directories by gfortran + (in directories specified with -I). + + Autotools configure uses the -fmoddir option to specify the folder. + CMake will use "mod" folder by default unless overridden by the CMake + variable; HDF5_INSTALL_MODULE_DIR. + + (ADB - 2022/07/21) Library: -- cgit v0.12