Skip to content

Commit a12442d

Browse files
committed
meson: bugfix and backport from dev
1 parent f5a6b40 commit a12442d

File tree

8 files changed

+55
-43
lines changed

8 files changed

+55
-43
lines changed

.github/workflows/ci_linux.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: ci_linux
22

33
on:
44
push:
5-
paths-ignore:
6-
- "**/*.md"
5+
paths:
6+
- "**.f90"
77
pull_request:
8-
paths-ignore:
9-
- "**/*.md"
8+
paths:
9+
- "**.f90"
1010

1111
jobs:
1212

@@ -17,8 +17,8 @@ jobs:
1717
- uses: actions/setup-python@v1
1818
with:
1919
python-version: '3.x'
20-
- run: python -m pip install meson
21-
- run: sudo apt install -yq --no-install-recommends ninja-build gfortran libhdf5-dev
20+
- run: python -m pip install meson ninja
21+
- run: sudo apt install -yq --no-install-recommends gfortran libhdf5-dev
2222
- run: meson setup build --default-library=static
2323
env:
2424
FC: gfortran
@@ -36,8 +36,8 @@ jobs:
3636
- uses: actions/setup-python@v1
3737
with:
3838
python-version: '3.x'
39-
- run: python -m pip install meson
40-
- run: sudo apt install -yq --no-install-recommends ninja-build gfortran libhdf5-dev
39+
- run: python -m pip install meson ninja
40+
- run: sudo apt install -yq --no-install-recommends gfortran libhdf5-dev
4141
- run: meson setup build --default-library=shared
4242
env:
4343
FC: gfortran

.github/workflows/ci_mac.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: ci_mac
22

33
on:
44
push:
5-
paths-ignore:
6-
- "**/*.md"
5+
paths:
6+
- "**.f90"
77
pull_request:
8-
paths-ignore:
9-
- "**/*.md"
8+
paths:
9+
- "**.f90"
1010

1111
jobs:
1212

