blob: e8a2f4fa7484684300e850e54da24da294644f32 [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']},
83}
84
85optioned_subdirs = []
86optioned_deps = []
87common_build = false
88
89foreach option_name, option_settings : all_options
90 if get_option(option_name).allowed()
91 common_build = true
92
93 foreach dir : option_settings.get('dirs', [])
94 if not optioned_subdirs.contains(dir)
95 optioned_subdirs += dir
96 endif
97 endforeach
98
99 foreach dep : option_settings.get('deps', [])
100 if not optioned_deps.contains(dep)
101 optioned_deps += dep
102 endif
103 endforeach
104 endif
105endforeach
106
107if common_build or build_tests.allowed()
Alexander Hansen192bb5d2025-02-27 11:28:15 +0100108 libpldm_dep = dependency('libpldm')
Patrick Williamsa7bf31b2025-07-08 10:08:25 -0400109 subdir('common')
110endif
Alexander Hansencc372352025-01-14 14:15:39 +0100111
Patrick Williamsa02807c2025-07-08 10:55:34 -0400112if optioned_deps.contains('libgpiod')
Patrick Williamsa7bf31b2025-07-08 10:08:25 -0400113 libgpiod_dep = dependency(
Alexander Hansenf2c95a02024-11-26 11:16:44 +0100114 'libgpiodcxx',
115 default_options: ['bindings=cxx'],
116 version: '>=1.1.2',
117 )
Alexander Hansencc372352025-01-14 14:15:39 +0100118endif
119
Patrick Williamsa02807c2025-07-08 10:55:34 -0400120foreach dir : optioned_subdirs
121 subdir(dir)
122endforeach
Daniel Hsuf6470b52025-02-26 15:03:47 +0800123
Alexander Hansen88b98bf2025-01-29 17:18:51 +0100124if build_tests.allowed()
Alexander Hansen192bb5d2025-02-27 11:28:15 +0100125 subdir('test')
Alexander Hansen4a053c82024-11-26 17:02:39 +0100126endif