diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..02125e3 --- /dev/null +++ b/meson.build @@ -0,0 +1,68 @@ +project('pugixml', 'cpp', + version: '1.11.4', + meson_version: '>=0.46.0', + default_options: ['cpp_std=c++11'], +) + +cxx = meson.get_compiler('cpp') + +version = meson.project_version().split('.') +soversion = '.'.join([ version[0], version[1] ]) + +sources = files('src/pugixml.cpp') + +if host_machine.system() == 'windows' + win_mod = import('windows') + sources += win_mod.compile_resources('scripts/pugixml_dll.rc') +endif + +args = [] +if cxx.get_id() == 'msvc' + if get_option('default_library') == 'shared' + args +='-DPUGIXML_API=__declspec(dllexport)' + elif get_option('default_library') == 'both' + error('cannot build both shared and static on MSVC due to declspec') + endif +endif + +foreach opt: ['wchar_mode', 'compact', 'no_xpath', 'no_stl', 'no_exceptions'] + if get_option(opt) + args += '-DPUGIXML_' + opt.to_upper() + endif +endforeach + +pugixml_lib = library('pugixml', sources, + cpp_args: args, + version: soversion, + install: true, +) +install_headers('src/pugiconfig.hpp', 'src/pugixml.hpp') + +pugixml_dep = declare_dependency( + link_with: pugixml_lib, + include_directories: include_directories('src') +) + +import('pkgconfig').generate( + pugixml_lib, + description: 'Light-weight, simple and fast XML parser for C++ with XPath support.', + url: 'https://pugixml.org/', +) + +if find_program('cmake', required: false).found() + cmake = import('cmake') + cmake.write_basic_package_version_file( + name: meson.project_name(), + version: meson.project_version(), + compatibility: 'SameMajorVersion', + ) + cmake.configure_package_config_file( + input: 'scripts/pugixml-config.cmake.in', + name: meson.project_name(), + configuration: configuration_data(), + ) +endif + +subdir('tests') +pugixml_check = executable('pugixml-check', test_sources, dependencies: pugixml_dep) +test('pugixml-check', pugixml_check, workdir: meson.current_source_dir()) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..bb4e5ce --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('wchar_mode', type: 'boolean', value: false, description: 'Enable wchar_t mode') +option('compact', type: 'boolean', value: false) +option('no_xpath', type: 'boolean', value: false) +option('no_stl', type: 'boolean', value: false) +option('no_exceptions', type: 'boolean', value: false) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..fe47fff --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,42 @@ +test_sources = files( + 'allocator.cpp', + 'main.cpp', + 'test_compact.cpp', + 'test.cpp', + 'test_deprecated.cpp', + 'test_document.cpp', + 'test_dom_modify.cpp', + 'test_dom_text.cpp', + 'test_dom_traverse.cpp', + 'test_header_guard.cpp', + 'test_header_iosfwd_1.cpp', + 'test_header_iosfwd_2.cpp', + 'test_header_iostream_1.cpp', + 'test_header_iostream_2.cpp', + 'test_header_only_1.cpp', + 'test_header_only_2.cpp', + 'test_header_string_1.cpp', + 'test_header_string_2.cpp', + 'test_header_string_iostream.cpp', + 'test_memory.cpp', + 'test_parse.cpp', + 'test_parse_doctype.cpp', + 'test_unicode.cpp', + 'test_version.cpp', + 'test_write.cpp', + 'test_xpath_api.cpp', + 'test_xpath.cpp', + 'test_xpath_functions.cpp', + 'test_xpath_operators.cpp', + 'test_xpath_parse.cpp', + 'test_xpath_paths_abbrev_w3c.cpp', + 'test_xpath_paths.cpp', + 'test_xpath_paths_w3c.cpp', + 'test_xpath_variables.cpp', + 'test_xpath_xalan_1.cpp', + 'test_xpath_xalan_2.cpp', + 'test_xpath_xalan_3.cpp', + 'test_xpath_xalan_4.cpp', + 'test_xpath_xalan_5.cpp', + 'writer_string.cpp', +)