Skip to content

Commit

Permalink
Warn if Fortran compiler does not support C-API (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk authored Mar 12, 2022
1 parent 2aaed0e commit 96c279d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ project(
'buildtype=debugoptimized',
],
)
has_cc = add_languages('c', required: get_option('python'), native: false)
fc_nested_functions = meson.get_compiler('fortran').run(
'call a(); contains; subroutine a(); print "(a)", "Nested functions supported"; end; end',
).returncode() == 0
if fc_nested_functions
has_cc = add_languages('c', required: get_option('python'), native: false)
else
has_cc = false
if get_option('python')
error('Cannot compile Python API, Fortran compiler does not support nested functions')
else
warning('Fortran compiler does not support nested functions, C API is disabled')
endif
endif

minpack_lib = library(
meson.project_name(),
sources: files(
'src/minpack.f90',
'src/minpack_capi.f90',
fc_nested_functions ? 'src/minpack_capi.f90' :,
),
install: true,
)
Expand All @@ -38,9 +50,11 @@ install_data(
install_dir: get_option('datadir')/'licenses'/meson.project_name()
)

install_headers(
minpack_header,
)
if fc_nested_functions
install_headers(
minpack_header,
)
endif

module_id = meson.project_name()
meson.add_install_script(
Expand Down

0 comments on commit 96c279d

Please sign in to comment.