diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-07 09:12:22 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-07 09:13:15 +0200 |
| commit | c87f9627efc8b612eb9b000acfcc6731cad15765 (patch) | |
| tree | 34eb4b9e70a51c2f3db3a97c2aef31ba0b139ec9 /meson.build | |
Initial commit
Diffstat (limited to 'meson.build')
| -rw-r--r-- | meson.build | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..f98276c --- /dev/null +++ b/meson.build @@ -0,0 +1,185 @@ +project( + 'jkc', + 'cpp', + version : '0.1', + meson_version : '>= 1.3.0', + default_options : [ + 'warning_level=3', + 'cpp_std=c++26', + 'cpp_eh=none', + 'cpp_rtti=false', + 'default_library=static', + ], +) + +cpp_flags = [] +cpp_optional_flags = [] +if get_option('buildtype') == 'release' + # If asserts are disabled parameters and variables used for only that + # end up causing warnings + cpp_optional_flags += ['-Wno-unused-parameter', '-Wno-unused-variable', + '-Wno-unused-but-set-variable'] + cpp_flags += '-DNDEBUG' +endif +cpp = meson.get_compiler('cpp') +foreach flag : cpp_optional_flags + if cpp.has_argument(flag) + cpp_flags += flag + endif +endforeach +add_project_arguments([cpp_flags], language: 'cpp') + +conf_data = configuration_data() +conf_data.set('version', meson.project_version()) +configure_file(input: 'src/config.h.in', + output: 'config.h', + configuration : conf_data) + +dbus_dep = dependency('sdbus-c++', version: '>= 2.0.0') + +inc = include_directories('src') + +args_lib = library( + 'args', + sources: [ + 'src/args.cc', + 'src/args.hh', + ], + include_directories: inc, +) +args_dep = declare_dependency(link_with: args_lib) + +buffer_lib = library( + 'buffer', + sources: [ + 'src/buffer.cc', + 'src/buffer.hh', + ], + include_directories: inc, +) +buffer_dep = declare_dependency(link_with: buffer_lib) + +io_lib = library( + 'io', + sources: [ + 'src/line.cc', + 'src/line.hh', + 'src/io.cc', + 'src/io.hh', + 'src/unique_fd.cc', + 'src/unique_fd.hh', + ], + include_directories: inc, +) +io_dep = declare_dependency(link_with: io_lib) + +str_lib = library( + 'str', + sources: [ + 'src/str.cc', + 'src/str.hh', + ], + include_directories: inc, +) +str_dep = declare_dependency(link_with: str_lib) + +bluetooth_jukebox = executable( + 'bluetooth-jukebox', + sources: [ + 'src/main.cc', + ], + include_directories: inc, + install : true, + dependencies : [ + args_dep, + io_dep, + str_dep, + ], +) + +gtest_main_dep = dependency('gtest_main', fallback : ['gtest_main']) + +test_dependencies = [ + gtest_main_dep, +] + +test('args', executable( + 'test_args', + sources: ['test/args.cc'], + include_directories: inc, + dependencies: [ + args_dep, + test_dependencies, + ], +)) + +io_test_helper_lib = library( + 'io_test_helper', + sources: [ + 'test/io_test_helper.cc', + 'test/io_test_helper.hh', + ], + include_directories: inc, + dependencies: io_dep, +) +io_test_helper_dep = declare_dependency( + link_with: io_test_helper_lib, + dependencies: io_dep, +) + +test('line', executable( + 'test_line', + sources: ['test/line.cc'], + include_directories: inc, + dependencies: [ + io_dep, + io_test_helper_dep, + test_dependencies, + ], +)) + +test('str', executable( + 'test_str', + sources: ['test/str.cc'], + include_directories: inc, + dependencies: [ + str_dep, + test_dependencies, + ], +)) + +test('io', executable( + 'test_io', + sources: ['test/io.cc'], + include_directories: inc, + dependencies: [ + io_dep, + io_test_helper_dep, + test_dependencies, + ], +)) + +test('buffer', executable( + 'test_buffer', + sources: ['test/buffer.cc'], + include_directories: inc, + dependencies : [ + buffer_dep, + test_dependencies, + ], +)) + +run_clang_tidy = find_program('run-clang-tidy', required: false) + +if run_clang_tidy.found() + # The clang-tidy target generated by meson misses most of the + # source files, so create our own. + run_target( + 'clang-tidy', + command: [ + run_clang_tidy, + '-quiet', + '-use-color', + ], + ) +endif |
