-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
153 lines (127 loc) · 4.09 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Define the project.
project(
'conjugateur',
'cpp',
default_options: [ 'cpp_std=c++17' ],
license: 'GPL-3.0-or-later',
license_files: 'LICENSE.md',
version: '1.0.3'
)
# Specify the include directories.
incdir = include_directories([ 'include' , 'configuration-files' ])
# Initialise a list of files which will hold all source files.
srcs = files()
# Initialise a environment for later use with custom targets.
env = environment()
# Initialise a configuration data object.
conf_data = configuration_data()
# Set configuration variables.
conf_data.set(
'version', meson.project_version()
)
conf_data.set(
'tag', 'v' + meson.project_version()
)
conf_data.set(
'project_source_root', meson.project_source_root()
)
conf_data.set(
'resources_dir', meson.project_source_root() + '/resources'
)
conf_data.set(
'config_filename', 'conjugateur.conf'
)
# Define the wxWidgets dependency depending on the 'static_wxwidgets' option.
if get_option('static_wxwidgets') == 'auto'
wx = dependency('wxwidgets')
elif get_option('static_wxwidgets') == 'enabled'
wx = dependency('wxwidgets', modules: '--static')
endif
# Configuration only needed on macOS.
if host_machine.system() == 'darwin'
# Add the necessary compiler arguments and env variables depending on the
# 'macos_min' option.
env.set('MACOSX_DEPLOYMENT_TARGET', get_option('macos_min'))
macos_min_arg = '-mmacosx-version-min=@0@'
add_global_arguments(macos_min_arg.format(get_option('macos_min')), language: 'cpp')
add_global_link_arguments(macos_min_arg.format(get_option('macos_min')), language: 'cpp')
# Add the necessary compiler arguments and configuration variables depending
# on the 'macos_universal' option.
if get_option('macos_universal') == 'true'
add_project_arguments('-arch', 'x86_64', '-arch', 'arm64', language: 'cpp')
add_project_link_arguments('-arch', 'x86_64', '-arch', 'arm64', language: 'cpp')
conf_data.set(
'mac_bundle_version', conf_data.get('version') + '-universal'
)
else
conf_data.set(
'mac_bundle_version', conf_data.get('version') + '-' + host_machine.cpu()
)
endif
# Set a different configuration filename
conf_data.set(
'config_filename', 'ch.tifrueh.conjugateur.conf'
)
# Configuration only needed on Windows.
elif host_machine.system() == 'windows'
# Initialise variable to hold the necessary resource compiler arguments for
# wxWidgets.
raw_wx_windres_args = wx.get_variable(configtool: 'rescomp').split()
wx_windres_args = []
foreach a : raw_wx_windres_args
if a != 'windres'
wx_windres_args += a
endif
endforeach
windows = import('windows')
# Configure the windows resource compiler.
resources = windows.compile_resources(
meson.current_build_dir() + '/configuration-files/resources.rc',
args: wx_windres_args,
depend_files: [ meson.project_source_root() + '/resources/conjugateur.ico',
meson.project_source_root() + '/resources/inspecteur.ico' ]
)
srcs += resources
endif
# Execute meson.build in the 'configuration-files' subdir.
subdir('configuration-files')
# Execute meson.build in the 'src' subdir.
subdir('src')
# Put wxWidgets in the dependency list.
deps = [ wx ]
## Install the logo as png and svg, as well as the desktop entry.
install_data('resources/conjugateur.png')
install_data('resources/conjugateur.svg')
install_data('resources/conjugateur.desktop')
# Configure the main executable.
conjugateur = executable(
'conjugateur',
srcs,
dependencies: deps,
include_directories: incdir,
win_subsystem: 'windows',
install: true
)
# MacOS-exclusive custom targets (see scripts/).
if host_machine.system() == 'darwin'
run_target(
'bundle_mac',
command: 'scripts/bundle_mac.sh',
depends: [ conjugateur ],
env: env
)
run_target(
'package_mac',
command: [
'scripts/package_mac.sh', conf_data.get('version')],
depends: [ conjugateur ],
env: env
)
run_target(
'dmg_mac',
command: [
'scripts/dmg_mac.sh', conf_data.get('version')],
depends: [ conjugateur ],
env: env
)
endif