-
Notifications
You must be signed in to change notification settings - Fork 188
/
meson.build
200 lines (173 loc) · 7.21 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
project('highs', 'cpp', 'c',
version : '1.8.1',
meson_version: '>= 1.1.0',
default_options : ['warning_level=1',
'cpp_std=c++17',
'wrap_mode=forcefallback',
'highsint64=false'])
# Add C++ compiler options
_args = [] # Extra arguments
_deps = [] # Dependencies
_incdirs = [] # All the includes
cc = meson.get_compiler('c')
cppc = meson.get_compiler('cpp')
# Platform detection
host_system = host_machine.system()
is_windows = host_system == 'windows'
is_mingw = is_windows and cc.get_id() == 'gcc'
# Granular flags
# C++
_cpp_Wno_invalid_offsetof = cppc.get_supported_arguments('-Wno-invalid-offsetof')
_cpp_Wno_maybe_uninitialized = cppc.get_supported_arguments('-Wno-maybe-uninitialized')
_cpp_Wno_reorder = cppc.get_supported_arguments('-Wno-reorder')
_cpp_Wno_reorder_ctor = cppc.get_supported_arguments('-Wno-reorder-ctor')
_cpp_Wno_sometimes_uninitialized = cppc.get_supported_arguments('-Wno-sometimes-uninitialized')
_cpp_Wno_unused_but_set_variable = cppc.get_supported_arguments('-Wno-unused-but-set-variable')
_cpp_Wno_unused_variable = cppc.get_supported_arguments('-Wno-unused-variable')
_cpp_Wno_use_after_free = cppc.get_supported_arguments('-Wno-use-after-free')
_cpp_Wno_comment = cppc.get_supported_arguments('-Wno-comment')
# C
Wno_comment = cc.get_supported_arguments('-Wno-comment')
Wno_invalid_offsetof = cc.get_supported_arguments('-Wno-invalid-offsetof')
Wno_maybe_uninitialized = cc.get_supported_arguments('-Wno-maybe-uninitialized')
Wno_sometimes_uninitialized = cc.get_supported_arguments('-Wno-sometimes-uninitialized')
Wno_unused_label = cc.get_supported_arguments('-Wno-unused-label')
Wno_use_after_free = cc.get_supported_arguments('-Wno-use-after-free')
Wno_unused_but_set_variable = cc.get_supported_arguments('-Wno-unused-but-set-variable')
Wno_unused_variable = cc.get_supported_arguments('-Wno-unused-variable')
Wno_use_after_free = cc.get_supported_arguments('-Wno-use-after-free')
# Conditional arguments
_highs_cpp_suppressions = [
_cpp_Wno_comment,
_cpp_Wno_invalid_offsetof,
_cpp_Wno_maybe_uninitialized,
_cpp_Wno_reorder,
_cpp_Wno_reorder_ctor,
_cpp_Wno_sometimes_uninitialized,
_cpp_Wno_unused_but_set_variable,
_cpp_Wno_unused_variable,
_cpp_Wno_use_after_free,
]
_highs_c_suppressions = [
Wno_comment,
Wno_invalid_offsetof,
Wno_maybe_uninitialized,
Wno_sometimes_uninitialized,
Wno_unused_but_set_variable,
Wno_unused_label,
Wno_unused_variable,
Wno_use_after_free,
]
if cppc.get_id() == 'msvc'
add_project_arguments(
'/wd4018', # Disable warning: 'expression' : signed/unsigned mismatch
'/wd4061', # Disable warning: enumerator 'identifier' in switch of enum 'enumeration' is not explicitly handled by a case label
'/wd4100', # Disable warning: 'identifier' : unreferenced formal parameter
'/wd4101', # Disable warning: 'identifier' : unreferenced local variable
'/wd4127', # Disable warning: conditional expression is constant
'/wd4189', # Disable warning: 'identifier' : local variable is initialized but not referenced
'/wd4244', # Disable warning: 'conversion' conversion from 'type1' to 'type2', possible loss of data
'/wd4245', # Disable warning: 'conversion' conversion from 'type1' to 'type2', signed/unsigned mismatch
'/wd4267', # Disable warning: 'conversion' conversion from 'size_t' to 'type', possible loss of data
'/wd4324', # Disable warning: 'structure' structure was padded due to alignment specifier
'/wd4365', # Disable warning: 'action' : conversion from 'type_1' to 'type_2', signed/unsigned mismatch
'/wd4389', # Disable warning: 'modifier' : signed/unsigned mismatch
'/wd4456', # Disable warning: declaration of 'identifier' hides previous local declaration
'/wd4457', # Disable warning: declaration of 'identifier' hides function parameter
'/wd4458', # Disable warning: declaration of 'identifier' hides class member
'/wd4459', # Disable warning: declaration of 'identifier' hides global declaration
'/wd4514', # Disable warning: 'function' : unreferenced inline function has been removed
'/wd4701', # Disable warning: potentially uninitialized local variable 'name' used
'/wd4820', # Disable warning: 'bytes' bytes padding added after construct 'member_name'
language: 'cpp',
)
_args += '-D_CRT_SECURE_NO_WARNINGS'
endif
cpu_family = host_machine.cpu_family()
if cpu_family in ['x86_64', 'i686'] and not is_windows
add_project_arguments(cppc.get_supported_arguments('-mpopcnt'), language: 'cpp')
endif
if cpu_family in ['ppc64', 'powerpc64'] and not meson.is_cross_build()
add_project_arguments(cppc.get_supported_arguments('-mpopcntd'), language: 'cpp')
endif
if is_mingw
# For mingw-w64, don't use LTO
add_project_arguments('-fno-use-linker-plugin', language: ['c', 'cpp'])
endif
# --------------------- Dependencies
threads_dep = dependency('threads', required: false)
_deps += threads_dep
# Determine whether it is necessary to link libatomic. This could be the case
# e.g. on 32-bit platforms when atomic operations are used on 64-bit types.
# The check is copied from SciPy which in turn came from
# Mesa <https://www.mesa3d.org/>.
null_dep = dependency('', required : false)
atomic_dep = null_dep
code_non_lockfree = '''
#include <stdint.h>
int main() {
struct {
uint64_t *v;
} x;
return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
(int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
}
'''
if cc.get_id() != 'msvc'
if not cc.links(
code_non_lockfree,
name : 'Check atomic builtins without -latomic'
)
atomic_dep = cc.find_library('atomic', required: false)
if atomic_dep.found()
# From SciPy
# We're not sure that with `-latomic` things will work for all compilers,
# so verify and only keep libatomic as a dependency if this works.
if not cc.links(
code_non_lockfree,
dependencies: atomic_dep,
name : 'Check atomic builtins with -latomic'
)
atomic_dep = null_dep
endif
endif
endif
endif
_deps += atomic_dep
# Optional
zlib_dep = dependency('zlib',
required: get_option('use_zlib'))
if zlib_dep.found()
_deps += zlib_dep
_incdirs += include_directories(['extern/zstr'])
endif
# Include Sources
_incdirs += include_directories([
'extern/',
'extern/pdqsort/',
'extern/filereaderlp/',
])
# Optional arguments
if get_option('fast_build')
add_project_arguments(cc.get_supported_arguments('-fno-omit-frame-pointer'), language : ['c', 'cpp'])
endif
if get_option('debug_sol')
_args += ['-DHIGHS_DEBUGSOL']
endif
if cppc.get_id() == 'msvc'
# Don't depend on VCRUNTIME140_1.dll
# https://cibuildwheel.readthedocs.io/en/stable/faq/#windows-importerror-dll-load-failed-the-specific-module-could-not-be-found
add_project_arguments('/d2FH4-', language : ['cpp', 'c'])
if get_option('with_stdcall')
add_project_arguments(cppc.get_supported_arguments('/Gz'), language : ['cpp', 'c'])
endif
endif
# --------------------- Library
subdir('src') # defines highslib
# --------------------- Tests
if get_option('with_tests')
subdir('check')
_deps += dependency('catch2', required: true)
endif
# --------------------- Bindings
# now in src/