meson.build 2.3 KB

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