blob: 48dce7194767bb1f0442076878f3624f1bb65c2b [file] [log] [blame]
Brad Bishopfeb19ef2019-11-07 18:02:16 -05001project(
2 'dbus-sensors',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Andrew Jefferyfbf92542021-05-27 15:00:47 +09307 'cpp_std=c++20'
Brad Bishopfeb19ef2019-11-07 18:02:16 -05008 ],
9 license: 'Apache-2.0',
10 version: '0.1',
Andrew Jefferyfbf92542021-05-27 15:00:47 +093011 meson_version: '>=0.57.0',
Brad Bishopfeb19ef2019-11-07 18:02:16 -050012)
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
Patrick Williams1889ebf2021-08-27 14:38:52 -050025cpp = meson.get_compiler('cpp')
26
Brad Bishopfeb19ef2019-11-07 18:02:16 -050027build_tests = get_option('tests')
Patrick Williams3911b822021-08-27 14:31:50 -050028gpiodcxx = dependency(
29 'libgpiodcxx',
30 fallback: ['libgpiod', 'gpiodcxx_dep'],
31 default_options: ['bindings=cxx'],
32)
Andrew Jeffery2d66c242021-05-27 12:57:50 +093033
34# i2c-tools doesn't ship a pkg-config file for libi2c
Brad Bishopfeb19ef2019-11-07 18:02:16 -050035i2c = meson.get_compiler('cpp').find_library('i2c')
Andrew Jeffery2d66c242021-05-27 12:57:50 +093036
Andrew Jeffery3f2e0522021-05-27 13:26:20 +093037sdbusplus = dependency(
38 'sdbusplus',
39 fallback: [
40 'sdbusplus',
41 'sdbusplus_dep'
42 ],
43)
44
Patrick Williams08d684a2021-08-27 15:15:34 -050045phosphor_logging_dep = dependency(
46 'phosphor-logging',
47 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
48)
49
Patrick Williams1889ebf2021-08-27 14:38:52 -050050if 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
Brad Bishopfeb19ef2019-11-07 18:02:16 -050062systemd = dependency('systemd')
Andrew Jefferyfbf92542021-05-27 15:00:47 +093063systemd_system_unit_dir = systemd.get_variable(
64 pkgconfig: 'systemdsystemunitdir',
65 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopfeb19ef2019-11-07 18:02:16 -050066threads = dependency('threads')
67
Patrick Williams302a61a2021-08-27 15:40:08 -050068default_deps = [
69 nlohmann_json,
Patrick Williams0c42f402021-08-27 16:05:45 -050070 phosphor_logging_dep,
Patrick Williams302a61a2021-08-27 15:40:08 -050071 sdbusplus,
72]
73
Brad Bishopfeb19ef2019-11-07 18:02:16 -050074thresholds_a = static_library(
75 'thresholds_a',
76 'src/Thresholds.cpp',
Patrick Williams302a61a2021-08-27 15:40:08 -050077 dependencies: default_deps,
Brad Bishopfeb19ef2019-11-07 18:02:16 -050078 implicit_include_directories: false,
79 include_directories: 'include',
80)
81
Patrick Williams8b8f6062021-08-27 14:53:50 -050082thresholds_dep = declare_dependency(
83 link_with: [ thresholds_a ],
Patrick Williams302a61a2021-08-27 15:40:08 -050084 dependencies: default_deps,
Patrick Williams8b8f6062021-08-27 14:53:50 -050085)
86
Brad Bishopfeb19ef2019-11-07 18:02:16 -050087utils_a = static_library(
88 'utils_a',
Ed Tanous6cb732a2021-02-18 15:33:51 -080089 ['src/Utils.cpp', 'src/SensorPaths.cpp'],
Patrick Williams302a61a2021-08-27 15:40:08 -050090 dependencies: default_deps,
Brad Bishopfeb19ef2019-11-07 18:02:16 -050091 implicit_include_directories: false,
92 include_directories: 'include',
93)
94
Patrick Williams8b8f6062021-08-27 14:53:50 -050095utils_dep = declare_dependency(
96 link_with: [ utils_a ],
97 dependencies: [ sdbusplus ],
98)
99
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500100pwmsensor_a = static_library(
101 'pwmsensor_a',
102 'src/PwmSensor.cpp',
Patrick Williams302a61a2021-08-27 15:40:08 -0500103 dependencies: [ default_deps, thresholds_dep ],
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500104 implicit_include_directories: false,
105 include_directories: 'include',
106)
107
Patrick Williams8b8f6062021-08-27 14:53:50 -0500108pwmsensor_dep = declare_dependency(
109 link_with: [ pwmsensor_a ],
Patrick Williams302a61a2021-08-27 15:40:08 -0500110 dependencies: [ default_deps, thresholds_dep ],
Patrick Williams8b8f6062021-08-27 14:53:50 -0500111)
112
Bruce Lee1263c3d2021-06-04 15:16:33 +0800113subdir('include')
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500114subdir('service_files')
115subdir('src')
116
117if not build_tests.disabled()
118 subdir('tests')
119endif