blob: 3546c1584532280896164a7fffe53f1a32c6d1ce [file] [log] [blame]
Dylan Bakerc509d562020-10-08 11:40:05 -07001# 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'],
Lee Thomason1dee28e2021-06-06 17:10:24 -070025 version : '9.0.0',
Dylan Bakerc509d562020-10-08 11:40:05 -070026 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
Dov Grobgeld9d899a72021-01-26 21:09:43 +020053dep_tinyxml2 = declare_dependency(
Dylan Bakerc509d562020-10-08 11:40:05 -070054 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')
heitbaum0838dd12021-05-17 15:14:01 +100061 meson.override_dependency('tinyxml2', dep_tinyxml2)
Dylan Bakerc509d562020-10-08 11:40:05 -070062endif
63
64if get_option('tests')
65 # Try to find a copy command. If this is windows we probably don't have cp,
66 # but if this is msys then we do, so make cp not required in that case, and
67 # try Xcopy if cp isn't found
68 prog_cp = find_program('cp', required : build_machine.system() != 'windows')
69 command = ['-r']
70 if not prog_cp.found()
71 prog_cp = find_program('Xcopy')
72 command = ['/E', '/I']
73 endif
74
75 # Copy the test resources into the build dir
76 run_command(
77 prog_cp,
78 [
79 command,
80 meson.current_source_dir() / 'resources',
81 meson.current_build_dir(),
82 ],
83 )
84
85 test(
86 'xmltest',
87 executable(
88 'xmltest',
89 ['xmltest.cpp'],
90 link_with : [lib_tinyxml2],
91 ),
92 workdir : meson.current_build_dir(),
93 )
94endif
95
96install_headers('tinyxml2.h')
97
98# This is better than using the .in because meson tracks dependencies
99# internally, and will generate a more accurate pkg-config file
100pkg = import('pkgconfig')
101pkg.generate(
102 lib_tinyxml2,
103 description : 'simple, small, C++ XML parser',
104)