-
Notifications
You must be signed in to change notification settings - Fork 1
/
meson.build
52 lines (40 loc) · 1.74 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
project('objc-boilerplate', 'objc', version : '0.2.0')
# Ensure clang is used for Objective-C
objc_compiler = meson.get_compiler('objc')
if objc_compiler.get_id() != 'clang'
error('Clang is required for this project. Please set CC=clang, and OBJC=clang before running Meson.')
endif
dependencies_to_link = []
# Common Objective-C flags
objc_flags = []
# Use GNUstep on non-Darwin platforms
if host_machine.system() != 'darwin'
# Objective-C (GNUstep) support from gnustep-config
gnustep_config = find_program('gnustep-config', required: true)
if not gnustep_config.found()
error('GNUstep is required for this project. Please install GNUstep and ensure gnustep-config is in your PATH. You might want to source GNUstep.sh before running Meson.')
endif
gnustep_flags = run_command(gnustep_config, '--objc-flags', check: true).stdout().strip().split()
gnustep_base_libs = run_command(gnustep_config, '--base-libs', check: true).stdout().strip().split()
# Filter out flags that are handled by Meson's built-in options
foreach flag : gnustep_flags
if flag != '-Wall' and flag != '-g' and flag != '-O2'
objc_flags += flag
endif
endforeach
add_project_link_arguments(gnustep_base_libs, language: 'objc')
else
# Properly link against the Foundation framework
foundation_dep = dependency('appleframeworks', modules: ['Foundation'])
dependencies_to_link += foundation_dep
add_project_link_arguments('-lobjc', language: 'objc')
endif
# Enable ARC (Automatic Reference Counting)
objc_flags += '-fobjc-arc'
# Add Objective-C flags
add_project_arguments(objc_flags, language: 'objc')
source = [
# Objc files
'src/main.m',
]
executable('objc-boilerplate', source, dependencies: dependencies_to_link)