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 '-DBOOST_SYSTEM_NO_DEPRECATED', 16 '-DBOOST_ERROR_CODE_HEADER_ONLY', 17 '-DBOOST_NO_RTTI', 18 '-DBOOST_NO_TYPEID', 19 '-DBOOST_ALL_NO_LIB', 20 '-DBOOST_ASIO_DISABLE_THREADS', 21 '-DBOOST_ALLOW_DEPRECATED_HEADERS', 22 language: 'cpp', 23) 24 25cpp = meson.get_compiler('cpp') 26 27build_tests = get_option('tests') 28gpiodcxx = dependency( 29 'libgpiodcxx', 30 fallback: ['libgpiod', 'gpiodcxx_dep'], 31 default_options: ['bindings=cxx'], 32) 33 34# i2c-tools doesn't ship a pkg-config file for libi2c 35i2c = meson.get_compiler('cpp').find_library('i2c') 36 37sdbusplus = dependency( 38 'sdbusplus', 39 fallback: [ 40 'sdbusplus', 41 'sdbusplus_dep' 42 ], 43) 44 45if cpp.has_header('nlohmann/json.hpp') 46 nlohmann_json = declare_dependency() 47else 48 subproject('nlohmann-json') 49 nlohmann_json = declare_dependency( 50 include_directories: include_directories( 51 'subprojects/nlohmann-json/single_include', 52 'subprojects/nlohmann-json/single_include/nlohmann', 53 ) 54 ) 55endif 56 57systemd = dependency('systemd') 58systemd_system_unit_dir = systemd.get_variable( 59 pkgconfig: 'systemdsystemunitdir', 60 pkgconfig_define: ['prefix', get_option('prefix')]) 61threads = dependency('threads') 62 63default_deps = [ 64 nlohmann_json, 65 sdbusplus, 66] 67 68thresholds_a = static_library( 69 'thresholds_a', 70 'src/Thresholds.cpp', 71 dependencies: default_deps, 72 implicit_include_directories: false, 73 include_directories: 'include', 74) 75 76thresholds_dep = declare_dependency( 77 link_with: [ thresholds_a ], 78 dependencies: default_deps, 79) 80 81utils_a = static_library( 82 'utils_a', 83 ['src/Utils.cpp', 'src/SensorPaths.cpp'], 84 dependencies: default_deps, 85 implicit_include_directories: false, 86 include_directories: 'include', 87) 88 89utils_dep = declare_dependency( 90 link_with: [ utils_a ], 91 dependencies: [ sdbusplus ], 92) 93 94pwmsensor_a = static_library( 95 'pwmsensor_a', 96 'src/PwmSensor.cpp', 97 dependencies: [ default_deps, thresholds_dep ], 98 implicit_include_directories: false, 99 include_directories: 'include', 100) 101 102pwmsensor_dep = declare_dependency( 103 link_with: [ pwmsensor_a ], 104 dependencies: [ default_deps, thresholds_dep ], 105) 106 107subdir('include') 108subdir('service_files') 109subdir('src') 110 111if not build_tests.disabled() 112 subdir('tests') 113endif 114