blob: 7e8a3e6b446f045394fa52c9e7c3d61fb5dbefe1 [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(
Andrew Jefferye3b23c02021-09-23 11:29:49 +093015 '-Wno-psabi',
Brad Bishopfeb19ef2019-11-07 18:02:16 -050016 '-DBOOST_SYSTEM_NO_DEPRECATED',
17 '-DBOOST_ERROR_CODE_HEADER_ONLY',
18 '-DBOOST_NO_RTTI',
19 '-DBOOST_NO_TYPEID',
20 '-DBOOST_ALL_NO_LIB',
21 '-DBOOST_ASIO_DISABLE_THREADS',
22 '-DBOOST_ALLOW_DEPRECATED_HEADERS',
23 language: 'cpp',
24)
25
Patrick Williams1889ebf2021-08-27 14:38:52 -050026cpp = meson.get_compiler('cpp')
27
Brad Bishopfeb19ef2019-11-07 18:02:16 -050028build_tests = get_option('tests')
Patrick Williams3911b822021-08-27 14:31:50 -050029gpiodcxx = dependency(
30 'libgpiodcxx',
31 fallback: ['libgpiod', 'gpiodcxx_dep'],
32 default_options: ['bindings=cxx'],
33)
Andrew Jeffery2d66c242021-05-27 12:57:50 +093034
35# i2c-tools doesn't ship a pkg-config file for libi2c
Brad Bishopfeb19ef2019-11-07 18:02:16 -050036i2c = meson.get_compiler('cpp').find_library('i2c')
Andrew Jeffery2d66c242021-05-27 12:57:50 +093037
Andrew Jeffery3f2e0522021-05-27 13:26:20 +093038sdbusplus = dependency(
39 'sdbusplus',
40 fallback: [
41 'sdbusplus',
42 'sdbusplus_dep'
43 ],
44)
45
Patrick Williams08d684a2021-08-27 15:15:34 -050046phosphor_logging_dep = dependency(
47 'phosphor-logging',
48 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
49)
50
Patrick Williams1889ebf2021-08-27 14:38:52 -050051if cpp.has_header('nlohmann/json.hpp')
52 nlohmann_json = declare_dependency()
53else
54 subproject('nlohmann-json')
55 nlohmann_json = declare_dependency(
56 include_directories: include_directories(
57 'subprojects/nlohmann-json/single_include',
58 'subprojects/nlohmann-json/single_include/nlohmann',
59 )
60 )
61endif
62
Brad Bishopfeb19ef2019-11-07 18:02:16 -050063systemd = dependency('systemd')
Andrew Jefferyfbf92542021-05-27 15:00:47 +093064systemd_system_unit_dir = systemd.get_variable(
65 pkgconfig: 'systemdsystemunitdir',
66 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopfeb19ef2019-11-07 18:02:16 -050067threads = dependency('threads')
68
Patrick Williams302a61a2021-08-27 15:40:08 -050069default_deps = [
70 nlohmann_json,
Patrick Williams0c42f402021-08-27 16:05:45 -050071 phosphor_logging_dep,
Patrick Williams302a61a2021-08-27 15:40:08 -050072 sdbusplus,
73]
74
Brad Bishopfeb19ef2019-11-07 18:02:16 -050075thresholds_a = static_library(
76 'thresholds_a',
77 'src/Thresholds.cpp',
Patrick Williams302a61a2021-08-27 15:40:08 -050078 dependencies: default_deps,
Brad Bishopfeb19ef2019-11-07 18:02:16 -050079 implicit_include_directories: false,
80 include_directories: 'include',
81)
82
Patrick Williams8b8f6062021-08-27 14:53:50 -050083thresholds_dep = declare_dependency(
84 link_with: [ thresholds_a ],
Patrick Williams302a61a2021-08-27 15:40:08 -050085 dependencies: default_deps,
Patrick Williams8b8f6062021-08-27 14:53:50 -050086)
87
Brad Bishopfeb19ef2019-11-07 18:02:16 -050088utils_a = static_library(
89 'utils_a',
Ed Tanous6cb732a2021-02-18 15:33:51 -080090 ['src/Utils.cpp', 'src/SensorPaths.cpp'],
Patrick Williams302a61a2021-08-27 15:40:08 -050091 dependencies: default_deps,
Brad Bishopfeb19ef2019-11-07 18:02:16 -050092 implicit_include_directories: false,
93 include_directories: 'include',
94)
95
Patrick Williams8b8f6062021-08-27 14:53:50 -050096utils_dep = declare_dependency(
97 link_with: [ utils_a ],
98 dependencies: [ sdbusplus ],
99)
100
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500101pwmsensor_a = static_library(
102 'pwmsensor_a',
103 'src/PwmSensor.cpp',
Patrick Williams302a61a2021-08-27 15:40:08 -0500104 dependencies: [ default_deps, thresholds_dep ],
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500105 implicit_include_directories: false,
106 include_directories: 'include',
107)
108
Patrick Williams8b8f6062021-08-27 14:53:50 -0500109pwmsensor_dep = declare_dependency(
110 link_with: [ pwmsensor_a ],
Patrick Williams302a61a2021-08-27 15:40:08 -0500111 dependencies: [ default_deps, thresholds_dep ],
Patrick Williams8b8f6062021-08-27 14:53:50 -0500112)
113
Bruce Lee1263c3d2021-06-04 15:16:33 +0800114subdir('include')
Brad Bishopfeb19ef2019-11-07 18:02:16 -0500115subdir('service_files')
116subdir('src')
117
118if not build_tests.disabled()
119 subdir('tests')
120endif