-
Notifications
You must be signed in to change notification settings - Fork 25
/
meson.build
158 lines (139 loc) · 4.07 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
project(
'QArchive',
'cpp',
version: '2.2.9',
license: 'BSD-3-Clause',
default_options: ['cpp_std=c++17'],
meson_version: '>=0.49.0',
)
qt_dep = dependency('qt6', modules: ['Core'], required: get_option('qt6'))
if qt_dep.found() and meson.version().version_compare('>=0.57.0')
qt = import('qt6')
elif qt_dep.found() and get_option('qt6').enabled()
error('Qt6 support needs meson 0.57.0 or higher')
else
qt_dep = dependency('qt5', modules: ['Core'])
qt = import('qt5')
endif
libarchive_dep = dependency('libarchive')
vers = meson.project_version().split('.')
cdata = configuration_data()
cdata.set('PROJECT_VERSION', meson.project_version())
cdata.set('PROJECT_VERSION_MAJOR', vers[0])
cdata.set('PROJECT_VERSION_MINOR', vers[1])
cdata.set('PROJECT_VERSION_PATCH', vers[2])
cdata.set('QARCHIVE_STATIC', get_option('default_library') == 'static')
conf = configure_file(
format: 'cmake@',
input: 'other/cmake/config.h.in',
output: 'config.h',
configuration: cdata,
)
src = files(
'src/qarchive_enums.cc',
'src/qarchivecompressor.cc',
'src/qarchivecompressor_p.cc',
'src/qarchivediskcompressor.cc',
'src/qarchivediskextractor.cc',
'src/qarchiveextractor.cc',
'src/qarchiveextractor_p.cc',
'src/qarchiveioreader_p.cc',
'src/qarchivememorycompressor.cc',
'src/qarchivememoryextractor.cc',
'src/qarchivememoryextractoroutput.cc',
'src/qarchivememoryfile.cc',
'src/qarchiveutils_p.cc',
)
headers = files(
'include/qarchivecompressor.hpp',
'include/qarchivecompressor_p.hpp',
'include/qarchivediskcompressor.hpp',
'include/qarchivediskextractor.hpp',
'include/qarchiveextractor.hpp',
'include/qarchiveextractor_p.hpp',
'include/qarchivememorycompressor.hpp',
'include/qarchivememoryextractor.hpp',
'include/qarchivememoryextractoroutput.hpp',
)
maininc = include_directories('include')
moc_files = qt.preprocess(
moc_sources: [],
moc_headers: headers,
include_directories: maininc,
dependencies: qt_dep,
)
qarchive_lib = library(
'QArchive',
src,
moc_files,
cpp_args: '-DQARCHIVE_BUILD',
include_directories: maininc,
dependencies: [libarchive_dep, qt_dep],
install: true,
)
pconf = import('pkgconfig')
pconf.generate(qarchive_lib, description: 'A Qt wrapper for libarchive.')
install_headers(
'include/qarchive_enums.hpp',
'include/qarchive_global.hpp',
'include/qarchivecompressor.hpp',
'include/qarchivediskcompressor.hpp',
'include/qarchivediskextractor.hpp',
'include/qarchiveextractor.hpp',
'include/qarchivememorycompressor.hpp',
'include/qarchivememoryextractor.hpp',
'include/qarchivememoryextractoroutput.hpp',
'include/qarchivememoryfile.hpp',
'QArchive',
conf,
subdir: 'QArchive',
)
depinc = include_directories('.')
qarchive_dep = declare_dependency(
include_directories: depinc,
link_with: qarchive_lib,
)
if meson.version().version_compare('>=0.54.0')
meson.override_dependency('qarchive', qarchive_dep)
endif
if get_option('tests')
test_src = files(
'tests/QArchiveDiskCompressorTests.cc',
'tests/QArchiveDiskExtractorTests.cc',
'tests/QArchiveMemoryCompressorTests.cc',
'tests/QArchiveMemoryExtractorTests.cc',
'tests/TestRunner.cc',
'tests/main.cc',
)
test_headers = files(
'tests/QArchiveDiskCompressorTests.hpp',
'tests/QArchiveDiskExtractorTests.hpp',
'tests/QArchiveMemoryCompressorTests.hpp',
'tests/QArchiveMemoryExtractorTests.hpp',
'tests/TestRunner.hpp',
)
test_include_dirs = include_directories('include', 'tests')
test_moc_files = qt.preprocess(
moc_sources: [],
moc_headers: test_headers,
include_directories: test_include_dirs,
dependencies: qt_dep,
)
test_dep = dependency(
'qt6',
modules: ['Test', 'Core', 'Concurrent'],
required: get_option('qt6'),
)
if not test_dep.found()
test_dep = dependency('qt5', modules: ['Test', 'Core', 'Concurrent'])
endif
test_exe = executable(
'QArchiveTests',
test_src,
test_moc_files,
include_directories: test_include_dirs,
cpp_args: '-DBUILD_TESTS',
dependencies: [qarchive_dep, test_dep],
)
test('QArchiveTests', test_exe)
endif