3 # Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
5 # This file is part of libcxml.
7 # libcxml is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # libcxml is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with libcxml. If not, see <http://www.gnu.org/licenses/>.
23 from waflib import Context
27 this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0].decode('UTF-8')
28 last_version = subprocess.Popen(shlex.split('git describe --tags --abbrev=0'), stdout=subprocess.PIPE).communicate()[0].decode('UTF-8')
30 if this_version == '':
31 VERSION = '%sdevel' % last_version[1:].strip()
33 VERSION = this_version[1:].strip()
38 opt.load('compiler_cxx')
39 opt.add_option('--target-windows-64', action='store_true', default=False, help='set up to do a cross-compile to Windows 64-bit')
40 opt.add_option('--target-windows-32', action='store_true', default=False, help='set up to do a cross-compile to Windows 32-bit')
41 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
42 opt.add_option('--static', action='store_true', default=False, help='build statically')
43 opt.add_option('--disable-tests', action='store_true', default=False, help='disable building of tests')
44 opt.add_option('--c++17', action='store_true', default=False, help='build with C++17 and libxml++-4.0')
47 conf.load('compiler_cxx')
49 if vars(conf.options)['c++17']:
51 conf.env.XMLPP_API = '4.0'
52 conf.env.GLIBMM_API = '2.68'
55 conf.env.XMLPP_API = '2.6'
56 conf.env.GLIBMM_API = '2.4'
58 if conf.options.enable_debug:
59 conf.env.append_value('CXXFLAGS', '-g')
60 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-O2', '-Wno-deprecated-declarations', '-std=c++' + cpp_std, '-DBOOST_NO_CXX11_SCOPED_ENUMS'])
62 conf.env.TARGET_WINDOWS = conf.options.target_windows_32 or conf.options.target_windows_64
63 conf.env.STATIC = conf.options.static
64 conf.env.DISABLE_TESTS = conf.options.disable_tests
65 conf.env.API_VERSION = API_VERSION
67 if conf.env.TARGET_WINDOWS:
68 boost_lib_suffix = '-mt-x32' if conf.options.target_windows_32 else '-mt-x64'
69 conf.env.append_value('CXXFLAGS', '-DLIBCXML_WINDOWS')
72 conf.env.append_value('CXXFLAGS', '-DLIBCXML_POSIX')
74 conf.check_cfg(package='libxml++-' + conf.env.XMLPP_API, args='--cflags --libs', uselib_store='LIBXML++', mandatory=True)
76 conf.check_cxx(fragment="""
77 #include <boost/filesystem.hpp>\n
78 int main() { boost::filesystem::copy_file ("a", "b"); }\n
80 msg='Checking for boost filesystem library',
81 libpath='/usr/local/lib',
82 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
83 uselib_store='BOOST_FILESYSTEM')
85 if not conf.options.disable_tests:
86 conf.check_cxx(fragment="""
87 #define BOOST_TEST_MODULE Config test\n
88 #include <boost/test/unit_test.hpp>\n
91 msg='Checking for boost unit testing library',
92 lib=['boost_unit_test_framework%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
93 uselib_store='BOOST_TEST')
98 bld(source='libcxml.pc.in',
100 includedir='%s/include' % bld.env.PREFIX,
101 libs="-L${libdir} -lcxml",
102 install_path='${LIBDIR}/pkgconfig',
103 xmlpp_api=bld.env.XMLPP_API,
104 glibmm_api=bld.env.GLIBMM_API)
107 if not bld.env.DISABLE_TESTS: