# Copyright 2019-2022 David Robillard # SPDX-License-Identifier: CC0-1.0 OR GPL-2.0-or-later project('chilbert', ['cpp'], version: '0.0.1', license: 'GPLv2+', meson_version: '>= 0.56.0', default_options: [ 'b_ndebug=if-release', 'buildtype=release', 'cpp_std=c++14', ]) major_version = meson.project_version().split('.')[0] versioned_name = 'chilbert-@0@'.format(major_version) ####################### # Compilers and Flags # ####################### # Required tools pkg = import('pkgconfig') cpp = meson.get_compiler('cpp') # Set global warning flags if get_option('strict') if not meson.is_subproject() subdir('meson/warnings') add_project_arguments(all_cpp_warnings, language: ['cpp']) endif cpp_suppressions = [] if cpp.get_id() == 'gcc' cpp_suppressions += [ '-Wno-effc++', '-Wno-volatile', ] elif cpp.get_id() == 'msvc' cpp_suppressions += [ '/wd4028', # formal parameter different from declaration '/wd4204', # non-constant aggregate initializer '/wd4514', # unreferenced inline function has been removed '/wd4668', # not defined as a preprocessor macro '/wd4706', # assignment within conditional expression '/wd4710', # function not inlined '/wd4711', # function selected for automatic inline expansion '/wd4820', # padding added after construct '/wd5045', # will insert Spectre mitigation ] endif add_project_arguments( cpp.get_supported_arguments(cpp_suppressions), language: ['cpp'], ) endif ########### # Library # ########### include_dirs = include_directories('include') headers = [ 'include/chilbert/BoundedBitVec.hpp', 'include/chilbert/DynamicBitVec.hpp', 'include/chilbert/SmallBitVec.hpp', 'include/chilbert/StaticBitVec.hpp', 'include/chilbert/chilbert.hpp', 'include/chilbert/chilbert.ipp', 'include/chilbert/operators.hpp', ] detail_headers = [ 'include/chilbert/detail/BitVecIndex.hpp', 'include/chilbert/detail/BitVecIterator.hpp', 'include/chilbert/detail/BitVecMask.hpp', 'include/chilbert/detail/MultiBitVec.hpp', 'include/chilbert/detail/gray_code_rank.hpp', 'include/chilbert/detail/operations.hpp', 'include/chilbert/detail/traits.hpp', ] # Declare dependency for internal meson dependants spaix_dep = declare_dependency(include_directories: include_dirs) # Generage pkg-config file for external dependants pkg.generate( description: 'Implementation of Compact Hilbert Indices', filebase: versioned_name, name: 'Chilbert', subdirs: [versioned_name], version: meson.project_version(), ) # Install headers to a versioned include directory install_headers(headers, subdir: versioned_name / 'chilbert') install_headers(headers, subdir: versioned_name / 'chilbert' / 'detail') ###################### # Tests / Benchmarks # ###################### # Build and run tests if not get_option('tests').disabled() foreach name : ['bitvec', 'gray_code_rank'] full_name = 'test_@0@'.format(name) test( full_name, executable( full_name, 'test/@0@.cpp'.format(full_name), include_directories: include_directories('include'), ), timeout: 1200, ) endforeach gmp_dep = cpp.find_library('gmp', required: false) gmpxx_dep = cpp.find_library('gmpxx', required: false) if gmp_dep.found() and gmpxx_dep.found() test( 'test_hilbert', executable( 'test_hilbert', 'test/test_hilbert.cpp', include_directories: include_directories('include'), dependencies: [gmp_dep, gmpxx_dep], ), ) endif endif # Build benchmarks if not get_option('benchmarks').disabled() foreach name : ['bitvec', 'hilbert'] executable( 'bench_@0@'.format(name), files('benchmark/bench_@0@.cpp'.format(name)), include_directories: include_directories('include', 'test'), ) endforeach endif # Display configuration summary if not meson.is_subproject() summary('Tests', not get_option('tests').disabled(), bool_yn: true) summary('Install prefix', get_option('prefix')) summary('Headers', get_option('prefix') / get_option('includedir')) endif