aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-01-30 23:41:15 -0500
committerMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-01-30 23:49:11 -0500
commit4d54a22b49b197bbb6a91aab3a67572b40b2f677 (patch)
tree353563d50adcb0a22e3035979980ca2e37b4c092
parent1ebaeadf60fd6f162e73ee3938e88cf72659a8a8 (diff)
downloadmeson-4d54a22b49b197bbb6a91aab3a67572b40b2f677.zip
meson-4d54a22b49b197bbb6a91aab3a67572b40b2f677.tar.gz
meson-4d54a22b49b197bbb6a91aab3a67572b40b2f677.tar.bz2
setup hdf5 test
deblank
-rw-r--r--ciimage/Dockerfile1
-rw-r--r--mesonbuild/dependencies/misc.py9
-rw-r--r--test cases/frameworks/25 hdf5/main.c32
-rw-r--r--test cases/frameworks/25 hdf5/main.cpp31
-rw-r--r--test cases/frameworks/25 hdf5/main.f9017
-rw-r--r--test cases/frameworks/25 hdf5/meson.build33
6 files changed, 119 insertions, 4 deletions
diff --git a/ciimage/Dockerfile b/ciimage/Dockerfile
index 520ce0f..980ed53 100644
--- a/ciimage/Dockerfile
+++ b/ciimage/Dockerfile
@@ -20,6 +20,7 @@ RUN sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list" \
&& apt-get -y install --no-install-recommends wine-stable \
&& apt-get -y install llvm-dev libclang-dev \
&& apt-get -y install libgcrypt11-dev \
+&& apt-get -y install libhdf5-dev \
&& dub fetch urld && dub build urld --compiler=gdc \
&& dub fetch dubtestproject \
&& dub build dubtestproject:test1 --compiler=ldc2 \
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index b9f8bb6..9968f43 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -57,16 +57,17 @@ class HDF5Dependency(ExternalDependency):
for larg in link_args:
lpath = Path(larg)
if lpath.is_file():
- if language == 'c':
- lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
- lang_link_args.append(larg)
- elif language == 'cpp':
+ if language == 'cpp':
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl_cpp' + lpath.suffix)))
lang_link_args.append(str(lpath.parent / (lpath.stem + '_cpp' + lpath.suffix)))
elif language == 'fortran':
lang_link_args.append(str(lpath.parent / (lpath.stem + 'hl_fortran' + lpath.suffix)))
lang_link_args.append(str(lpath.parent / (lpath.stem + '_fortran' + lpath.suffix)))
+ # C is used by other languages
+ lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
+ lang_link_args.append(larg)
+
self.link_args = lang_link_args
self.version = pkgdep.get_version()
self.is_found = True
diff --git a/test cases/frameworks/25 hdf5/main.c b/test cases/frameworks/25 hdf5/main.c
new file mode 100644
index 0000000..8773e49
--- /dev/null
+++ b/test cases/frameworks/25 hdf5/main.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+int main(void)
+{
+herr_t ier;
+unsigned maj;
+unsigned min;
+unsigned rel;
+
+ier = H5open();
+if (ier) {
+ fprintf(stderr,"Unable to initialize HDF5: %d\n", ier);
+ return EXIT_FAILURE;
+}
+
+ier = H5get_libversion(&maj, &min, &rel);
+if (ier) {
+ fprintf(stderr,"HDF5 did not initialize!\n");
+ return EXIT_FAILURE;
+}
+printf("C HDF5 version %d.%d.%d\n", maj, min, rel);
+
+ier = H5close();
+if (ier) {
+ fprintf(stderr,"Unable to close HDF5: %d\n", ier);
+ return EXIT_FAILURE;
+}
+return EXIT_SUCCESS;
+}
diff --git a/test cases/frameworks/25 hdf5/main.cpp b/test cases/frameworks/25 hdf5/main.cpp
new file mode 100644
index 0000000..1d53e76
--- /dev/null
+++ b/test cases/frameworks/25 hdf5/main.cpp
@@ -0,0 +1,31 @@
+#include <iostream>
+#include "hdf5.h"
+
+
+int main(void)
+{
+herr_t ier;
+unsigned maj;
+unsigned min;
+unsigned rel;
+
+ier = H5open();
+if (ier) {
+ std::cerr << "Unable to initialize HDF5: %d" << ier << std::endl;
+ return EXIT_FAILURE;
+}
+
+ier = H5get_libversion(&maj, &min, &rel);
+if (ier) {
+ std::cerr << "HDF5 did not initialize!" << std::endl;
+ return EXIT_FAILURE;
+}
+printf("C++ HDF5 version %d.%d.%d\n", maj, min, rel);
+
+ier = H5close();
+if (ier) {
+ std::cerr << "Unable to close HDF5: %d" << ier << std::endl;
+ return EXIT_FAILURE;
+}
+return EXIT_SUCCESS;
+}
diff --git a/test cases/frameworks/25 hdf5/main.f90 b/test cases/frameworks/25 hdf5/main.f90
new file mode 100644
index 0000000..b21abf1
--- /dev/null
+++ b/test cases/frameworks/25 hdf5/main.f90
@@ -0,0 +1,17 @@
+use hdf5
+
+implicit none
+
+integer :: ier, major, minor, rel
+
+call h5open_f(ier)
+if (ier /= 0) error stop 'Unable to initialize HDF5'
+
+call h5get_libversion_f(major, minor, rel, ier)
+if (ier /= 0) error stop 'Unable to check HDF5 version'
+print '(A,I1,A1,I0.2,A1,I1)','Fortran HDF5 version ',major,'.',minor,'.',rel
+
+call h5close_f(ier)
+if (ier /= 0) error stop 'Unable to close HDF5 library'
+
+end program
diff --git a/test cases/frameworks/25 hdf5/meson.build b/test cases/frameworks/25 hdf5/meson.build
new file mode 100644
index 0000000..94505a8
--- /dev/null
+++ b/test cases/frameworks/25 hdf5/meson.build
@@ -0,0 +1,33 @@
+project('hdf5_test', 'c', 'cpp', 'fortran')
+
+
+# --- C tests
+h5c = dependency('hdf5', language : 'c', required : false)
+if not h5c.found()
+ error('MESON_SKIP_TEST: HDF5 not found, skipping.')
+endif
+exec = executable('exec', 'main.c',
+ dependencies : h5c)
+
+test('HDF5 C', exec)
+
+# --- C++ tests
+h5cpp = dependency('hdf5', language : 'cpp')
+execpp = executable('execpp', 'main.cpp',
+ dependencies : h5cpp)
+
+test('HDF5 C++', execpp)
+
+
+# --- Fortran tests
+h5f = dependency('hdf5', language : 'fortran')
+exef = executable('exef', 'main.f90',
+ dependencies : h5f)
+
+test('HDF5 Fortran', exef)
+
+
+# Check we can apply a version constraint
+if h5c.version() != 'unknown'
+ dependency('hdf5', version: '>=@0@'.format(h5c.version()))
+endif