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 45phosphor_logging_dep = dependency( 46 'phosphor-logging', 47 fallback: ['phosphor-logging', 'phosphor_logging_dep'], 48) 49 50if cpp.has_header('nlohmann/json.hpp') 51 nlohmann_json = declare_dependency() 52else 53 subproject('nlohmann-json') 54 nlohmann_json = declare_dependency( 55 include_directories: include_directories( 56 'subprojects/nlohmann-json/single_include', 57 'subprojects/nlohmann-json/single_include/nlohmann', 58 ) 59 ) 60endif 61 62systemd = dependency('systemd') 63systemd_system_unit_dir = systemd.get_variable( 64 pkgconfig: 'systemdsystemunitdir', 65 pkgconfig_define: ['prefix', get_option('prefix')]) 66threads = dependency('threads') 67 68default_deps = [ 69 nlohmann_json, 70 sdbusplus, 71] 72 73thresholds_a = static_library( 74 'thresholds_a', 75 'src/Thresholds.cpp', 76 dependencies: default_deps, 77 implicit_include_directories: false, 78 include_directories: 'include', 79) 80 81thresholds_dep = declare_dependency( 82 link_with: [ thresholds_a ], 83 dependencies: default_deps, 84) 85 86utils_a = static_library( 87 'utils_a', 88 ['src/Utils.cpp', 'src/SensorPaths.cpp'], 89 dependencies: default_deps, 90 implicit_include_directories: false, 91 include_directories: 'include', 92) 93 94utils_dep = declare_dependency( 95 link_with: [ utils_a ], 96 dependencies: [ sdbusplus ], 97) 98 99pwmsensor_a = static_library( 100 'pwmsensor_a', 101 'src/PwmSensor.cpp', 102 dependencies: [ default_deps, thresholds_dep ], 103 implicit_include_directories: false, 104 include_directories: 'include', 105) 106 107pwmsensor_dep = declare_dependency( 108 link_with: [ pwmsensor_a ], 109 dependencies: [ default_deps, thresholds_dep ], 110) 111 112subdir('include') 113subdir('service_files') 114subdir('src') 115 116if not build_tests.disabled() 117 subdir('tests') 118endif 119