Dylan Baker | c509d56 | 2020-10-08 11:40:05 -0700 | [diff] [blame] | 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 | |
| 22 | project( |
| 23 | 'tinyxml2', |
| 24 | ['cpp'], |
Lee Thomason | 1dee28e | 2021-06-06 17:10:24 -0700 | [diff] [blame] | 25 | version : '9.0.0', |
Dylan Baker | c509d56 | 2020-10-08 11:40:05 -0700 | [diff] [blame] | 26 | meson_version : '>= 0.49.0', |
| 27 | ) |
| 28 | |
| 29 | cpp = meson.get_compiler('cpp') |
| 30 | |
| 31 | tinyxml_extra_args = [] |
| 32 | if cpp.get_argument_syntax() == 'msvc' |
| 33 | tinyxml_extra_args += '-D_CRT_SECURE_NO_WARNINGS' |
| 34 | endif |
| 35 | |
| 36 | if get_option('default_library') == 'shared' |
| 37 | tinyxml_extra_args += '-DTINYXML2_EXPORT' |
| 38 | endif |
| 39 | |
| 40 | if get_option('debug') |
| 41 | tinyxml_extra_args += '-DTINYXML2_DEBUG' |
| 42 | endif |
| 43 | |
| 44 | lib_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 Grobgeld | 9d899a7 | 2021-01-26 21:09:43 +0200 | [diff] [blame] | 53 | dep_tinyxml2 = declare_dependency( |
Dylan Baker | c509d56 | 2020-10-08 11:40:05 -0700 | [diff] [blame] | 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 |
| 60 | if meson.version().version_compare('>= 0.54.0') |
heitbaum | 0838dd1 | 2021-05-17 15:14:01 +1000 | [diff] [blame] | 61 | meson.override_dependency('tinyxml2', dep_tinyxml2) |
Dylan Baker | c509d56 | 2020-10-08 11:40:05 -0700 | [diff] [blame] | 62 | endif |
| 63 | |
| 64 | if 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 | ) |
| 94 | endif |
| 95 | |
| 96 | install_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 |
| 100 | pkg = import('pkgconfig') |
| 101 | pkg.generate( |
| 102 | lib_tinyxml2, |
| 103 | description : 'simple, small, C++ XML parser', |
| 104 | ) |