mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
Fix compiling ObjC/ObjC++ on Windows/MinGW
Co-Authored-By: L. E. Segovia <amy@amyspark.me>
This commit is contained in:
1 parent
43b80e02ce
commit
81b151f611
18 files changed
+60
-3
No files matched your search
@@ -188,6 +188,8 @@ class CMakeToolchain:
|
||||
defaults[prefix + 'COMPILER'] = exe_list
|
||||
if comp_obj.get_id() == 'clang-cl':
|
||||
defaults['CMAKE_LINKER'] = comp_obj.get_linker_exelist()
|
||||
if lang.startswith('objc') and comp_obj.get_id().startswith('clang'):
|
||||
defaults[f'{prefix}FLAGS'] = ['-D__STDC__=1']
|
||||
|
||||
return defaults
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ if is_windows():
|
||||
defaults['cpp'] = ['icl', 'cl', 'c++', 'g++', 'clang++', 'clang-cl']
|
||||
# the binary flang-new will be renamed to flang in the foreseeable future
|
||||
defaults['fortran'] = ['ifort', 'gfortran', 'flang-new', 'flang', 'pgfortran', 'g95']
|
||||
defaults['objc'] = ['clang-cl', 'gcc']
|
||||
defaults['objcpp'] = ['clang-cl', 'g++']
|
||||
defaults['objc'] = ['clang', 'clang-cl', 'gcc']
|
||||
defaults['objcpp'] = ['clang++', 'clang-cl', 'g++']
|
||||
defaults['cs'] = ['csc', 'mcs']
|
||||
else:
|
||||
if platform.machine().lower() == 'e2k':
|
||||
|
||||
@@ -58,6 +58,8 @@ class ClangCompiler(GnuLikeCompiler):
|
||||
# linkers don't have base_options.
|
||||
if isinstance(self.linker, AppleDynamicLinker):
|
||||
self.base_options.add(OptionKey('b_bitcode'))
|
||||
elif isinstance(self.linker, MSVCDynamicLinker):
|
||||
self.base_options.add(OptionKey('b_vscrt'))
|
||||
# All Clang backends can also do LLVM IR
|
||||
self.can_compile_suffixes.add('ll')
|
||||
|
||||
|
||||
@@ -383,6 +383,8 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
|
||||
# As a last resort, try search in a compiled binary
|
||||
return self._symbols_have_underscore_prefix_searchbin(env)
|
||||
|
||||
def get_pie_args(self) -> T.List[str]:
|
||||
return []
|
||||
|
||||
class MSVCCompiler(VisualStudioLikeCompiler):
|
||||
|
||||
|
||||
@@ -1326,6 +1326,9 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
|
||||
def rsp_file_syntax(self) -> RSPFileSyntax:
|
||||
return self.rsp_syntax
|
||||
|
||||
def get_pie_args(self) -> T.List[str]:
|
||||
return []
|
||||
|
||||
|
||||
class MSVCDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@ if not add_languages('objc', required : false)
|
||||
error('MESON_SKIP_TEST: No ObjC compiler')
|
||||
endif
|
||||
|
||||
objc = meson.get_compiler('objc')
|
||||
c = meson.get_compiler('c')
|
||||
if c.get_argument_syntax() != objc.get_argument_syntax()
|
||||
error('MESON_SKIP_TEST: cmake cannot mix compiler types on Windows')
|
||||
endif
|
||||
|
||||
cm = import('cmake')
|
||||
|
||||
sub_pro = cm.subproject('cmTest')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(cmTest)
|
||||
project(cmTest LANGUAGES C OBJC)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@@ -2,4 +2,7 @@ project('test', default_options: ['werror=true'])
|
||||
if not add_languages('objc', required: false)
|
||||
error('MESON_SKIP_TEST: Objective C not found')
|
||||
endif
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objcpp is not supported by vs backend')
|
||||
endif
|
||||
executable('prog', 'test.m')
|
||||
@@ -2,4 +2,7 @@ project('test', default_options: ['werror=true'])
|
||||
if not add_languages('objcpp', required: false)
|
||||
error('MESON_SKIP_TEST: Objective C++ not found')
|
||||
endif
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objcpp is not supported by vs backend')
|
||||
endif
|
||||
executable('prog', 'test.mm')
|
||||
@@ -1,4 +1,8 @@
|
||||
project('objective c', 'objc', default_options: ['c_std=c99'])
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
exe = executable('prog', 'prog.m')
|
||||
test('objctest', exe)
|
||||
@@ -1,5 +1,9 @@
|
||||
project('nsstring', 'objc')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'darwin'
|
||||
dep = dependency('appleframeworks', modules : 'Foundation')
|
||||
elif host_machine.system() == 'cygwin'
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
project('objective c args', 'objc')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
exe = executable('prog', 'prog.m', objc_args : ['-DMESON_TEST'])
|
||||
test('objective c args', exe)
|
||||
@@ -1,5 +1,9 @@
|
||||
project('master', ['cpp'])
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
foo = subproject('foo')
|
||||
dep = foo.get_variable('foo_dep')
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
project('foo', ['objc'])
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
l = static_library('foo', 'foo.m')
|
||||
|
||||
foo_dep = declare_dependency(link_with : l)
|
||||
@@ -1,5 +1,9 @@
|
||||
project('objfw build tests', 'objc')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objc is not supported by vs backend')
|
||||
endif
|
||||
|
||||
objfw_dep = dependency('objfw', required: false)
|
||||
objfwtest_dep = dependency('objfw', modules: ['ObjFWTest'], required: false)
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
project('Objective C++', 'objcpp', default_options: 'cpp_std=c++14')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objcpp is not supported by vs backend')
|
||||
endif
|
||||
|
||||
exe = executable('objcppprog', 'prog.mm')
|
||||
test('objcpp', exe)
|
||||
@@ -1,4 +1,8 @@
|
||||
project('objective c++ args', 'objcpp')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objcpp is not supported by vs backend')
|
||||
endif
|
||||
|
||||
exe = executable('prog', 'prog.mm', objcpp_args : ['-DMESON_OBJCPP_TEST'])
|
||||
test('objective c++ args', exe)
|
||||
@@ -1,5 +1,9 @@
|
||||
project('objfw build tests', 'objcpp')
|
||||
|
||||
if get_option('backend').startswith('vs')
|
||||
error('MESON_SKIP_TEST: objcpp is not supported by vs backend')
|
||||
endif
|
||||
|
||||
objfw_dep = dependency('objfw', required: false)
|
||||
objfwtest_dep = dependency('objfw', modules: ['ObjFWTest'], required: false)
|
||||
|
||||
|
||||
Reference in new issue
Block a user