xref: /openbmc/openpower-hw-diags/meson.build (revision 832526df90ead77f5dcb501406cb07fbbfa7046b)
1# See README.md for details.
2project('openpower-hw-diags', 'cpp',
3        version: '0.1', meson_version: '>=0.49.0',
4        default_options: [
5          'warning_level=3',
6          'werror=true',
7          'cpp_std=c++17',
8        ])
9
10#-------------------------------------------------------------------------------
11# Versioning
12#-------------------------------------------------------------------------------
13buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'],
14                  input: 'buildinfo.hpp.in',
15                  output: 'buildinfo.hpp',
16                  replace_string:'@BUILDINFO@',
17                  fallback: '0')
18
19#-------------------------------------------------------------------------------
20# Compiler
21#-------------------------------------------------------------------------------
22
23cmplr = meson.get_compiler('cpp')
24
25#-------------------------------------------------------------------------------
26# Config file
27#-------------------------------------------------------------------------------
28
29conf = configuration_data()
30
31conf.set('CONFIG_PHAL_API', get_option('phal').enabled())
32
33configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)
34
35#-------------------------------------------------------------------------------
36# Include directories
37#-------------------------------------------------------------------------------
38
39# Only using the base directory. All header includes should provide the full
40# path from the base directory.
41incdir = include_directories('.')
42
43#-------------------------------------------------------------------------------
44# External library dependencies
45#-------------------------------------------------------------------------------
46
47# Look if the libhei library has already been built and installed. If not,
48# default to the subproject.
49libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
50
51sdbusplus_dep       = dependency('sdbusplus', version : '>=1.0')
52dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
53
54libpdbg_dep = cmplr.find_library('pdbg')
55
56# See if phosphor-logging is available, if not use test case logging code. This
57# allows for local builds outside of CI test sandbox.
58h = 'phosphor-logging/log.hpp'
59if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
60    test_arg = []
61    phosphor_logging = true
62else
63    test_arg = [
64        '-DTEST_TRACE',
65    ]
66    phosphor_logging = false
67endif
68
69pthread = declare_dependency(link_args : '-pthread')
70lrt = declare_dependency(link_args : '-lrt')
71
72#-------------------------------------------------------------------------------
73# Build the local static libraries
74#-------------------------------------------------------------------------------
75
76subdir('analyzer')
77subdir('attn')
78subdir('util')
79
80hwdiags_libs = [
81    analyzer_lib,
82    attn_lib,
83    util_lib,
84]
85
86#-------------------------------------------------------------------------------
87# Build the executable
88#-------------------------------------------------------------------------------
89
90no_listener_mode = get_option('nlmode')
91
92if not no_listener_mode.disabled()
93  executable('openpower-hw-diags',
94              sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo ],
95              link_with : hwdiags_libs,
96              install : true)
97else
98  executable('openpower-hw-diags',
99              sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo ],
100              dependencies : [lrt, pthread],
101              link_with : hwdiags_libs,
102              cpp_args : test_arg,
103              install : true)
104endif
105
106#-------------------------------------------------------------------------------
107# Test, if configured
108#-------------------------------------------------------------------------------
109
110build_tests = get_option('tests')
111
112if not build_tests.disabled()
113  subdir('test')
114endif
115