@@ -17,8 +17,8 @@ jobs:
1717
- uses: actions/setup-python@v1
1818
with:
1919
python-version: '3.x'
20-
- run: python -m pip install meson
21-
- run: brew install ninja pkg-config gcc hdf5
20+
- run: python -m pip install meson ninja
21+
- run: brew install pkg-config gcc hdf5
2222
- run: meson setup build --default-library=shared
2323
env:
2424
FC: gfortran-9

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE)
44
endif()
55
project(hdf5iface
66
LANGUAGES Fortran
7-
VERSION 1.3.0
7+
VERSION 1.3.1
88
HOMEPAGE_URL https://github.com/scivision/h5fortran)
99
enable_testing()
1010

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Requirements:
4040
Note that some precompiled HDF5 libraries include C / C++ without Fortran.
4141

4242
Build this HDF5 OO Fortran interface with Meson or CMake.
43-
The library `libh5oo` is built, link it into your program as usual.
43+
The library `libh5fortran` is built, link it into your program as usual.
4444

4545
### Meson
4646

@@ -52,8 +52,8 @@ meson test -C build
5252

5353
If HDF5 isn't found, you may need to specify on the command line:
5454

55-
* `-Dh5libdir`: HDF5 library directory
56-
* `-Dh5incdir`: HDF5 include directory
55+
* `-Dhdf5_libdir`: HDF5 library directory
56+
* `-Dhdf5_incdir`: HDF5 include directory
5757

5858
To include h5fortran as a Meson subproject, in the master project meson.build (that uses h5fortran) have like:
5959

meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
project('Object-oriented HDF5 Fortran', 'fortran',
1+
project('h5fortran', 'fortran',
22
meson_version : '>=0.51.2',
3-
version : '1.3.0',
3+
version : '1.3.1',
44
default_options : ['default_library=static', 'buildtype=release', 'warning_level=3'])
55

6-
subdir('cmake')
6+
subdir('meson')
77

88
subdir('src')
99

10-
ooh5 = library('oohdf5',
10+
ooh5 = library('h5fortran',
1111
sources: hdf5_src,
1212
dependencies: hdf5,
1313
install: true)

cmake/meson.build renamed to meson/meson.build

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,75 @@ f18flag = fc.first_supported_argument(['-std=f2018', '-stand f18', '/stand:f18']
77
if fc.get_id() == 'gcc'
88
add_project_arguments('-fimplicit-none', f18flag, language : 'fortran')
99
quiet = ['-Wno-compare-reals', '-Wno-maybe-uninitialized']
10-
elif fcid == 'intel'
10+
elif fc.get_id() == 'intel'
1111
add_project_arguments('-warn', '-heap-arrays', f18flag, language : 'fortran')
12-
elif fcid == 'intel-cl'
12+
elif fc.get_id() == 'intel-cl'
1313
add_project_arguments('/warn', '/heap-arrays', f18flag, language : 'fortran')
14-
elif fcid == 'pgi'
14+
elif fc.get_id() == 'pgi'
1515
add_project_arguments('-C', '-Mdclchk', language : 'fortran')
1616
endif
1717

1818
#== find HDF5
1919

2020
# needed for HDF5 on some systems including Ubuntu
21+
# these are moving to glibc so eventually this goes away
22+
# https://github.com/mesonbuild/meson/issues/4297#issuecomment-425744841
2123
threads = dependency('threads', required: false)
2224
dl = fc.find_library('dl', required: false)
2325

2426
use_static = get_option('default_library') == 'static'
2527
# NOTE: static: parameter is too strict for now. Works more reliably without this parameter
2628

2729
hdf5 = dependency('hdf5', language : 'fortran', required: false, disabler: true) # , static: use_static
30+
hdf5 = [hdf5]
31+
if threads.found()
32+
hdf5 += threads
33+
endif
34+
if dl.found()
35+
hdf5 += dl
36+
endif
2837
if fc.links('use h5lt; end', dependencies: hdf5, name: 'HDF5')
29-
h5incdir = []
30-
hdf5 = [hdf5, threads, dl]
38+
hdf5_incdir = []
3139
subdir_done()
3240
endif
3341

3442
# HDF5 was not found
35-
h5incdir = include_directories(get_option('h5incdir'))
36-
h5libdir = get_option('h5libdir')
37-
if h5libdir == ''
43+
hdf5_incdir = include_directories(get_option('hdf5_incdir'))
44+
hdf5_libdir = get_option('hdf5_libdir')
45+
if hdf5_libdir == ''
3846
if os == 'darwin'
3947
# assume homebrew
40-
h5libdir = '/usr/local/opt/hdf5/lib'
41-
h5incdir = include_directories('/usr/local/opt/hdf5/include')
48+
hdf5_libdir = '/usr/local/opt/hdf5/lib'
49+
hdf5_incdir = include_directories('/usr/local/opt/hdf5/include')
4250
elif os == 'windows'
4351
# assume MSYS2
44-
h5libdir = 'c:/msys64/mingw64/lib'
52+
hdf5_libdir = 'c:/msys64/mingw64/lib'
4553
if use_static
46-
h5incdir = include_directories('c:/msys64/mingw64/include/static')
54+
hdf5_incdir = include_directories('c:/msys64/mingw64/include/static')
4755
else
48-
h5incdir = include_directories('c:/msys64/mingw64/include/shared')
56+
hdf5_incdir = include_directories('c:/msys64/mingw64/include/shared')
4957
endif
5058
else
51-
h5libdir = []
59+
hdf5_libdir = []
5260
endif
5361
endif
5462

5563
hdf5_libs = []
5664
foreach name : ['hdf5', 'hdf5_fortran', 'hdf5_hl', 'hdf5_hl_fortran', # msys2 names
5765
'hdf5_serial', 'hdf5_serial_fortran',
5866
'hdf5_serial_hl', 'hdf5_serialhl_fortran']
59-
lib = fc.find_library(name, required: false, dirs: h5libdir) # , static: use_static
67+
lib = fc.find_library(name, required: false, dirs: hdf5_libdir) # , static: use_static
6068
if lib.found()
6169
hdf5_libs += lib
6270
endif
6371
endforeach
6472

6573

66-
if not fc.links('use h5lt; end', dependencies: hdf5_libs, include_directories: h5incdir, name: 'HDF5')
67-
hdf5 = disabler()
74+
if fc.links('use h5lt; end', dependencies: hdf5_libs,
75+
include_directories: hdf5_incdir,
76+
name: 'HDF5')
77+
hdf5 = declare_dependency(dependencies: [hdf5_libs, threads, dl],
78+
include_directories: hdf5_incdir)
6879
else
69-
hdf5 = declare_dependency(dependencies: [hdf5_libs, threads, dl], include_directories: h5incdir)
80+
hdf5 = disabler()
7081
endif

meson_options.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
option('h5libdir', type : 'string', description : 'HDF5 library directory', yield: true)
2-
option('h5incdir', type : 'string', description : 'HDF5 include directory', yield: true)
1+
option('hdf5_libdir', type: 'string', description : 'HDF5 library directory', yield: true)
2+
option('hdf5_incdir', type: 'string', description : 'HDF5 include directory', yield: true)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
meson
1+
meson
2+
ninja

0 commit comments

Comments
 (0)