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