compilers: prefer C++ over objc in clink_langs

Otherwise we will try to use the objc compiler when linking projects
with both objc and C++.

Technically we should use the objc++ linker when doing this, but on
most (all?) systems the objc++ linker is `c++`, which is the same
as the C++ linker.

Closes https://github.com/mesonbuild/meson/issues/2468
This commit is contained in:
Nirbheek Chauhan 2017-12-30 06:19:31 +05:30 committed by Jussi Pakkanen
parent 2c1b45b2b2
commit 6f3e2a0a07
5 changed files with 27 additions and 1 deletions

View File

@ -49,7 +49,7 @@ cpp_suffixes = lang_suffixes['cpp'] + ('h',)
c_suffixes = lang_suffixes['c'] + ('h',)
# List of languages that can be linked with C code directly by the linker
# used in build.py:process_compilers() and build.py:get_dynamic_linker()
clike_langs = ('objcpp', 'objc', 'd', 'cpp', 'c', 'fortran',)
clike_langs = ('d', 'objcpp', 'cpp', 'objc', 'c', 'fortran',)
clike_suffixes = ()
for _l in clike_langs:
clike_suffixes += lang_suffixes[_l]

View File

@ -0,0 +1,11 @@
#include <iostream>
extern "C"
int foo();
int main() {
std::cout << "Starting\n";
std::cout << foo() << "\n";
return 0;
}

View File

@ -0,0 +1,6 @@
project('master', ['cpp'])
foo = subproject('foo')
dep = foo.get_variable('foo_dep')
executable('master', 'master.cpp', dependencies: dep)

View File

@ -0,0 +1,4 @@
int foo() {
return 42;
}

View File

@ -0,0 +1,5 @@
project('foo', ['objc'])
l = static_library('foo', 'foo.m')
foo_dep = declare_dependency(link_with : l)