blob: 49d75751ca7e7a5d10acff808a4cbb86e6f8f8fb [file] [log] [blame]
William A. Kennington III9b171d92021-04-16 13:29:44 -07001project(
Patrick Williams6d592582025-02-01 08:37:30 -05002 'stdplus',
3 'cpp',
4 version: '0.1',
5 meson_version: '>=1.1.1',
6 default_options: [
7 'warning_level=3',
Alexander Hansenbe32aee2025-05-12 12:16:51 +02008 'werror=true',
Patrick Williams6d592582025-02-01 08:37:30 -05009 'cpp_std=c++23',
10 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
11 'examples=' + (meson.is_subproject() ? 'false' : 'true'),
12 ],
13)
William A. Kennington III15982f62019-01-31 14:43:41 -080014
William A. Kennington III7613a5e2022-07-13 16:25:00 -070015has_dl = false
16if not get_option('dl').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050017 dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
18 has_dl = meson.get_compiler('cpp').links(
19 '''
William A. Kennington III7613a5e2022-07-13 16:25:00 -070020 #include <dlfcn.h>
21 int main() { dlopen("", 0); }
Patrick Williams6d592582025-02-01 08:37:30 -050022 ''',
23 dependencies: dl_dep,
24 )
William A. Kennington III7613a5e2022-07-13 16:25:00 -070025endif
26if get_option('dl').enabled() and not has_dl
Patrick Williams6d592582025-02-01 08:37:30 -050027 error('libdl support required')
William A. Kennington III7613a5e2022-07-13 16:25:00 -070028endif
29
30has_fd = false
31if not get_option('fd').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050032 has_fd = true
William A. Kennington III7613a5e2022-07-13 16:25:00 -070033endif
34
35has_io_uring = false
36if not get_option('io_uring').disabled() and has_fd
Patrick Williams6d592582025-02-01 08:37:30 -050037 io_uring_dep = dependency('liburing', required: get_option('io_uring'))
38 if io_uring_dep.found()
39 has_io_uring = true
40 endif
William A. Kennington III7613a5e2022-07-13 16:25:00 -070041endif
42if get_option('io_uring').enabled() and not has_io_uring
Patrick Williams6d592582025-02-01 08:37:30 -050043 error('io_uring support is required')
William A. Kennington III7613a5e2022-07-13 16:25:00 -070044endif
45
William A. Kennington III953de362022-07-13 17:32:55 -070046build_tests = get_option('tests')
47has_gtest = false
48if not build_tests.disabled() or not get_option('gtest').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050049 gtest_dep = dependency('gtest', required: false)
50 gtest_main_dep = dependency('gtest', main: true, required: false)
51 gmock_dep = dependency('gmock', required: false)
52 if not gtest_dep.found() or not gmock_dep.found()
53 gtest_opts = import('cmake').subproject_options()
54 gtest_opts.add_cmake_defines(
55 {'BUILD_SHARED_LIBS': 'ON', 'CMAKE_CXX_FLAGS': '-Wno-pedantic'},
56 )
57 gtest_proj = import('cmake').subproject(
58 'googletest',
59 options: gtest_opts,
60 required: false,
61 )
62 if gtest_proj.found()
63 gtest_dep = declare_dependency(
64 dependencies: [
65 dependency('threads'),
66 gtest_proj.dependency('gtest'),
67 ],
68 )
69 gtest_main_dep = declare_dependency(
70 dependencies: [gtest_dep, gtest_proj.dependency('gtest_main')],
71 )
72 gmock_dep = gtest_proj.dependency('gmock')
73 else
74 assert(
75 not build_tests.enabled() and not get_option('gtest').enabled(),
76 'Googletest is required',
77 )
78 endif
William A. Kennington III953de362022-07-13 17:32:55 -070079 endif
Patrick Williams6d592582025-02-01 08:37:30 -050080 if not get_option('gtest').disabled() and gtest_dep.found()
81 has_gtest = true
82 endif
William A. Kennington III953de362022-07-13 17:32:55 -070083endif
84
William A. Kennington III7613a5e2022-07-13 16:25:00 -070085subdir('include')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070086if has_dl
Patrick Williams6d592582025-02-01 08:37:30 -050087 subdir('include-dl')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070088endif
89if has_fd
Patrick Williams6d592582025-02-01 08:37:30 -050090 subdir('include-fd')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070091endif
92if has_io_uring
Patrick Williams6d592582025-02-01 08:37:30 -050093 subdir('include-uring')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070094endif
William A. Kennington III953de362022-07-13 17:32:55 -070095if has_gtest
Patrick Williams6d592582025-02-01 08:37:30 -050096 subdir('include-gtest')
William A. Kennington III953de362022-07-13 17:32:55 -070097endif
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070098
William A. Kennington III15982f62019-01-31 14:43:41 -080099subdir('src')
100
William A. Kennington III15982f62019-01-31 14:43:41 -0800101build_examples = get_option('examples')
102
103if build_examples
Patrick Williams6d592582025-02-01 08:37:30 -0500104 subdir('example')
William A. Kennington III15982f62019-01-31 14:43:41 -0800105endif
106if not build_tests.disabled()
Patrick Williams6d592582025-02-01 08:37:30 -0500107 subdir('test')
William A. Kennington III15982f62019-01-31 14:43:41 -0800108endif