Skip to content

Commit bd7e66a

Browse files
committed
meson: default homebrew for mac
1 parent 05394ee commit bd7e66a

File tree

5 files changed

+91
-44
lines changed

5 files changed

+91
-44
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ jobs:
1010
- uses: actions/checkout@v1
1111
- uses: actions/setup-python@v1
1212
with:
13-
python-version: 3.7
14-
- name: Install Meson
15-
run: python -m pip install meson
16-
- name: Install packages
17-
run: sudo apt install -yq --no-install-recommends ninja-build gfortran libhdf5-dev
18-
- name: Meson configure
19-
run: meson setup build
13+
python-version: '3.x'
14+
- run: python -m pip install meson
15+
- run: sudo apt install -yq --no-install-recommends ninja-build gfortran libhdf5-dev
16+
- run: meson setup build
2017
env:
2118
FC: gfortran
22-
- name: Meson test
23-
run: meson test -C build -v
19+
- run: meson test -C build -v
2420
- uses: actions/upload-artifact@v1
2521
if: failure()
2622
with:
@@ -31,17 +27,13 @@ jobs:
3127
runs-on: ubuntu-latest
3228
steps:
3329
- uses: actions/checkout@v1
34-
- name: Install packages
35-
run: sudo apt install -yq --no-install-recommends gfortran libhdf5-dev
36-
- name: Cmake configure
37-
run: |
30+
- run: sudo apt install -yq --no-install-recommends gfortran libhdf5-dev
31+
- run: |
3832
mkdir build
3933
cd build
4034
cmake ..
4135
env:
4236
FC: gfortran
43-
- name: Cmake build
44-
run: cmake --build build --parallel
45-
- name: Cmake test
46-
run: ctest -V
37+
- run: cmake --build build --parallel
38+
- run: ctest -V
4739
working-directory: build

