xref: /aosp_15_r20/external/tinyxml2/meson.build (revision 7485b22521f577cf944e5687361548d8993d8d2c)
1# Copyright © 2020 Dylan Baker
2
3# This software is provided 'as-is', without any express or implied
4# warranty. In no event will the authors be held liable for any
5# damages arising from the use of this software.
6
7# Permission is granted to anyone to use this software for any
8# purpose, including commercial applications, and to alter it and
9# redistribute it freely, subject to the following restrictions:
10
11# 1. The origin of this software must not be misrepresented; you must
12# not claim that you wrote the original software. If you use this
13# software in a product, an acknowledgment in the product documentation
14# would be appreciated but is not required.
15
16# 2. Altered source versions must be plainly marked as such, and
17# must not be misrepresented as being the original software.
18
19# 3. This notice may not be removed or altered from any source
20# distribution.
21
22project(
23    'tinyxml2',
24    ['cpp'],
25    version : '10.0.0',
26    meson_version : '>= 0.49.0',
27)
28
29cpp = meson.get_compiler('cpp')
30
31tinyxml_extra_args = []
32if cpp.get_argument_syntax() == 'msvc'
33    tinyxml_extra_args += '-D_CRT_SECURE_NO_WARNINGS'
34endif
35
36if get_option('default_library') == 'shared'
37    tinyxml_extra_args += '-DTINYXML2_EXPORT'
38endif
39
40if get_option('debug')
41    tinyxml_extra_args += '-DTINYXML2_DEBUG'
42endif
43
44lib_tinyxml2 = library(
45    'tinyxml2',
46    ['tinyxml2.cpp'],
47    cpp_args : tinyxml_extra_args,
48    gnu_symbol_visibility : 'hidden',
49    version : meson.project_version(),
50    install : true,
51)
52
53dep_tinyxml2 = declare_dependency(
54    link_with : lib_tinyxml2,
55    include_directories : include_directories('.'),
56)
57
58# This is the new way to set dependencies, but let's not break users of older
59# versions of meson
60if meson.version().version_compare('>= 0.54.0')
61  meson.override_dependency('tinyxml2', dep_tinyxml2)
62endif
63
64if get_option('tests')
65    test(
66        'xmltest',
67        executable(
68            'xmltest',
69            ['xmltest.cpp'],
70            link_with : [lib_tinyxml2],
71        ),
72        workdir : meson.current_source_dir(),
73    )
74endif
75
76install_headers('tinyxml2.h')
77
78# This is better than using the .in because meson tracks dependencies
79# internally, and will generate a more accurate pkg-config file
80pkg = import('pkgconfig')
81pkg.generate(
82    lib_tinyxml2,
83    description : 'simple, small, C++ XML parser',
84)
85