1project( 2 'dbus-sensors', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++20' 8 ], 9 license: 'Apache-2.0', 10 version: '0.1', 11 meson_version: '>=0.57.0', 12) 13 14add_project_arguments( 15 '-Wno-psabi', 16 '-Wuninitialized', 17 '-DBOOST_SYSTEM_NO_DEPRECATED', 18 '-DBOOST_ERROR_CODE_HEADER_ONLY', 19 '-DBOOST_NO_RTTI', 20 '-DBOOST_NO_TYPEID', 21 '-DBOOST_ALL_NO_LIB', 22 '-DBOOST_ASIO_DISABLE_THREADS', 23 '-DBOOST_ALLOW_DEPRECATED_HEADERS', 24 language: 'cpp', 25) 26 27cpp = meson.get_compiler('cpp') 28 29build_tests = get_option('tests') 30gpiodcxx = dependency( 31 'libgpiodcxx', 32 fallback: ['libgpiod', 'gpiodcxx_dep'], 33 default_options: ['bindings=cxx'], 34) 35 36# i2c-tools doesn't ship a pkg-config file for libi2c 37i2c = meson.get_compiler('cpp').find_library('i2c') 38 39sdbusplus = dependency( 40 'sdbusplus', 41 fallback: [ 42 'sdbusplus', 43 'sdbusplus_dep' 44 ], 45) 46 47phosphor_logging_dep = dependency( 48 'phosphor-logging', 49 fallback: ['phosphor-logging', 'phosphor_logging_dep'], 50) 51 52if cpp.has_header('nlohmann/json.hpp') 53 nlohmann_json = declare_dependency() 54else 55 subproject('nlohmann-json') 56 nlohmann_json = declare_dependency( 57 include_directories: include_directories( 58 'subprojects/nlohmann-json/single_include', 59 'subprojects/nlohmann-json/single_include/nlohmann', 60 ) 61 ) 62endif 63 64systemd = dependency('systemd') 65systemd_system_unit_dir = systemd.get_variable( 66 pkgconfig: 'systemdsystemunitdir', 67 pkgconfig_define: ['prefix', get_option('prefix')]) 68threads = dependency('threads') 69 70default_deps = [ 71 nlohmann_json, 72 phosphor_logging_dep, 73 sdbusplus, 74] 75 76thresholds_a = static_library( 77 'thresholds_a', 78 'src/Thresholds.cpp', 79 dependencies: default_deps, 80 implicit_include_directories: false, 81 include_directories: 'include', 82) 83 84thresholds_dep = declare_dependency( 85 link_with: [ thresholds_a ], 86 dependencies: default_deps, 87) 88 89utils_a = static_library( 90 'utils_a', 91 ['src/Utils.cpp', 'src/SensorPaths.cpp'], 92 dependencies: default_deps, 93 implicit_include_directories: false, 94 include_directories: 'include', 95) 96 97utils_dep = declare_dependency( 98 link_with: [ utils_a ], 99 dependencies: [ sdbusplus ], 100) 101 102pwmsensor_a = static_library( 103 'pwmsensor_a', 104 'src/PwmSensor.cpp', 105 dependencies: [ default_deps, thresholds_dep ], 106 implicit_include_directories: false, 107 include_directories: 'include', 108) 109 110pwmsensor_dep = declare_dependency( 111 link_with: [ pwmsensor_a ], 112 dependencies: [ default_deps, thresholds_dep ], 113) 114 115subdir('include') 116subdir('service_files') 117subdir('src') 118 119if not build_tests.disabled() 120 subdir('tests') 121endif 122