.github/workflows/ci_mac.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ci_mac
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
macMeson:
8+
runs-on: macos-latest
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: actions/setup-python@v1
12+
with:
13+
python-version: '3.x'
14+
- run: python -m pip install meson
15+
- run: brew install ninja gcc hdf5
16+
- run: meson setup build
17+
env:
18+
FC: gfortran-9
19+
CC: gcc-9
20+
- run: meson test -C build -v
21+
- uses: actions/upload-artifact@v1
22+
if: failure()
23+
with:
24+
name: Mac_Meson_Testlog
25+
path: build/meson-logs/testlog.txt
26+
27+
macCmake:
28+
runs-on: macos-latest
29+
steps:
30+
- uses: actions/checkout@v1
31+
- name: Install packages
32+
run: brew install gcc hdf5
33+
- run: cmake -B build
34+
env:
35+
FC: gfortran-9
36+
CC: gcc-9
37+
- run: cmake --build build --parallel
38+
- run: ctest -V
39+
working-directory: build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![DOI](https://zenodo.org/badge/128736984.svg)](https://zenodo.org/badge/latestdoi/128736984)
22

33
[![Actions Status](https://github.com/scivision/oo_hdf5_fortran/workflows/ci/badge.svg)](https://github.com/scivision/oo_hdf5_fortran/actions)
4-
4+
[![Actions Status](https://github.com/scivision/oo_hdf5_fortran/workflows/ci_mac/badge.svg)](https://github.com/scivision/oo_hdf5_fortran/actions)
55

66
# Object-oriented Fortran 2018 HDF5 interface
77

@@ -31,7 +31,7 @@ Requirements:
3131

3232
* modern Fortran 2008 compiler
3333
* HDF5 Fortran library (1.8 or 1.10)
34-
* Mac: `brew install gcc hdf5`
34+
* Mac / Homebrew: `brew install gcc hdf5`
3535
* Linux: `apt install gfortran libhdf5-dev`
3636
* Windows Subsystem for Linux: `apt install gfortran libhdf5-dev`
3737
* Windows MSYS2: `pacman -S mingw-w64-x86_64-hdf5`

cmake/meson.build

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
quiet = ['-w']
22

33
fc = meson.get_compiler('fortran')
4+
os = target_machine.system()
5+
46
f18flag = fc.first_supported_argument(['-std=f2018', '-stand f18', '/stand:f18'])
57
if fc.get_id() == 'gcc'
68
add_project_arguments('-fimplicit-none', f18flag, language : 'fortran')
@@ -14,30 +16,40 @@ elif fcid == 'pgi'
1416
endif
1517

1618

17-
hdf5 = dependency('hdf5', language : 'fortran', required: false)
18-
h5incdir = []
19-
if not hdf5.found()
20-
h5libdir = get_option('h5libdir')
21-
if h5libdir == ''
19+
hdf5 = dependency('hdf5', language : 'fortran', required: false, disabler: true)
20+
if fc.links('use h5lt; end', dependencies: hdf5, name: 'HDF5')
21+
subdir_done()
22+
endif
23+
24+
# HDF5 was not found
25+
h5incdir = include_directories(get_option('h5incdir'))
26+
h5libdir = get_option('h5libdir')
27+
if h5libdir == ''
28+
if os == 'darwin'
29+
# assume homebrew
30+
h5libdir = '/usr/local/opt/hdf5/lib'
31+
h5incdir = include_directories('/usr/local/opt/hdf5/include')
32+
else
2233
h5libdir = []
2334
endif
24-
h5incdir = include_directories(get_option('h5incdir'))
25-
hdf5_libs = []
26-
foreach name : ['hdf5', 'hdf5_fortran', 'hdf5_hl', 'hdf5_hl_fortran', # msys2 names
27-
'hdf5_serial', 'hdf5_serial_fortran',
28-
'hdf5_serial_hl', 'hdf5_serialhl_fortran']
29-
lib = fc.find_library(name, required: false, dirs: h5libdir)
30-
if lib.found()
31-
hdf5_libs += lib
32-
endif
33-
endforeach
34-
if hdf5_libs.length() == 0
35-
error('could not find HDF5 library')
35+
endif
36+
37+
hdf5_libs = []
38+
foreach name : ['hdf5', 'hdf5_fortran', 'hdf5_hl', 'hdf5_hl_fortran', # msys2 names
39+
'hdf5_serial', 'hdf5_serial_fortran',
40+
'hdf5_serial_hl', 'hdf5_serialhl_fortran']
41+
lib = fc.find_library(name, required: false, dirs: h5libdir)
42+
if lib.found()
43+
hdf5_libs += lib
3644
endif
37-
# hdf5 = declare_dependency(dependencies: hdf5_libs, include_directories: h5incdir) # meson bug?
38-
hdf5 = hdf5_libs
45+
endforeach
46+
47+
if hdf5_libs.length() == 0
48+
error('could not find HDF5 library')
3949
endif
40-
h5run = fc.run('use h5lt; end', dependencies: hdf5, include_directories: h5incdir, name: 'HDF5 runs')
41-
if h5run.returncode() != 0
50+
51+
hdf5 = hdf5_libs
52+
53+
if not fc.links('use h5lt; end', dependencies: hdf5, include_directories: h5incdir, name: 'HDF5')
4254
warning('HDF5 possible linking problems: ' + h5run.stdout() + h5run.stderr())
43-
endif
55+
endif

meson.build

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ project('Object-oriented HDF5 Fortran', 'fortran',
66
subdir('cmake')
77

88
subdir('src')
9+
910
ooh5 = library('oohdf5',
1011
sources: hdf5_src,
1112
dependencies: hdf5,
12-
include_directories: h5incdir
13-
)
13+
include_directories: h5incdir,
14+
install: true)
1415

1516
# --- testing
1617
subdir('tests')
@@ -19,4 +20,7 @@ shapes = executable('shapes_hdf5', 'tests/GetShape.f90',
1920
dependencies: hdf5,
2021
link_with: ooh5,
2122
fortran_args: quiet)
22-
test('Shapes', shapes, args: ['p5.h5','group69/flux_node'], is_parallel: false)
23+
test('Shapes', shapes,
24+
args: ['p5.h5','group69/flux_node'],
25+
is_parallel: false,
26+
timeout: 30)

0 commit comments

Comments
 (0)