Fix combining C and Fortran. Closes #8377.

0.57
Jussi Pakkanen 4 years ago committed by Nirbheek Chauhan
parent bc19b12a57
commit 5eaaef27d1
  1. 7
      mesonbuild/backend/ninjabackend.py
  2. 8
      test cases/fortran/9 cpp/main.c
  3. 12
      test cases/fortran/9 cpp/meson.build

@ -2513,15 +2513,18 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
element.add_item('DEPFILE', dep_file) element.add_item('DEPFILE', dep_file)
element.add_item('ARGS', commands) element.add_item('ARGS', commands)
self.add_dependency_scanner_entries_to_element(target, compiler, element) self.add_dependency_scanner_entries_to_element(target, compiler, element, src)
self.add_build(element) self.add_build(element)
assert(isinstance(rel_obj, str)) assert(isinstance(rel_obj, str))
assert(isinstance(rel_src, str)) assert(isinstance(rel_src, str))
return (rel_obj, rel_src.replace('\\', '/')) return (rel_obj, rel_src.replace('\\', '/'))
def add_dependency_scanner_entries_to_element(self, target, compiler, element): def add_dependency_scanner_entries_to_element(self, target, compiler, element, src):
if not self.should_use_dyndeps_for_target(target): if not self.should_use_dyndeps_for_target(target):
return return
extension = os.path.splitext(src.fname)[1][1:]
if not (extension in compilers.lang_suffixes['fortran'] or extension in compilers.lang_suffixes['cpp']):
return
dep_scan_file = self.get_dep_scan_file_for(target) dep_scan_file = self.get_dep_scan_file_for(target)
element.add_item('dyndep', dep_scan_file) element.add_item('dyndep', dep_scan_file)
element.add_orderdep(dep_scan_file) element.add_orderdep(dep_scan_file)

@ -0,0 +1,8 @@
#include <stdio.h>
double fortran(void);
int main(void) {
printf("FORTRAN gave us this number: %lf.\n", fortran());
return 0;
}

@ -1,4 +1,4 @@
project('C++ and FORTRAN', 'cpp', 'fortran') project('C, C++ and Fortran', 'c', 'cpp', 'fortran')
cpp = meson.get_compiler('cpp') cpp = meson.get_compiler('cpp')
fc = meson.get_compiler('fortran') fc = meson.get_compiler('fortran')
@ -17,9 +17,17 @@ if fc.get_id() == 'intel'
endif endif
e = executable( e = executable(
'cfort',
['main.c', 'fortran.f'],
dependencies : link_with,
)
test('C and Fortran', e)
e2 = executable(
'cppfort', 'cppfort',
['main.cpp', 'fortran.f'], ['main.cpp', 'fortran.f'],
dependencies : link_with, dependencies : link_with,
) )
test('C++ FORTRAN', e) test('C++ and Fortran', e2)

Loading…
Cancel
Save