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') md_dep = dependency('libmd', version: '>= 1.0.0', required: false) openssl_dep = dependency('openssl', version: '>= 1.0.0', required: false) 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], ) logger_lib = library( 'logger', sources: [ 'src/logger.cc', 'src/logger.hh', ], include_directories: inc, ) logger_dep = declare_dependency(link_with: logger_lib) looper_lib = library( 'looper', sources: [ 'src/looper_poll.cc', 'src/looper.hh', ], include_directories: inc, dependencies: [logger_dep], ) looper_dep = declare_dependency( link_with: looper_lib, dependencies: [logger_dep], ) http_lib = library( 'http', sources: [ 'src/http.cc', 'src/http.hh', ], include_directories: inc, dependencies: [buffer_dep, logger_dep, looper_dep], ) http_dep = declare_dependency( link_with: http_lib, dependencies: [buffer_dep, logger_dep, looper_dep], ) bt_lib = library( 'bt', sources: [ 'src/bt.cc', 'src/bt.hh', ], include_directories: inc, dependencies: [logger_dep, looper_dep, dbus_dep], ) bt_dep = declare_dependency( link_with: bt_lib, dependencies: [logger_dep, looper_dep, dbus_dep], ) signals_lib = library( 'signals', sources: [ 'src/signals.cc', 'src/signals.hh', ], include_directories: inc, dependencies: [io_dep, looper_dep], ) signals_dep = declare_dependency( link_with: signals_lib, dependencies: [io_dep, looper_dep], ) json_lib = library( 'json', sources: [ 'src/json.cc', 'src/json.hh', ], include_directories: inc, ) json_dep = declare_dependency( link_with: json_lib, ) base64_lib = library( 'base64', sources: [ 'src/base64.cc', 'src/base64.hh', ], include_directories: inc, ) base64_dep = declare_dependency( link_with: base64_lib, ) if md_dep.found() sha1_inner_source = 'src/sha1_md.cc' sha1_inner_dep = md_dep elif openssl_dep.found() sha1_inner_source = 'src/sha1_openssl.cc' sha1_inner_dep = openssl_dep else error('Need a library with SHA-1, either openssl or libmd') endif sha1_lib = library( 'sha1', sources: [ 'src/sha1.cc', 'src/sha1.hh', sha1_inner_source, ], include_directories: inc, dependencies: [sha1_inner_dep], ) sha1_dep = declare_dependency( link_with: sha1_lib, dependencies: [sha1_inner_dep], ) uri_lib = library( 'uri', sources: [ 'src/u.hh', 'src/u8.hh', 'src/uri.cc', 'src/uri.hh', ], include_directories: inc, ) uri_dep = declare_dependency( link_with: uri_lib, ) websocket_lib = library( 'websocket', sources: [ 'src/websocket.cc', 'src/websocket.hh', ], include_directories: inc, dependencies: [base64_dep, looper_dep, logger_dep, str_dep, sha1_dep], ) websocket_dep = declare_dependency( link_with: websocket_lib, dependencies: [base64_dep, looper_dep, logger_dep, str_dep, sha1_dep], ) bluetooth_jukebox = executable( 'bluetooth-jukebox', sources: [ 'src/main.cc', ], include_directories: inc, install : true, dependencies : [ args_dep, bt_dep, cfg_dep, http_dep, json_dep, looper_dep, signals_dep, uri_dep, websocket_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, ], )) test('json', executable( 'test_json', sources: ['test/json.cc'], include_directories: inc, dependencies : [ json_dep, test_dependencies, ], )) test('base64', executable( 'test_base64', sources: ['test/base64.cc'], include_directories: inc, dependencies : [ base64_dep, test_dependencies, ], )) test('sha1', executable( 'test_sha1', sources: ['test/sha1.cc'], include_directories: inc, dependencies : [ sha1_dep, base64_dep, test_dependencies, ], )) test('uri', executable( 'test_uri', sources: ['test/uri.cc'], include_directories: inc, dependencies : [ uri_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