-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
189 lines (168 loc) · 5.7 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#
# See LICENSE for more information about licensing
# Copyright 2023
#
# Author: Luis G. Leon Vega <luis.leon@ieee.org>
#
project('efimon', ['c','cpp'], version : '0.2.0',
default_options : ['warning_level=3',
'cpp_std=c++17',
'c_std=c17',
],
license: 'LGPL-2.1-only',
meson_version: '>= 1.0.0'
)
# -----------------------------------------------------------------------------
# Global variables and default definitions
# -----------------------------------------------------------------------------
c_args = ['-Werror']
cpp_args = ['-Werror']
cmake = import('cmake')
fs = import('fs')
project_inc = [include_directories('include')]
project_deps = []
c_args = ['-Werror']
cpp_args = ['-Werror']
# Find proc library
cpp = meson.get_compiler('cpp')
libprocps1_dep = cpp.find_library('libprocps', required: false)
enable_libprocps = false
if libprocps1_dep.found()
message('libprocps1 found. Proceeding')
project_deps += libprocps1_dep
enable_libprocps = true
else
warning('libprocps not found. Listers will not be available')
endif
# Find SQLite3
enable_sql = false
sqlite_dep = dependency('sqlite3', required: false)
if sqlite_dep.found() and get_option('enable-sql')
message('SQLite Found. Enabling')
enable_sql = true
project_deps += sqlite_dep
c_args += ['-DENABLE_SQLITE']
cpp_args += ['-DENABLE_SQLITE']
else
warning('SQLite dependency not found. Disabling loggers related to SQLite')
endif
# Verify if Perf is installed
enable_perf = false
perf_executable = find_program('perf', required: false, native: true)
if perf_executable.found() and get_option('enable-perf')
enable_perf = true
message('Linux Perf Found. Enabling')
c_args += ['-DENABLE_PERF']
cpp_args += ['-DENABLE_PERF']
else
warning('Linux Perf not found. Disabling code related to Linux Perf')
endif
# Verify if IPMI OEM is installed
enable_ipmi = false
enable_ipmi_sensors = false
ipmi_oem_executable = find_program('ipmi-oem', required: false, native: true)
if ipmi_oem_executable.found() and get_option('enable-ipmi')
enable_ipmi = true
cpp_args += ['-DENABLE_IPMI']
message('IPMI found')
else
message('IPMI not found. Disabling code related to IPMI')
endif
ipmi_sensors_executable = find_program('ipmi-sensors', required: false, native: true)
if ipmi_sensors_executable.found() and get_option('enable-ipmi')
enable_ipmi_sensors = true
cpp_args += ['-DENABLE_IPMI_SENSORS']
message('IPMI Sensors found')
else
message('IPMI not found. Disabling code related to IPMI Sensors')
endif
# Add Intel PCM
enable_pcm = false
if get_option('enable-pcm')
# Configure the CMake project
opt_var = cmake.subproject_options()
opt_var.set_override_option('warning_level', '0')
pcm_proj = cmake.subproject('pcm', options: opt_var)
# Fetch the dependency object
pcm_dep = pcm_proj.dependency('PCM_SHARED')
project_deps += pcm_dep
enable_pcm = true
else
warning('Intel PCM is disabled')
endif
# Verify if RAPL exists
enable_rapl = false
if fs.is_dir('/sys/class/powercap/intel-rapl') and get_option('enable-rapl')
message('RAPL Found. Enabling')
c_args += ['-DENABLE_RAPL']
cpp_args += ['-DENABLE_RAPL']
enable_rapl = true
else
warning('RAPL not found. Disabling code related to Intel RAPL')
endif
# Verify if ZeroMQ is installed
enable_zeromq = false
zeromq_dep = dependency('libzmq', required: false)
if zeromq_dep.found()
message('ZeroMQ Found. Enabling')
enable_zeromq = true
project_deps += [zeromq_dep]
c_args += ['-DENABLE_ZEROMQ']
cpp_args += ['-DENABLE_ZEROMQ']
else
warning('ZeroMQ not found. It will disabled the efimon-daemon and some examples')
endif
# Verify if JsonCPP is installed
enable_jsoncpp = false
jsoncpp_dep = dependency('jsoncpp', required: false)
if jsoncpp_dep.found()
message('JSONCPP Found. Enabling')
enable_jsoncpp = true
project_deps += [jsoncpp_dep]
c_args += ['-DENABLE_JSONCPP']
cpp_args += ['-DENABLE_JSONCPP']
else
warning('JSONCPP not found. It will disabled the efimon-daemon and some examples')
endif
# Verify Capstone and Ptrace
enable_ptrace_capstone = false
capstone_dep = dependency('capstone', required: false)
ptrace_header_check = cpp.has_header('sys/ptrace.h', required: false)
if capstone_dep.found() and ptrace_header_check
message('Capstone and Ptrace Found. Enabling')
enable_ptrace_capstone = true
project_deps += [capstone_dep]
c_args += ['-DENABLE_PTRACE_CAPSTONE']
cpp_args += ['-DENABLE_PTRACE_CAPSTONE']
else
warning('Capstone or ptrace not found. It will disable the ptrace-capstone ASM support')
endif
project_deps += dependency('threads')
# -----------------------------------------------------------------------------
# Developer mode options
# -----------------------------------------------------------------------------
if get_option('developer-mode')
pre_commit = find_program('pre-commit', required: true, native: true)
run_command(pre_commit, 'install', check: false)
run_command(pre_commit, 'install', '--hook-type', 'commit-msg', check: false)
c_args += ['-DDEBUG_MODE']
cpp_args += ['-DDEBUG_MODE']
endif
# -----------------------------------------------------------------------------
# Subdirectories
# -----------------------------------------------------------------------------
if not get_option('build-docs-only')
subdir('include/efimon')
subdir('src')
# Imports pkgconfig module
pkgconfig = import('pkgconfig')
pkgconfig_install_dir = join_paths(get_option('libdir'), 'pkgconfig')
pkgconfig.generate(libefimon,
description: 'Implementation-Agnostic Efficiency Monitor')
endif
if get_option('build-examples')
subdir('examples')
endif
if get_option('build-docs') or get_option('build-docs-only')
subdir('docs-src')
endif