William A. Kennington III | 9b171d9 | 2021-04-16 13:29:44 -0700 | [diff] [blame] | 1 | project( |
| 2 | 'stdplus', |
| 3 | 'cpp', |
| 4 | version: '0.1', |
Patrick Williams | 29f235f | 2023-07-17 10:13:19 -0500 | [diff] [blame] | 5 | meson_version: '>=1.1.1', |
William A. Kennington III | 9b171d9 | 2021-04-16 13:29:44 -0700 | [diff] [blame] | 6 | default_options: [ |
| 7 | 'warning_level=3', |
Patrick Williams | 29f235f | 2023-07-17 10:13:19 -0500 | [diff] [blame] | 8 | 'cpp_std=c++23', |
William A. Kennington III | 9b171d9 | 2021-04-16 13:29:44 -0700 | [diff] [blame] | 9 | 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), |
| 10 | 'examples=' + (meson.is_subproject() ? 'false' : 'true'), |
| 11 | ]) |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 12 | |
William A. Kennington III | 7613a5e | 2022-07-13 16:25:00 -0700 | [diff] [blame] | 13 | has_dl = false |
| 14 | if 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) |
| 20 | endif |
| 21 | if get_option('dl').enabled() and not has_dl |
| 22 | error('libdl support required') |
| 23 | endif |
| 24 | |
| 25 | has_fd = false |
| 26 | if not get_option('fd').disabled() |
| 27 | has_fd = true |
| 28 | endif |
| 29 | |
| 30 | has_io_uring = false |
| 31 | if 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 |
| 36 | endif |
| 37 | if get_option('io_uring').enabled() and not has_io_uring |
| 38 | error('io_uring support is required') |
| 39 | endif |
| 40 | |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 41 | build_tests = get_option('tests') |
| 42 | has_gtest = false |
| 43 | if 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 |
| 76 | endif |
| 77 | |
William A. Kennington III | 7613a5e | 2022-07-13 16:25:00 -0700 | [diff] [blame] | 78 | subdir('include') |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 79 | if has_dl |
| 80 | subdir('include-dl') |
| 81 | endif |
| 82 | if has_fd |
| 83 | subdir('include-fd') |
| 84 | endif |
| 85 | if has_io_uring |
| 86 | subdir('include-uring') |
| 87 | endif |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 88 | if has_gtest |
| 89 | subdir('include-gtest') |
| 90 | endif |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 91 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 92 | subdir('src') |
| 93 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 94 | build_examples = get_option('examples') |
| 95 | |
| 96 | if build_examples |
| 97 | subdir('example') |
| 98 | endif |
| 99 | if not build_tests.disabled() |
| 100 | subdir('test') |
| 101 | endif |