xref: /openbmc/sdeventplus/src/meson.build (revision 159a3560)
1# Function2 might not have a pkg-config. It is header only so just make
2# sure we can access the needed symbols from the header.
3function2_dep = dependency('function2', required: false)
4has_function2 = meson.get_compiler('cpp').has_header_symbol(
5  'function2/function2.hpp',
6  'fu2::unique_function',
7  dependencies: function2_dep,
8  required: false)
9if not has_function2
10  function2_proj = import('cmake').subproject(
11    'function2',
12    cmake_options: [
13	  '-DBUILD_TESTING=OFF',
14    ],
15    required: false)
16  assert(function2_proj.found(), 'function2 is required')
17  if function2_proj.found()
18    function2_dep = function2_proj.dependency('function2')
19  endif
20endif
21
22sdeventplus_deps = [
23  dependency('libsystemd', version: '>=240'),
24  dependency('stdplus', fallback: ['stdplus', 'stdplus']),
25  function2_dep,
26]
27
28sdeventplus_headers = include_directories('.')
29
30sdeventplus_lib = library(
31  'sdeventplus',
32  [
33    'sdeventplus/clock.cpp',
34    'sdeventplus/event.cpp',
35    'sdeventplus/exception.cpp',
36    'sdeventplus/internal/sdevent.cpp',
37    'sdeventplus/source/base.cpp',
38    'sdeventplus/source/child.cpp',
39    'sdeventplus/source/event.cpp',
40    'sdeventplus/source/io.cpp',
41    'sdeventplus/source/signal.cpp',
42    'sdeventplus/source/time.cpp',
43    'sdeventplus/utility/timer.cpp',
44  ],
45  include_directories: sdeventplus_headers,
46  implicit_include_directories: false,
47  version: meson.project_version(),
48  dependencies: sdeventplus_deps,
49  install: true)
50
51sdeventplus = declare_dependency(
52  dependencies: sdeventplus_deps,
53  include_directories: sdeventplus_headers,
54  link_with: sdeventplus_lib)
55
56sdeventplus_reqs = []
57foreach dep : sdeventplus_deps
58  if dep.type_name() == 'pkgconfig'
59	sdeventplus_reqs += dep
60  endif
61endforeach
62
63import('pkgconfig').generate(
64  name: 'sdeventplus',
65  description: 'C++ systemd event wrapper',
66  version: meson.project_version(),
67  libraries: sdeventplus,
68  requires: sdeventplus_reqs)
69
70install_headers(
71  'sdeventplus/clock.hpp',
72  'sdeventplus/event.hpp',
73  'sdeventplus/exception.hpp',
74  'sdeventplus/types.hpp',
75  subdir: 'sdeventplus')
76
77install_headers(
78  'sdeventplus/internal/sdevent.hpp',
79  'sdeventplus/internal/utils.hpp',
80  subdir: 'sdeventplus/internal')
81
82install_headers(
83  'sdeventplus/source/base.hpp',
84  'sdeventplus/source/child.hpp',
85  'sdeventplus/source/event.hpp',
86  'sdeventplus/source/io.hpp',
87  'sdeventplus/source/signal.hpp',
88  'sdeventplus/source/time.hpp',
89  subdir: 'sdeventplus/source')
90
91install_headers(
92  'sdeventplus/test/sdevent.hpp',
93  subdir: 'sdeventplus/test')
94
95install_headers(
96  'sdeventplus/utility/timer.hpp',
97  subdir: 'sdeventplus/utility')
98