-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmeson.build
97 lines (80 loc) · 2.43 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
project('libcubescript', ['cpp'],
version: '1.0.0',
default_options: [
'buildtype=debugoptimized', 'warning_level=3', 'cpp_rtti=false',
'cpp_std=none'
],
meson_version: '>=0.50'
)
dir_prefix = get_option('prefix')
dir_include = join_paths(dir_prefix, get_option('includedir'))
dir_data = join_paths(dir_prefix, get_option('datadir'))
dir_lib = join_paths(dir_prefix, get_option('libdir'))
dir_package_include = join_paths(dir_include, 'cubescript')
libcubescript_includes = [include_directories('include')]
cxx = meson.get_compiler('cpp')
extra_cxxflags = []
if get_option('buildtype') != 'plain'
if cxx.has_argument('-Wshadow')
extra_cxxflags += '-Wshadow'
endif
if cxx.has_argument('-Wold-style-cast')
extra_cxxflags += '-Wold-style-cast'
endif
endif
# Meson does not support C++20 std in a portable way in this version
# unless specified explicitly, have our own logic which will guess it
if get_option('cpp_std') == 'none'
if cxx.has_argument('-std=c++20')
# modern gcc/clang
extra_cxxflags += '-std=c++20'
elif cxx.has_argument('-std=c++2a')
# older gcc/clang
extra_cxxflags += '-std=c++2a'
elif cxx.has_argument('/std:c++20')
# future msvc++? not supported anywhere yet
extra_cxxflags += '/std:c++20'
elif cxx.has_argument('/std:c++latest')
# msvc++ 2019
extra_cxxflags += '/std:c++latest'
endif
endif
build_root = meson.current_build_dir()
thr_prog = '''
#include <cubescript/cubescript.hh>
#if ! LIBCUBESCRIPT_CONF_THREAD_SAFE
#error "not thread-safe"
#endif
int main() {}
'''
if cxx.compiles(
thr_prog,
include_directories: libcubescript_includes,
args: extra_cxxflags
)
message('libcubescript: using threads...')
thr_dep = dependency('threads')
else
message('libcubescript: not using threads...')
thr_dep = dependency('', required: false)
endif
subdir('include')
subdir('src')
subdir('tools')
if meson.is_cross_build() and get_option('tests')
build_tests = get_option('tests_cross')
else
build_tests = get_option('tests')
endif
if build_tests
subdir('tests')
endif
pkg = import('pkgconfig')
pkg.generate(
libraries: libcubescript_target,
version: meson.project_version(),
name: 'libcubescript',
filebase: 'libcubescript',
url: 'https://git.octaforge.org/octaforge/libcubescript',
description: 'An embeddable version of the CubeScript language'
)