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 [ 92 'src/FileHandle.cpp', 93 'src/SensorPaths.cpp', 94 'src/Utils.cpp', 95 ], 96 dependencies: default_deps, 97 implicit_include_directories: false, 98 include_directories: 'include', 99) 100 101utils_dep = declare_dependency( 102 link_with: [ utils_a ], 103 dependencies: [ sdbusplus ], 104) 105 106pwmsensor_a = static_library( 107 'pwmsensor_a', 108 'src/PwmSensor.cpp', 109 dependencies: [ default_deps, thresholds_dep ], 110 implicit_include_directories: false, 111 include_directories: 'include', 112) 113 114pwmsensor_dep = declare_dependency( 115 link_with: [ pwmsensor_a ], 116 dependencies: [ default_deps, thresholds_dep ], 117) 118 119subdir('include') 120subdir('service_files') 121subdir('src') 122 123if not build_tests.disabled() 124 subdir('tests') 125endif 126