diff options
-rw-r--r-- | mesonbuild/compilers/fortran.py | 4 | ||||
-rw-r--r-- | test cases/fortran/9 cpp/fortran.f | 5 | ||||
-rw-r--r-- | test cases/fortran/9 cpp/main.cpp | 8 | ||||
-rw-r--r-- | test cases/fortran/9 cpp/meson.build | 10 |
4 files changed, 26 insertions, 1 deletions
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 9d3240f..87fa702 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -183,13 +183,15 @@ class GnuFortranCompiler(FortranCompiler): def openmp_flags(self): return ['-fopenmp'] + def language_stdlib_only_link_flags(self): + return ['-lgfortran', '-lm', '-lquadmath'] + class ElbrusFortranCompiler(GnuFortranCompiler, ElbrusCompiler): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None, **kwargs): GnuFortranCompiler.__init__(self, exelist, version, gcc_type, is_cross, exe_wrapper, defines, **kwargs) ElbrusCompiler.__init__(self, gcc_type, defines) - class G95FortranCompiler(FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): super().__init__(exelist, version, is_cross, exe_wrapper=None, **kwags) diff --git a/test cases/fortran/9 cpp/fortran.f b/test cases/fortran/9 cpp/fortran.f new file mode 100644 index 0000000..e694669 --- /dev/null +++ b/test cases/fortran/9 cpp/fortran.f @@ -0,0 +1,5 @@ + function fortran() bind(C) + use, intrinsic :: iso_c_binding + real(kind=c_double) :: fortran + fortran = 2.0**rand(1) + end function fortran diff --git a/test cases/fortran/9 cpp/main.cpp b/test cases/fortran/9 cpp/main.cpp new file mode 100644 index 0000000..f5828f4 --- /dev/null +++ b/test cases/fortran/9 cpp/main.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +extern "C" double fortran(); + +int main(int, char**) { + std::cout << "FORTRAN gave us this number: " << fortran() << '\n'; + return 0; +} diff --git a/test cases/fortran/9 cpp/meson.build b/test cases/fortran/9 cpp/meson.build new file mode 100644 index 0000000..49497c0 --- /dev/null +++ b/test cases/fortran/9 cpp/meson.build @@ -0,0 +1,10 @@ +project('C++ and FORTRAN', 'cpp', 'fortran') + +cpp = meson.get_compiler('cpp') + +if cpp.get_id() == 'clang' + error('MESON_SKIP_TEST Clang C++ does not find -lgfortran for some reason.') +endif + +e = executable('cppfort', 'main.cpp', 'fortran.f') +test('C++ FORTRAN', e) |