2020-01-04 14:21:38 +00:00
|
|
|
project(
|
2020-02-29 20:34:08 +00:00
|
|
|
'tomlplusplus',
|
|
|
|
'cpp',
|
2020-04-19 19:01:13 +00:00
|
|
|
version : '1.2.5',
|
2020-01-04 14:21:38 +00:00
|
|
|
license : 'MIT',
|
|
|
|
default_options : [
|
|
|
|
'cpp_std=c++17',
|
|
|
|
'warning_level=3',
|
2020-02-29 20:34:08 +00:00
|
|
|
'werror=true',
|
2020-04-06 12:57:49 +00:00
|
|
|
'cpp_eh=default',
|
2020-04-13 20:23:11 +00:00
|
|
|
'b_ndebug=if-release'
|
2020-01-04 14:21:38 +00:00
|
|
|
]
|
|
|
|
)
|
2020-02-29 20:34:08 +00:00
|
|
|
|
2020-03-04 11:01:46 +00:00
|
|
|
tomlplusplus_dep = declare_dependency(
|
|
|
|
include_directories : include_directories('include'),
|
|
|
|
version : meson.project_version(),
|
|
|
|
)
|
|
|
|
|
2020-04-08 13:33:57 +00:00
|
|
|
build_tests = get_option('BUILD_TESTS').enabled() or (get_option('BUILD_TESTS').auto() and not meson.is_subproject())
|
|
|
|
build_examples = get_option('BUILD_EXAMPLES').enabled() or (get_option('BUILD_EXAMPLES').auto() and not meson.is_subproject())
|
2020-03-18 13:28:00 +00:00
|
|
|
|
|
|
|
if build_tests or build_examples
|
|
|
|
|
|
|
|
compiler = meson.get_compiler('cpp')
|
|
|
|
message(['compiler ID: ', compiler.get_id()])
|
|
|
|
message(['compiler version: ', compiler.version()])
|
2020-04-13 20:23:11 +00:00
|
|
|
|
|
|
|
# GCC or Clang
|
2020-04-08 13:33:57 +00:00
|
|
|
if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang'
|
|
|
|
add_project_arguments([
|
|
|
|
'-march=native',
|
|
|
|
'-fno-rtti',
|
|
|
|
],
|
|
|
|
language : 'cpp'
|
2020-04-13 20:23:11 +00:00
|
|
|
)
|
|
|
|
if get_option('SMALL_BINARIES')
|
|
|
|
add_project_arguments([ '-fdata-sections', '-ffunction-sections', '-Wl,--gc-sections', '-Wl,-s' ], language : 'cpp')
|
|
|
|
endif
|
2020-04-08 13:33:57 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-13 20:23:11 +00:00
|
|
|
# GCC
|
2020-03-18 13:28:00 +00:00
|
|
|
if compiler.get_id() == 'gcc'
|
|
|
|
add_project_arguments([
|
|
|
|
'-fmax-errors=5',
|
2020-04-13 20:23:11 +00:00
|
|
|
'-Wno-init-list-lifetime'
|
2020-03-18 13:28:00 +00:00
|
|
|
],
|
|
|
|
language : 'cpp'
|
|
|
|
)
|
2020-04-13 20:23:11 +00:00
|
|
|
if get_option('ALL_WARNINGS')
|
|
|
|
add_project_arguments([
|
|
|
|
'-Wcast-align',
|
|
|
|
'-Wcast-qual',
|
|
|
|
'-Wctor-dtor-privacy',
|
|
|
|
'-Wdisabled-optimization',
|
|
|
|
'-Wextra',
|
|
|
|
'-Wfloat-equal',
|
|
|
|
'-Wimport',
|
|
|
|
'-Winit-self',
|
|
|
|
'-Wlogical-op',
|
|
|
|
'-Wmissing-declarations',
|
|
|
|
'-Wmissing-field-initializers',
|
|
|
|
'-Wmissing-format-attribute',
|
|
|
|
'-Wmissing-include-dirs',
|
|
|
|
'-Wmissing-noreturn',
|
|
|
|
'-Wnoexcept',
|
|
|
|
'-Wold-style-cast',
|
|
|
|
'-Woverloaded-virtual',
|
|
|
|
'-Wpacked',
|
|
|
|
'-Wpadded',
|
|
|
|
'-Wpedantic',
|
|
|
|
'-Wpointer-arith',
|
|
|
|
'-Wredundant-decls',
|
|
|
|
'-Wshadow',
|
|
|
|
'-Wsign-conversion',
|
|
|
|
'-Wsign-promo',
|
|
|
|
'-Wstack-protector',
|
|
|
|
'-Wstrict-null-sentinel',
|
|
|
|
'-Wswitch-default',
|
|
|
|
'-Wswitch-enum',
|
|
|
|
'-Wundef',
|
|
|
|
'-Wunreachable-code',
|
|
|
|
'-Wunused',
|
|
|
|
'-Wunused-parameter',
|
|
|
|
'-Wvariadic-macros',
|
|
|
|
'-Wwrite-strings',
|
|
|
|
],
|
|
|
|
language : 'cpp'
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
if get_option('SMALL_BINARIES')
|
|
|
|
add_project_arguments([ '-fmerge-constants' ], language : 'cpp')
|
|
|
|
endif
|
2020-03-18 13:28:00 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-13 20:23:11 +00:00
|
|
|
# Clang
|
2020-03-18 13:28:00 +00:00
|
|
|
if compiler.get_id() == 'clang'
|
2020-04-13 20:23:11 +00:00
|
|
|
|
|
|
|
if get_option('ALL_WARNINGS')
|
|
|
|
add_project_arguments([ '-Weverything' ], language : 'cpp')
|
|
|
|
endif
|
2020-03-18 13:28:00 +00:00
|
|
|
add_project_arguments([
|
|
|
|
'-ferror-limit=5',
|
2020-04-13 20:23:11 +00:00
|
|
|
'-fchar8_t',
|
|
|
|
'-Wno-unused-command-line-argument',
|
|
|
|
|
|
|
|
# flags from here down are disabling stupidly pedantic warnings that only appear with -Weverything
|
2020-03-18 13:28:00 +00:00
|
|
|
'-Wno-c++98-compat',
|
|
|
|
'-Wno-c++98-compat-pedantic',
|
2020-04-08 13:33:57 +00:00
|
|
|
'-Wno-documentation',
|
2020-03-18 13:28:00 +00:00
|
|
|
'-Wno-documentation-unknown-command',
|
2020-04-13 20:23:11 +00:00
|
|
|
'-Wno-switch-enum',
|
|
|
|
'-Wno-covered-switch-default'
|
2020-03-18 13:28:00 +00:00
|
|
|
],
|
|
|
|
language : 'cpp'
|
|
|
|
)
|
2020-04-13 20:23:11 +00:00
|
|
|
if get_option('TIME_TRACE')
|
|
|
|
add_project_arguments([ '-ftime-trace' ], language : 'cpp')
|
|
|
|
endif
|
|
|
|
if get_option('SMALL_BINARIES')
|
|
|
|
add_project_arguments([ '-Oz', '-fmerge-all-constants' ], language : 'cpp')
|
|
|
|
endif
|
2020-03-18 13:28:00 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-13 20:23:11 +00:00
|
|
|
# ICC's visual studio frontend, ICL
|
2020-03-18 13:28:00 +00:00
|
|
|
if compiler.get_id() == 'intel-cl'
|
|
|
|
add_project_arguments([
|
|
|
|
'/Qoption,cpp,--unicode_source_kind,UTF-8',
|
|
|
|
'/std=c++latest',
|
|
|
|
'/wd82', # storage class is not first
|
|
|
|
'/wd280', # selector expression is constant (why the fuck is that a warning?)
|
|
|
|
'/wd411', # class provides no constructor (duh, it's an aggregate)
|
|
|
|
'/wd1011', # missing return statement (false negative)
|
|
|
|
'/wd1628', # function marked [[noreturn]] returns (false positive)
|
|
|
|
'/wd3280' # declaration hides member (triggered in Catch2)
|
|
|
|
],
|
|
|
|
language : 'cpp'
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
|
|
|
inc = include_directories('include', 'extern')
|
|
|
|
|
|
|
|
if build_tests
|
|
|
|
subdir('tests')
|
|
|
|
else
|
|
|
|
message('Not building tests')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if build_examples
|
|
|
|
subdir('examples')
|
|
|
|
else
|
|
|
|
message('Not building examples')
|
|
|
|
endif
|
|
|
|
|
2020-03-04 11:01:46 +00:00
|
|
|
endif
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-04-03 08:03:15 +00:00
|
|
|
install_subdir('include/toml++/',
|
|
|
|
strip_directory: true,
|
|
|
|
install_dir: 'include/toml++'
|
|
|
|
)
|
|
|
|
|
|
|
|
pkgc = import('pkgconfig')
|
|
|
|
pkgc.generate (
|
2020-04-07 15:26:55 +00:00
|
|
|
name: meson.project_name(),
|
2020-04-03 08:03:15 +00:00
|
|
|
version: meson.project_version(),
|
2020-04-06 12:57:49 +00:00
|
|
|
description: 'Header-only TOML config file parser and serializer for modern C++'
|
2020-04-03 08:03:15 +00:00
|
|
|
)
|
2020-04-07 15:33:00 +00:00
|
|
|
|
2020-04-07 19:34:54 +00:00
|
|
|
# meson cmake stuff requires at least 0.50
|
|
|
|
if meson.version().version_compare('>= 0.50')
|
|
|
|
if get_option('GENERATE_CMAKE_CONFIG').enabled() or (get_option('GENERATE_CMAKE_CONFIG').auto() and not meson.is_subproject())
|
|
|
|
cmake = import('cmake')
|
|
|
|
cmake.write_basic_package_version_file(
|
|
|
|
name: meson.project_name(),
|
|
|
|
version: meson.project_version()
|
|
|
|
)
|
|
|
|
|
|
|
|
cmake_conf = configuration_data()
|
|
|
|
cmake.configure_package_config_file(
|
|
|
|
name: meson.project_name(),
|
|
|
|
input: 'cmake/tomlplusplus.cmake.in',
|
|
|
|
configuration: cmake_conf,
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
endif
|