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
pull/2838/head
Nirbheek Chauhan 7 years ago committed by Jussi Pakkanen
parent 2c1b45b2b2
commit 6f3e2a0a07
  1. 2
      mesonbuild/compilers/compilers.py
  2. 11
      test cases/objc/6 c++ project objc subproject/master.cpp
  3. 6
      test cases/objc/6 c++ project objc subproject/meson.build
  4. 4
      test cases/objc/6 c++ project objc subproject/subprojects/foo/foo.m
  5. 5
      test cases/objc/6 c++ project objc subproject/subprojects/foo/meson.build

@ -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]

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

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

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