blob: 4c25e15a63423df9829d7b410897f2b831b466c7 [file] [log] [blame]
Patrick Williamsec807fc2025-02-03 14:13:00 -05001project(
2 'phosphor-bmc-code-mgmt',
3 'cpp',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05004 default_options: [
Gunnar Millsf7a69e12020-06-15 12:16:51 -05005 'buildtype=debugoptimized',
Patrick Williamsb9ecb2b2023-07-12 11:15:11 -05006 'cpp_std=c++23',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05007 'warning_level=3',
Patrick Williamsec807fc2025-02-03 14:13:00 -05008 'werror=true',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05009 ],
Patrick Williamsb9ecb2b2023-07-12 11:15:11 -050010 meson_version: '>=1.1.1',
Adriana Kobylak0af80a42020-05-05 13:32:10 -050011 license: 'Apache-2.0',
Patrick Williamsec807fc2025-02-03 14:13:00 -050012 version: '1.0',
13)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050014
Lei YU25868182021-05-14 14:50:51 +080015add_project_arguments(
16 '-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_ASIO_NO_DEPRECATED',
23 language: 'cpp',
24)
25
Patrick Williams40267022021-08-26 16:48:42 -050026cpp = meson.get_compiler('cpp')
27
Konstantin Aladyshevfa34e222024-04-02 17:12:40 +030028boost_dep = dependency('boost')
29
Patrick Williamsc026f6c2022-03-21 09:37:14 -050030sdbusplus_dep = dependency('sdbusplus')
31sdbusplusplus_prog = find_program('sdbus++', native: true)
32sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams40267022021-08-26 16:48:42 -050033
Patrick Williamsc026f6c2022-03-21 09:37:14 -050034pdi_dep = dependency('phosphor-dbus-interfaces')
35phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams40267022021-08-26 16:48:42 -050036
37cereal_dep = dependency('cereal', required: false)
38has_cereal = cpp.has_header_symbol(
39 'cereal/cereal.hpp',
40 'cereal::specialize',
41 dependencies: cereal_dep,
Patrick Williamsec807fc2025-02-03 14:13:00 -050042 required: false,
43)
Patrick Williams40267022021-08-26 16:48:42 -050044if not has_cereal
45 cereal_opts = import('cmake').subproject_options()
Patrick Williamsec807fc2025-02-03 14:13:00 -050046 cereal_opts.add_cmake_defines(
47 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
48 )
Patrick Williams40267022021-08-26 16:48:42 -050049 cereal_proj = import('cmake').subproject(
50 'cereal',
51 options: cereal_opts,
Patrick Williamsec807fc2025-02-03 14:13:00 -050052 required: false,
53 )
Patrick Williams40267022021-08-26 16:48:42 -050054 assert(cereal_proj.found(), 'cereal is required')
55 cereal_dep = cereal_proj.dependency('cereal')
56endif
57
Patrick Williamsec807fc2025-02-03 14:13:00 -050058deps = [cereal_dep, pdi_dep, phosphor_logging_dep, sdbusplus_dep]
Adriana Kobylake0aa7802020-05-05 13:54:49 -050059
Patrick Williamsf899aed2025-07-08 10:13:34 -040060ssl_dep = dependency('openssl')
Adriana Kobylake0aa7802020-05-05 13:54:49 -050061
Jagpal Singh Gille7931502025-07-11 18:55:00 -070062systemd_dep = dependency('systemd')
63systemd_system_unit_dir = systemd_dep.get_variable(
Patrick Williams5afc9aa2025-07-08 10:15:46 -040064 'systemd_system_unit_dir',
65 pkgconfig_define: ['prefix', get_option('prefix')],
66)
Adriana Kobylak29a0d902020-05-05 13:59:49 -050067
Alexander Hansen4a053c82024-11-26 17:02:39 +010068build_tests = get_option('tests')
69
Alexander Hansen4a053c82024-11-26 17:02:39 +010070common_include = include_directories('.')
71
Patrick Williamsa02807c2025-07-08 10:55:34 -040072subdir('bmc')
Alexander Hansencc372352025-01-14 14:15:39 +010073
Patrick Williamsa02807c2025-07-08 10:55:34 -040074
75all_options = {
76 'bios-software-update': {'dirs' : ['bios'], 'deps': ['libgpiod']},
77 'cpld-software-update': {'dirs' : ['common/i2c', 'cpld']},
78 'eepromdevice-software-update': {
79 'dirs': ['eeprom-device'],
80 'deps': ['libgpiod'],
81 },
82 'i2cvr-software-update': {'dirs' : ['common/i2c', 'i2c-vr']},
Kevin Tungc5387272025-07-28 18:10:43 +080083 'tpm-software-update': {'dirs': ['tpm']},
Patrick Williamsa02807c2025-07-08 10:55:34 -040084}
85
86optioned_subdirs = []
87optioned_deps = []
88common_build = false
89
90foreach option_name, option_settings : all_options
91 if get_option(option_name).allowed()
92 common_build = true
93
94 foreach dir : option_settings.get('dirs', [])
95 if not optioned_subdirs.contains(dir)
96 optioned_subdirs += dir
97 endif
98 endforeach
99
100 foreach dep : option_settings.get('deps', [])
101 if not optioned_deps.contains(dep)
102 optioned_deps += dep
103 endif
104 endforeach
105 endif
106endforeach
107
108if common_build or build_tests.allowed()
Alexander Hansen192bb5d2025-02-27 11:28:15 +0100109 libpldm_dep = dependency('libpldm')
Patrick Williamsa7bf31b2025-07-08 10:08:25 -0400110 subdir('common')
111endif
Alexander Hansencc372352025-01-14 14:15:39 +0100112
Patrick Williamsa02807c2025-07-08 10:55:34 -0400113if optioned_deps.contains('libgpiod')
Patrick Williamsa7bf31b2025-07-08 10:08:25 -0400114 libgpiod_dep = dependency(
Alexander Hansenf2c95a02024-11-26 11:16:44 +0100115 'libgpiodcxx',
116 default_options: ['bindings=cxx'],
117 version: '>=1.1.2',
118 )
Alexander Hansencc372352025-01-14 14:15:39 +0100119endif
120
Patrick Williamsa02807c2025-07-08 10:55:34 -0400121foreach dir : optioned_subdirs
122 subdir(dir)
123endforeach
Daniel Hsuf6470b52025-02-26 15:03:47 +0800124
Alexander Hansen88b98bf2025-01-29 17:18:51 +0100125if build_tests.allowed()
Alexander Hansen192bb5d2025-02-27 11:28:15 +0100126 subdir('test')
Alexander Hansen4a053c82024-11-26 17:02:39 +0100127endif