blob: 7b10cbd10f34b477bf31195eccf587e078d15bf2 [file] [log] [blame]
William A. Kennington III9b171d92021-04-16 13:29:44 -07001project(
2 'stdplus',
3 'cpp',
4 version: '0.1',
Patrick Williams29f235f2023-07-17 10:13:19 -05005 meson_version: '>=1.1.1',
William A. Kennington III9b171d92021-04-16 13:29:44 -07006 default_options: [
7 'warning_level=3',
Patrick Williams29f235f2023-07-17 10:13:19 -05008 'cpp_std=c++23',
William A. Kennington III9b171d92021-04-16 13:29:44 -07009 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
10 'examples=' + (meson.is_subproject() ? 'false' : 'true'),
11 ])
William A. Kennington III15982f62019-01-31 14:43:41 -080012
William A. Kennington III7613a5e2022-07-13 16:25:00 -070013has_dl = false
14if not get_option('dl').disabled()
15 dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
16 has_dl = meson.get_compiler('cpp').links('''
17 #include <dlfcn.h>
18 int main() { dlopen("", 0); }
19 ''', dependencies: dl_dep)
20endif
21if get_option('dl').enabled() and not has_dl
22 error('libdl support required')
23endif
24
25has_fd = false
26if not get_option('fd').disabled()
27 has_fd = true
28endif
29
30has_io_uring = false
31if not get_option('io_uring').disabled() and has_fd
32 io_uring_dep = dependency('liburing', required: get_option('io_uring'))
33 if io_uring_dep.found()
34 has_io_uring = true
35 endif
36endif
37if get_option('io_uring').enabled() and not has_io_uring
38 error('io_uring support is required')
39endif
40
William A. Kennington III953de362022-07-13 17:32:55 -070041build_tests = get_option('tests')
42has_gtest = false
43if not build_tests.disabled() or not get_option('gtest').disabled()
44 gtest_dep = dependency('gtest', required: false)
45 gtest_main_dep = dependency('gtest', main: true, required: false)
46 gmock_dep = dependency('gmock', required: false)
47 if not gtest_dep.found() or not gmock_dep.found()
48 gtest_opts = import('cmake').subproject_options()
49 gtest_opts.add_cmake_defines({
50 'BUILD_SHARED_LIBS': 'ON',
51 'CMAKE_CXX_FLAGS': '-Wno-pedantic',
52 })
53 gtest_proj = import('cmake').subproject(
54 'googletest',
55 options: gtest_opts,
56 required: false)
57 if gtest_proj.found()
58 gtest_dep = declare_dependency(
59 dependencies: [
60 dependency('threads'),
61 gtest_proj.dependency('gtest'),
62 ])
63 gtest_main_dep = declare_dependency(
64 dependencies: [
65 gtest_dep,
66 gtest_proj.dependency('gtest_main'),
67 ])
68 gmock_dep = gtest_proj.dependency('gmock')
69 else
70 assert(not build_tests.enabled() and not get_option('gtest').enabled(), 'Googletest is required')
71 endif
72 endif
73 if not get_option('gtest').disabled() and gtest_dep.found()
74 has_gtest = true
75 endif
76endif
77
William A. Kennington III7613a5e2022-07-13 16:25:00 -070078subdir('include')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070079if has_dl
80 subdir('include-dl')
81endif
82if has_fd
83 subdir('include-fd')
84endif
85if has_io_uring
86 subdir('include-uring')
87endif
William A. Kennington III953de362022-07-13 17:32:55 -070088if has_gtest
89 subdir('include-gtest')
90endif
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070091
William A. Kennington III15982f62019-01-31 14:43:41 -080092subdir('src')
93
William A. Kennington III15982f62019-01-31 14:43:41 -080094build_examples = get_option('examples')
95
96if build_examples
97 subdir('example')
98endif
99if not build_tests.disabled()
100 subdir('test')
101endif