1project('dbus-sensor-tester', 'cpp', 2 version : '1.0', 3 meson_version: '>=1.1.1', 4 default_options: [ 5 'b_lto_mode=default', 6 'b_lto_threads=0', 7 'b_lto=true', 8 'b_ndebug=if-release', 9 'buildtype=debugoptimized', 10 'cpp_rtti=false', 11 'cpp_std=c++23', 12 'warning_level=3', 13 'werror=true', 14 ]) 15 16# Project related links 17 18project_pretty_name = 'dbus-sensor-tester' 19 20# Validate the c++ Standard 21 22if get_option('cpp_std') != 'c++23' 23 error('This project requires c++23 support') 24endif 25 26# Get compiler and default build type 27 28cxx = meson.get_compiler('cpp') 29build = get_option('buildtype') 30optimization = get_option('optimization') 31summary('Build Type',build, section : 'Build Info') 32summary('Optimization',optimization, section : 'Build Info') 33 34# Disable lto when compiling with no optimization 35if(get_option('optimization') == '0') 36 add_project_arguments('-fno-lto', language: 'cpp') 37 message('Disabling lto & its supported features as optimization is disabled') 38endif 39 40# Add compiler arguments 41 42# -Wpedantic, -Wextra comes by default with warning level 43add_project_arguments( 44 cxx.get_supported_arguments([ 45 '-Wcast-align', 46 '-Wconversion', 47 '-Wformat=2', 48 '-Wold-style-cast', 49 '-Woverloaded-virtual', 50 '-Wsign-conversion', 51 '-Wunused', 52 '-Wno-attributes', 53 ]), 54 language: 'cpp' 55) 56 57if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0')) 58add_project_arguments( 59 cxx.get_supported_arguments([ 60 '-Weverything', 61 '-Wno-c++98-compat-pedantic', 62 '-Wno-c++98-compat', 63 '-Wno-documentation-unknown-command', 64 '-Wno-documentation', 65 '-Wno-exit-time-destructors', 66 '-Wno-global-constructors', 67 '-Wno-newline-eof', 68 '-Wno-padded', 69 '-Wno-shadow', 70 '-Wno-used-but-marked-unused', 71 '-Wno-weak-vtables', 72 ]), 73 language:'cpp') 74endif 75 76# if compiler is gnu-gcc , and version is > 8.0 then we add few more 77# compiler arguments , we know that will pass 78 79if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) 80 add_project_arguments( 81 cxx.get_supported_arguments([ 82 '-Wduplicated-cond', 83 '-Wduplicated-branches', 84 '-Wlogical-op', 85 '-Wunused-parameter', 86 '-Wnull-dereference', 87 '-Wdouble-promotion', 88 ]), 89 language:'cpp') 90endif 91 92# Find the dependency modules, if not found use meson wrap to get them 93# automatically during the configure step 94dependencies = [] 95 96sdbusplus = dependency('sdbusplus', required : false, include_type: 'system') 97if not sdbusplus.found() 98 sdbusplus_proj = subproject('sdbusplus', required: true) 99 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') 100 sdbusplus = sdbusplus.as_system('system') 101endif 102dependencies += sdbusplus 103 104cli11 = dependency('cli11', required : false, include_type: 'system') 105if not cli11.found() 106 cli11_proj = subproject('cli11', required: true) 107 cli11 = cli11_proj.get_variable('CLI11_dep') 108 cli11 = cli11.as_system('system') 109endif 110dependencies += cli11 111 112systemd = dependency('systemd') 113dependencies += [systemd] 114 115boost = dependency('boost', version : '>=1.78.0', required : false, include_type: 'system') 116if not boost.found() 117 subproject('boost', required: false) 118 boost_inc = include_directories('subprojects/boost_1_78_0/', is_system:true) 119 boost = declare_dependency(include_directories : boost_inc) 120 boost = boost.as_system('system') 121endif 122dependencies += boost 123 124srcfiles_sensortest = [ 125] 126 127systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') 128bindir = get_option('prefix') + '/' +get_option('bindir') 129 130# Generate the executable 131executable( 132 'sensortest', 133 srcfiles_sensortest + ['main.cpp'], 134 dependencies: dependencies, 135 link_args: '-Wl,--gc-sections', 136 install: true, 137 install_dir: bindir 138) 139