parent
16463046b1
commit
06bfc2dab6
8 changed files with 67 additions and 8 deletions
@ -0,0 +1,10 @@ |
||||
## New target keyword argument: `link_language` |
||||
There may be situations for which the user wishes to manually specify the linking language. |
||||
For example, a C++ target may link C, Fortran, etc. and perhaps the automatic detection in Meson does not pick the desired compiler. |
||||
The user can manually choose the linker by language per-target like this example of a target where one wishes to link with the Fortran compiler: |
||||
```meson |
||||
executable(..., link_language : 'fortran') |
||||
``` |
||||
|
||||
A specific case this option fixes is where for example the main program is Fortran that calls C and/or C++ code. |
||||
The automatic language detection of Meson prioritizes C/C++, and so an compile-time error results like `undefined reference to main`, because the linker is C or C++ instead of Fortran, which is fixed by this per-target override. |
@ -0,0 +1,7 @@ |
||||
#include <stdio.h> |
||||
|
||||
void hello(void){ |
||||
|
||||
printf("hello from C\n"); |
||||
|
||||
} |
@ -0,0 +1,10 @@ |
||||
implicit none |
||||
|
||||
interface |
||||
subroutine hello() bind (c) |
||||
end subroutine hello |
||||
end interface |
||||
|
||||
call hello() |
||||
|
||||
end program |
@ -0,0 +1,13 @@ |
||||
project('Fortran calling C', 'fortran', 'c') |
||||
|
||||
ccid = meson.get_compiler('c').get_id() |
||||
if ccid == 'msvc' or ccid == 'clang-cl' |
||||
error('MESON_SKIP_TEST: MSVC and GCC do not interoperate like this.') |
||||
endif |
||||
|
||||
c_lib = library('clib', 'clib.c') |
||||
|
||||
f_call_c = executable('f_call_c', 'f_call_c.f90', |
||||
link_with: c_lib, |
||||
link_language: 'fortran') |
||||
test('Fortran calling C', f_call_c) |
Loading…
Reference in new issue