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) paths_lib = library( 'paths', sources: [ 'src/paths.cc', 'src/paths.hh', ], include_directories: inc, dependencies: [str_dep], ) paths_dep = declare_dependency( link_with: paths_lib, dependencies: [str_dep], ) cfg_lib = library( 'cfg', sources: [ 'src/cfg.cc', 'src/cfg.hh', ], include_directories: inc, dependencies: [io_dep, paths_dep, str_dep], ) cfg_dep = declare_dependency( link_with: cfg_lib, dependencies: [io_dep, paths_dep, str_dep], ) bluetooth_jukebox = executable( 'bluetooth-jukebox', sources: [ 'src/main.cc', ], include_directories: inc, install : true, dependencies : [ args_dep, cfg_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, ) testdir_lib = library( 'testdir', sources: [ 'test/testdir.cc', 'test/testdir.hh', ], include_directories: inc, ) testdir_dep = declare_dependency(link_with: testdir_lib) testenv_lib = library( 'testenv', sources: [ 'test/testenv.cc', 'test/testenv.hh', ], include_directories: inc, ) testenv_dep = declare_dependency(link_with: testenv_lib) 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, ], )) test('paths', executable( 'test_paths', sources: ['test/paths.cc'], include_directories: inc, dependencies : [ paths_dep, test_dependencies, testenv_dep, ], )) test('cfg', executable( 'test_cfg', sources: ['test/cfg.cc'], include_directories: inc, dependencies : [ cfg_dep, test_dependencies, testdir_dep, testenv_dep, ], )) 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