Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-objmgr', |
| 3 | 'c', 'cpp', |
| 4 | default_options: [ |
Brad Bishop | d6aa552 | 2022-05-31 19:23:48 -0400 | [diff] [blame] | 5 | 'buildtype=debugoptimized', |
Patrick Williams | 26ed980 | 2023-07-12 11:16:09 -0500 | [diff] [blame] | 6 | 'cpp_std=c++23', |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 7 | 'warning_level=3', |
| 8 | 'werror=true', |
| 9 | ], |
| 10 | license: 'Apache-2.0', |
Patrick Williams | 26ed980 | 2023-07-12 11:16:09 -0500 | [diff] [blame] | 11 | meson_version: '>=1.1.1', |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 12 | version: '1.0', |
| 13 | ) |
| 14 | |
Brad Bishop | 8c24362 | 2022-07-11 11:21:50 -0400 | [diff] [blame] | 15 | cxx = meson.get_compiler('cpp') |
| 16 | |
| 17 | if cxx.has_header('CLI/CLI.hpp') |
| 18 | cli11_dep = declare_dependency() |
| 19 | else |
| 20 | cli11_dep = dependency('cli11') |
| 21 | endif |
Patrick Williams | f814e5b | 2022-03-21 11:14:17 -0500 | [diff] [blame] | 22 | phosphor_logging = dependency('phosphor-logging') |
Brad Bishop | 5962db5 | 2022-05-16 21:04:05 -0400 | [diff] [blame] | 23 | phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') |
Patrick Williams | f814e5b | 2022-03-21 11:14:17 -0500 | [diff] [blame] | 24 | sdbusplus = dependency('sdbusplus') |
Ed Tanous | 26ed4a1 | 2022-07-13 13:46:08 -0700 | [diff] [blame] | 25 | boost = dependency('boost', version : '>=1.79.0', required: false, include_type: 'system') |
| 26 | if not boost.found() |
| 27 | subproject('boost', required: false) |
| 28 | boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true) |
| 29 | boost = declare_dependency(include_directories : boost_inc) |
| 30 | boost = boost.as_system('system') |
| 31 | endif |
Brad Bishop | d6aa552 | 2022-05-31 19:23:48 -0400 | [diff] [blame] | 32 | |
| 33 | if get_option('buildtype').startswith('debug') |
| 34 | add_project_arguments('-DMAPPER_ENABLE_DEBUG', language : 'cpp') |
| 35 | endif |
| 36 | |
Patrick Williams | ec87407 | 2023-11-29 06:45:19 -0600 | [diff] [blame] | 37 | if get_option('tests').allowed() |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 38 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 39 | gmock = dependency('gmock', disabler: true, required: false) |
| 40 | if not gtest.found() or not gmock.found() |
| 41 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 42 | if gtest_proj.found() |
| 43 | gtest = declare_dependency( |
| 44 | dependencies: [ |
| 45 | dependency('threads'), |
| 46 | gtest_proj.dependency('gtest'), |
| 47 | gtest_proj.dependency('gtest_main'), |
| 48 | ] |
| 49 | ) |
| 50 | gmock = gtest_proj.dependency('gmock') |
| 51 | else |
| 52 | assert( |
Patrick Williams | ec87407 | 2023-11-29 06:45:19 -0600 | [diff] [blame] | 53 | not get_option('tests').allowed(), |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 54 | 'Googletest is required if tests are enabled' |
| 55 | ) |
| 56 | endif |
| 57 | endif |
| 58 | subdir('src/test') |
| 59 | subdir('libmapper/test') |
| 60 | endif |
| 61 | |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 62 | install_headers('libmapper/mapper.h') |
| 63 | |
| 64 | libmapper = library( |
| 65 | 'mapper', |
| 66 | 'libmapper/mapper.c', |
| 67 | dependencies: [ dependency('libsystemd') ], |
| 68 | gnu_symbol_visibility: 'hidden', |
| 69 | version: meson.project_version(), |
| 70 | install: true) |
| 71 | |
Patrick Williams | d488775 | 2022-06-16 11:29:08 -0500 | [diff] [blame] | 72 | mapper_dep = declare_dependency( |
| 73 | link_with: libmapper, |
| 74 | include_directories: include_directories('libmapper'), |
| 75 | dependencies: [ dependency('libsystemd') ], |
| 76 | ) |
| 77 | |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 78 | import('pkgconfig').generate( |
| 79 | name: 'libmapper', |
| 80 | description: 'OpenBMC service discovery utility library', |
| 81 | version: meson.project_version(), |
| 82 | libraries: libmapper) |
| 83 | |
| 84 | executable( |
| 85 | 'mapper', |
| 86 | 'libmapper/app.c', |
| 87 | link_with: libmapper, |
| 88 | dependencies: [ dependency('libsystemd') ], |
| 89 | install: true) |
| 90 | |
Andrew Jeffery | fb85366 | 2024-05-03 14:54:11 +0930 | [diff] [blame] | 91 | mapperx = executable( |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 92 | 'mapperx', |
| 93 | [ |
| 94 | 'src/main.cpp', |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 95 | 'src/processing.cpp', |
| 96 | 'src/associations.cpp', |
Willy Tu | aba14d3 | 2023-01-31 14:19:59 -0800 | [diff] [blame] | 97 | 'src/handler.cpp', |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 98 | ], |
| 99 | dependencies: [ |
Ed Tanous | 26ed4a1 | 2022-07-13 13:46:08 -0700 | [diff] [blame] | 100 | boost, |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 101 | dependency('libsystemd'), |
Brad Bishop | 5962db5 | 2022-05-16 21:04:05 -0400 | [diff] [blame] | 102 | phosphor_dbus_interfaces, |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 103 | phosphor_logging, |
| 104 | sdbusplus, |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 105 | dependency('threads'), |
Konstantin Aladyshev | 883d91d | 2024-04-03 12:38:37 +0300 | [diff] [blame] | 106 | dependency('tinyxml2', default_options: ['tests=false']), |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 107 | ], |
Brad Bishop | 2ec9157 | 2022-06-03 08:52:11 -0400 | [diff] [blame] | 108 | install: true, |
| 109 | install_dir: join_paths( |
| 110 | get_option('prefix'), get_option('libexecdir'), meson.project_name()) |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 111 | ) |
Andrew Jeffery | fb85366 | 2024-05-03 14:54:11 +0930 | [diff] [blame] | 112 | meson.override_find_program('mapperx', mapperx) |
Brad Bishop | 0aa1590 | 2019-05-08 21:30:01 -0400 | [diff] [blame] | 113 | |
Brad Bishop | 2ec9157 | 2022-06-03 08:52:11 -0400 | [diff] [blame] | 114 | systemd_system_unit_dir = dependency('systemd').get_variable( |
Patrick Williams | 4030274 | 2023-04-12 08:01:37 -0500 | [diff] [blame] | 115 | 'systemdsystemunitdir' |
Brad Bishop | 2ec9157 | 2022-06-03 08:52:11 -0400 | [diff] [blame] | 116 | ) |
| 117 | |
| 118 | conf = configuration_data() |
| 119 | conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir'))) |
| 120 | conf.set('LIBEXECDIR', join_paths( |
| 121 | get_option('prefix'), get_option('libexecdir'))) |
| 122 | |
| 123 | unit_files = [ |
| 124 | 'xyz.openbmc_project.ObjectMapper.service', |
| 125 | 'mapper-subtree-remove@.service', |
| 126 | 'mapper-wait@.service' |
| 127 | ] |
| 128 | |
| 129 | foreach u : unit_files |
| 130 | configure_file( |
| 131 | configuration: conf, |
| 132 | input : join_paths('src/systemd', u) + '.in', |
| 133 | install : true, |
| 134 | install_dir: systemd_system_unit_dir, |
| 135 | output : u |
| 136 | ) |
| 137 | endforeach |
| 138 | |
| 139 | dbus_system_bus_services_dir = dependency('dbus-1').get_variable( |
Patrick Williams | 4030274 | 2023-04-12 08:01:37 -0500 | [diff] [blame] | 140 | 'system_bus_services_dir', |
Brad Bishop | 2ec9157 | 2022-06-03 08:52:11 -0400 | [diff] [blame] | 141 | pkgconfig_define: ['prefix', get_option('prefix')] |
| 142 | ) |
| 143 | |
| 144 | install_data( |
| 145 | 'src/dbus/xyz.openbmc_project.ObjectMapper.service', |
| 146 | install_dir: dbus_system_bus_services_dir) |
| 147 | |
| 148 | install_data( |
| 149 | 'src/dbus/xyz.openbmc_project.ObjectMapper.conf', |
| 150 | install_dir: get_option('datadir') / 'dbus-1' / 'system.d') |
| 151 | |
Brad Bishop | 42e5aee | 2023-02-03 13:57:33 -0500 | [diff] [blame] | 152 | if not get_option('unit-failure-monitor').disabled() |
| 153 | executable( |
| 154 | 'phosphor-unit-failure-monitor', |
| 155 | [ |
| 156 | 'fail-monitor/main.cpp', |
| 157 | 'fail-monitor/monitor.cpp', |
| 158 | ], |
| 159 | dependencies: [ |
| 160 | cli11_dep, |
| 161 | phosphor_logging, |
| 162 | ], |
| 163 | install: true |
| 164 | ) |
| 165 | endif |