Skip to content

Commit 96c279d

Browse files
authored
Warn if Fortran compiler does not support C-API (#56)
1 parent 2aaed0e commit 96c279d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

meson.build

+19-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,25 @@ project(
88
'buildtype=debugoptimized',
99
],
1010
)
11-
has_cc = add_languages('c', required: get_option('python'), native: false)
11+
fc_nested_functions = meson.get_compiler('fortran').run(
12+
'call a(); contains; subroutine a(); print "(a)", "Nested functions supported"; end; end',
13+
).returncode() == 0
14+
if fc_nested_functions
15+
has_cc = add_languages('c', required: get_option('python'), native: false)
16+
else
17+
has_cc = false
18+
if get_option('python')
19+
error('Cannot compile Python API, Fortran compiler does not support nested functions')
20+
else
21+
warning('Fortran compiler does not support nested functions, C API is disabled')
22+
endif
23+
endif
1224

1325
minpack_lib = library(
1426
meson.project_name(),
1527
sources: files(
1628
'src/minpack.f90',
17-
'src/minpack_capi.f90',
29+
fc_nested_functions ? 'src/minpack_capi.f90' :,
1830
),
1931
install: true,
2032
)
@@ -38,9 +50,11 @@ install_data(
3850
install_dir: get_option('datadir')/'licenses'/meson.project_name()
3951
)
4052

41-
install_headers(
42-
minpack_header,
43-
)
53+
if fc_nested_functions
54+
install_headers(
55+
minpack_header,
56+
)
57+
endif
4458

4559
module_id = meson.project_name()
4660
meson.add_install_script(

0 commit comments

Comments
 (0)