blob: 08de90982a860a1d291db9dcd812b65cb267c3f8 [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',
8 'cpp_std=c++23',
9 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
10 'examples=' + (meson.is_subproject() ? 'false' : 'true'),
11 ],
12)
William A. Kennington III15982f62019-01-31 14:43:41 -080013
William A. Kennington III7613a5e2022-07-13 16:25:00 -070014has_dl = false
15if not get_option('dl').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050016 dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
17 has_dl = meson.get_compiler('cpp').links(
18 '''
William A. Kennington III7613a5e2022-07-13 16:25:00 -070019 #include <dlfcn.h>
20 int main() { dlopen("", 0); }
Patrick Williams6d592582025-02-01 08:37:30 -050021 ''',
22 dependencies: dl_dep,
23 )
William A. Kennington III7613a5e2022-07-13 16:25:00 -070024endif
25if get_option('dl').enabled() and not has_dl
Patrick Williams6d592582025-02-01 08:37:30 -050026 error('libdl support required')
William A. Kennington III7613a5e2022-07-13 16:25:00 -070027endif
28
29has_fd = false
30if not get_option('fd').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050031 has_fd = true
William A. Kennington III7613a5e2022-07-13 16:25:00 -070032endif
33
34has_io_uring = false
35if not get_option('io_uring').disabled() and has_fd
Patrick Williams6d592582025-02-01 08:37:30 -050036 io_uring_dep = dependency('liburing', required: get_option('io_uring'))
37 if io_uring_dep.found()
38 has_io_uring = true
39 endif
William A. Kennington III7613a5e2022-07-13 16:25:00 -070040endif
41if get_option('io_uring').enabled() and not has_io_uring
Patrick Williams6d592582025-02-01 08:37:30 -050042 error('io_uring support is required')
William A. Kennington III7613a5e2022-07-13 16:25:00 -070043endif
44
William A. Kennington III953de362022-07-13 17:32:55 -070045build_tests = get_option('tests')
46has_gtest = false
47if not build_tests.disabled() or not get_option('gtest').disabled()
Patrick Williams6d592582025-02-01 08:37:30 -050048 gtest_dep = dependency('gtest', required: false)
49 gtest_main_dep = dependency('gtest', main: true, required: false)
50 gmock_dep = dependency('gmock', required: false)
51 if not gtest_dep.found() or not gmock_dep.found()
52 gtest_opts = import('cmake').subproject_options()
53 gtest_opts.add_cmake_defines(
54 {'BUILD_SHARED_LIBS': 'ON', 'CMAKE_CXX_FLAGS': '-Wno-pedantic'},
55 )
56 gtest_proj = import('cmake').subproject(
57 'googletest',
58 options: gtest_opts,
59 required: false,
60 )
61 if gtest_proj.found()
62 gtest_dep = declare_dependency(
63 dependencies: [
64 dependency('threads'),
65 gtest_proj.dependency('gtest'),
66 ],
67 )
68 gtest_main_dep = declare_dependency(
69 dependencies: [gtest_dep, gtest_proj.dependency('gtest_main')],
70 )
71 gmock_dep = gtest_proj.dependency('gmock')
72 else
73 assert(
74 not build_tests.enabled() and not get_option('gtest').enabled(),
75 'Googletest is required',
76 )
77 endif
William A. Kennington III953de362022-07-13 17:32:55 -070078 endif
Patrick Williams6d592582025-02-01 08:37:30 -050079 if not get_option('gtest').disabled() and gtest_dep.found()
80 has_gtest = true
81 endif
William A. Kennington III953de362022-07-13 17:32:55 -070082endif
83
William A. Kennington III7613a5e2022-07-13 16:25:00 -070084subdir('include')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070085if has_dl
Patrick Williams6d592582025-02-01 08:37:30 -050086 subdir('include-dl')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070087endif
88if has_fd
Patrick Williams6d592582025-02-01 08:37:30 -050089 subdir('include-fd')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070090endif
91if has_io_uring
Patrick Williams6d592582025-02-01 08:37:30 -050092 subdir('include-uring')
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070093endif
William A. Kennington III953de362022-07-13 17:32:55 -070094if has_gtest
Patrick Williams6d592582025-02-01 08:37:30 -050095 subdir('include-gtest')
William A. Kennington III953de362022-07-13 17:32:55 -070096endif
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070097
William A. Kennington III15982f62019-01-31 14:43:41 -080098subdir('src')
99
William A. Kennington III15982f62019-01-31 14:43:41 -0800100build_examples = get_option('examples')
101
102if build_examples
Patrick Williams6d592582025-02-01 08:37:30 -0500103 subdir('example')
William A. Kennington III15982f62019-01-31 14:43:41 -0800104endif
105if not build_tests.disabled()
Patrick Williams6d592582025-02-01 08:37:30 -0500106 subdir('test')
William A. Kennington III15982f62019-01-31 14:43:41 -0800107endif