-
Notifications
You must be signed in to change notification settings - Fork 20
/
meson.build
148 lines (131 loc) · 4.54 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
project(
'dcv-color-primitives', 'c',
license : 'MIT-0',
version : run_command('build-aux' / 'getversion.py', check: false).stdout().strip(),
meson_version: '>= 0.52.0'
)
cc = meson.get_compiler('c')
host_system = host_machine.system()
arch = host_machine.cpu_family()
is_win = host_system == 'windows'
prefix = get_option('prefix')
libdir = prefix / get_option('libdir')
# Compiler flags
if cc.get_id() == 'msvc'
# Make MSVC more pedantic, this is a recommended pragma list
# from _Win32_Programming_ by Rector and Newcomer. Taken from
# glib's msvc_recommended_pragmas.h--please see that file for
# the meaning of the warning codes used here
test_cflags = [
'-we4002', # too many actual parameters for macro
'-we4003', # not enough actual parameters for macro
'-w14010', # single-line comment contains line-continuation character
'-we4013', # 'function' undefined; assuming extern returning int
'-w14016', # no function return type; using int as default
'-we4020', # too many actual parameters
'-we4021', # too few actual parameters
'-we4027', # function declared without formal parameter list
'-we4029', # declared formal parameter list different from definition
'-we4033', # 'function' must return a value
'-we4035', # 'function' : no return value
'-we4045', # array bounds overflow
'-we4047', # different levels of indirection
'-we4049', # terminating line number emission
'-we4053', # an expression of type void was used as an operand
'-we4071', # no function prototype given
'-we4819', # the file contains a character that cannot be represented in the current code page
]
elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_cflags = [
'-Wpointer-arith',
'-Wmissing-declarations',
'-Wformat=2',
'-Wstrict-prototypes',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wunused',
'-Wno-uninitialized',
'-Wshadow',
'-Wcast-align',
'-Wmissing-noreturn',
'-Wmissing-format-attribute',
'-Wlogical-op',
'-Wno-discarded-qualifiers',
'-Werror=implicit',
'-Werror=nonnull',
'-Werror=init-self',
'-Werror=main',
'-Werror=sequence-point',
'-Werror=return-type',
'-Werror=trigraphs',
'-Werror=array-bounds',
'-Werror=write-strings',
'-Werror=address',
'-Werror=int-to-pointer-cast',
'-Werror=pointer-to-int-cast',
'-Werror=empty-body',
'-Wsign-compare',
'-fno-strict-aliasing',
'-Wno-int-conversion',
'-Wno-missing-braces',
]
else
test_cflags = []
endif
common_cflags = cc.get_supported_arguments(test_cflags)
message('Building DCV Color Primitives')
if get_option('buildtype') == 'release'
dcp_build_dir = 'release'
cargo_target = ['build', '--release', ]
elif get_option('buildtype') == 'debugoptimized'
dcp_build_dir = 'release'
cargo_target = ['build', '--release', ]
else
dcp_build_dir = 'debug'
cargo_target = ['build', ]
endif
cargo_result = run_command('cargo', cargo_target, check: false)
message(cargo_result.stdout())
message(cargo_result.stderr())
if cargo_result.returncode() != 0
error('-- cargo build failed')
endif
dcp_lib_path = meson.source_root() / 'target' / dcp_build_dir
if is_win
static_lib_name = 'dcv_color_primitives.lib'
else
static_lib_name = 'libdcv_color_primitives.a'
endif
install_data(
dcp_lib_path / static_lib_name,
install_dir: libdir
)
thread_dep = dependency('threads')
dcv_color_primitives_dep = cc.find_library('dcv_color_primitives', dirs: [dcp_lib_path])
libm_dep = cc.find_library('m', required: is_win == false)
libdl_dep = cc.find_library('dl', required: is_win == false)
ws2_32_dep = cc.find_library('ws2_32', required: is_win)
userenv_dep = cc.find_library('userenv', required: is_win)
bcrypt_dep = cc.find_library('bcrypt', required: is_win)
ntdll_dep = cc.find_library('ntdll', required: is_win)
clock_gettime_test_code = '''
#include <time.h>
struct timespec t;
int main (int argc, char ** argv) {
return clock_gettime(CLOCK_REALTIME, &t);
}'''
librt_dep = []
if cc.links(clock_gettime_test_code, name : 'clock_gettime')
# nothing to link to
elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime in librt')
librt_dep = cc.find_library('rt')
endif
subdir('include')
subdir('c_tests')
# Generate pc file
pkgg = import('pkgconfig')
pkgg.generate(libraries: '${libdir}' / static_lib_name,
name: meson.project_name(),
subdirs: meson.project_name(),
description: 'DCV Color Primitives is a library to perform image color model conversion.')