summaryrefslogtreecommitdiffstats
path: root/fortran/examples
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/examples')
-rw-r--r--fortran/examples/CMakeLists.txt103
-rw-r--r--fortran/examples/Makefile.am4
-rw-r--r--fortran/examples/Makefile.in8
-rw-r--r--fortran/examples/run-fortran-ex.sh.in30
4 files changed, 82 insertions, 63 deletions
diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt
index aa702ff..02a71c3 100644
--- a/fortran/examples/CMakeLists.txt
+++ b/fortran/examples/CMakeLists.txt
@@ -35,28 +35,22 @@ set (F2003_examples
foreach (example ${examples})
add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
- target_compile_options(f90_ex_${example}
- PRIVATE
- $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>
- )
-# set_property(TARGET f90_ex_${example} APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
-# )
-# set_property(TARGET f90_ex_${example} APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>
-# )
+ target_compile_options(f90_ex_${example} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>)
+# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">)
+# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>)
if(MSVC)
set_property(TARGET f90_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
endif()
if (NOT BUILD_SHARED_LIBS)
target_include_directories (f90_ex_${example}
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static"
- )
- target_link_libraries (f90_ex_${example}
- PRIVATE
- ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/static"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/static"
)
+ target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (f90_ex_${example} PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran
@@ -65,12 +59,13 @@ foreach (example ${examples})
else ()
target_include_directories (f90_ex_${example}
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared"
- )
- target_link_libraries (f90_ex_${example}
- PRIVATE
- ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/shared"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/shared"
)
+ target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (f90_ex_${example} PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran
@@ -81,28 +76,22 @@ endforeach ()
foreach (example ${F2003_examples})
add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
- target_compile_options(f03_ex_${example}
- PRIVATE
- $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>
- )
-# set_property(TARGET f03_ex_${example} APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
-# )
-# set_property(TARGET f03_ex_${example} APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>
-# )
+ target_compile_options(f03_ex_${example} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>)
+# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">)
+# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>)
if(MSVC)
set_property(TARGET f03_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
endif()
if (NOT ONLY_SHARED_LIBS)
target_include_directories (f03_ex_${example}
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static"
- )
- target_link_libraries (f03_ex_${example}
- PRIVATE
- ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/static"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/static"
)
+ target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (f03_ex_${example} PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran03
@@ -111,12 +100,13 @@ foreach (example ${F2003_examples})
else ()
target_include_directories (f03_ex_${example}
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared"
- )
- target_link_libraries (f03_ex_${example}
- PRIVATE
- ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/shared"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/shared"
)
+ target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (f03_ex_${example} PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran03
@@ -127,27 +117,26 @@ endforeach ()
if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90)
- target_compile_options(f90_ex_ph5example
- PRIVATE
- $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>
- )
-# set_property(TARGET f90_ex_ph5example APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
-# )
-# set_property(TARGET f90_ex_ph5example APPEND PROPERTY
-# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>
-# )
+ target_compile_options(f90_ex_ph5example PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>)
+# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">)
+# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>)
if(MSVC)
set_property(TARGET f90_ex_ph5example PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
endif()
if (NOT ONLY_SHARED_LIBS)
target_include_directories (f90_ex_ph5example
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/static"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/static"
+ "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
)
target_link_libraries (f90_ex_ph5example
PRIVATE
- ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}
+ ${HDF5_F90_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>
)
set_target_properties (f90_ex_ph5example PROPERTIES
@@ -158,11 +147,17 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
else ()
target_include_directories (f90_ex_ph5example
PRIVATE
- "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
+ "${CMAKE_Fortran_MODULE_DIRECTORY}/shared"
+ "${HDF5_SRC_DIR}"
+ "${HDF5_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}"
+ "${HDF5_F90_BINARY_DIR}/shared"
+ "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
)
target_link_libraries (f90_ex_ph5example
PRIVATE
- ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}
+ ${HDF5_F90_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>
)
set_target_properties (f90_ex_ph5example PROPERTIES
diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am
index d78cbb3..a2d322f 100644
--- a/fortran/examples/Makefile.am
+++ b/fortran/examples/Makefile.am
@@ -76,8 +76,8 @@ endif
# Tell automake how to install examples
# Note: no '/' after DESTDIR. Explanation in commence.am
-EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran
-EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples
+EXAMPLEDIR=$(examplesdir)/fortran
+EXAMPLETOPDIR=$(examplesdir)
# List dependencies for each example. Normally, automake would take
# care of this for us, but if we tell automake about the programs it
diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in
index 24baa4e..eeea786 100644
--- a/fortran/examples/Makefile.in
+++ b/fortran/examples/Makefile.in
@@ -361,7 +361,7 @@ AMTAR = @AMTAR@
# AM_CFLAGS is an automake construct which should be used by Makefiles
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@
AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -423,6 +423,7 @@ GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
+H5_ECFLAGS = @H5_ECFLAGS@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
H5_LDFLAGS = @H5_LDFLAGS@
@@ -542,6 +543,7 @@ docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
+examplesdir = @examplesdir@
exec_prefix = @exec_prefix@
fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
@@ -654,8 +656,8 @@ FORTRAN_API = yes
# Tell automake how to install examples
# Note: no '/' after DESTDIR. Explanation in commence.am
-EXAMPLEDIR = ${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran
-EXAMPLETOPDIR = ${DESTDIR}$(exec_prefix)/share/hdf5_examples
+EXAMPLEDIR = $(examplesdir)/fortran
+EXAMPLETOPDIR = $(examplesdir)
# Assume that all tests in this directory are examples, and tell
# conclude.am when to build them.
diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in
index 41bf9b1..b3585b6 100644
--- a/fortran/examples/run-fortran-ex.sh.in
+++ b/fortran/examples/run-fortran-ex.sh.in
@@ -18,7 +18,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This script will compile and run the fortran examples from source files #
-# installed in .../share/hdf5_examples/fortran using h5fc or h5pfc. The #
+# installed in @examplesdir@/fortran using h5fc or h5pfc. The #
# order for running programs with RunTest in the MAIN section below is taken #
# from the Makefile. The order is important since some of the test programs #
# use data files created by earlier test programs. Any future additions should #
@@ -30,9 +30,32 @@
EXIT_SUCCESS=0
EXIT_FAILURE=1
+#
+# Try to derive the path to the installation $prefix established
+# by ./configure relative to the examples directory established by
+# ./configure. If successful, set `prefix_relto_examplesdir` to the
+# relative path. Otherwise, set `prefix_relto_examplesdir` to the
+# absolute installation $prefix.
+#
+# This script uses the value of `prefix` in the user's environment, if
+# it is set, below. The content of $() is evaluated in a sub-shell, so
+# if `prefix` is set in the user's environment, the shell statements in
+# $() won't clobbered it.
+#
+prefix_relto_examplesdir=$(
+prefix=@prefix@
+examplesdir=@examplesdir@
+if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then
+ echo $(echo ${examplesdir##${prefix}/} | \
+ sed 's,[^/][^/]*,..,g')
+else
+ echo $prefix
+fi
+)
+
# Where the tool is installed.
# default is relative path to installed location of the tools
-prefix="${prefix:-../../../}"
+prefix="${prefix:-../${prefix_relto_examplesdir}}"
PARALLEL=@PARALLEL@ # Am I in parallel mode?
AR="@AR@"
RANLIB="@RANLIB@"
@@ -120,12 +143,11 @@ then
EXIT_VALUE=${EXIT_FAILURE}
fi
fi
-
# Cleanup
rm *.o
rm *.h5
echo
-exit $EXIT_VALUE
+exit $EXIT_VALUE