2023-01-22 19:53:21 +00:00
|
|
|
# This file is a part of toml++ and is subject to the the terms of the MIT license.
|
|
|
|
# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
|
|
|
# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2020-01-04 14:21:38 +00:00
|
|
|
project(
|
2020-02-29 20:34:08 +00:00
|
|
|
'tomlplusplus',
|
|
|
|
'cpp',
|
2021-09-22 06:47:15 +00:00
|
|
|
license: 'MIT',
|
2023-01-22 19:53:21 +00:00
|
|
|
version: '3.2.0',
|
|
|
|
meson_version: '>=0.61.0',
|
|
|
|
default_options: [
|
|
|
|
# https://mesonbuild.com/Builtin-options.html
|
2020-09-05 10:26:12 +00:00
|
|
|
# core options
|
|
|
|
'buildtype=release',
|
2023-01-22 19:53:21 +00:00
|
|
|
'default_library=shared',
|
2020-09-05 10:26:12 +00:00
|
|
|
# base options
|
2023-01-22 19:53:21 +00:00
|
|
|
'b_lto=false',
|
2020-09-05 10:26:12 +00:00
|
|
|
'b_ndebug=if-release',
|
|
|
|
# compiler options
|
|
|
|
'cpp_std=c++17'
|
2020-01-04 14:21:38 +00:00
|
|
|
]
|
|
|
|
)
|
2020-02-29 20:34:08 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# global vars + imports
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-03-04 11:01:46 +00:00
|
|
|
|
2020-09-05 10:26:12 +00:00
|
|
|
compiler = meson.get_compiler('cpp')
|
2021-10-25 19:15:23 +00:00
|
|
|
message('target cpu_family: @0@'.format(host_machine.cpu_family()))
|
|
|
|
message('target cpu: @0@'.format(host_machine.cpu()))
|
|
|
|
message('target system: @0@'.format(host_machine.system()))
|
|
|
|
message('target endian: @0@'.format(host_machine.endian()))
|
2020-03-18 13:28:00 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
is_devel = get_option('devel')
|
2020-09-05 10:26:12 +00:00
|
|
|
is_debug = get_option('debug')
|
|
|
|
is_release = not is_debug
|
2023-01-22 19:53:21 +00:00
|
|
|
is_pedantic = get_option('pedantic') or is_devel
|
2020-09-05 10:26:12 +00:00
|
|
|
is_windows = host_machine.system() == 'windows'
|
|
|
|
is_x64 = host_machine.cpu_family() == 'x86_64'
|
|
|
|
is_subproject = meson.is_subproject()
|
2020-03-18 13:28:00 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
cpp = meson.get_compiler('cpp')
|
|
|
|
is_gcc = cpp.get_id() == 'gcc'
|
|
|
|
is_clang = cpp.get_id() == 'clang'
|
|
|
|
is_msvc = cpp.get_id() == 'msvc'
|
|
|
|
is_icc_cl = cpp.get_id() == 'intel-cl'
|
|
|
|
is_icc = is_icc_cl or cpp.get_id() == 'intel'
|
|
|
|
is_lld = cpp.get_linker_id() == 'ld.lld'
|
|
|
|
has_exceptions = get_option('cpp_eh') != 'none'
|
2023-01-22 20:09:41 +00:00
|
|
|
unreleased_features = get_option('unreleased_features')
|
2020-09-05 10:26:12 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
build_tests = (get_option('build_tests') or is_devel) and not is_subproject
|
|
|
|
build_examples = (get_option('build_examples') or is_devel) and not is_subproject
|
2023-01-22 20:09:41 +00:00
|
|
|
build_tt = (get_option('build_tt') or is_devel) and not is_subproject and has_exceptions and not unreleased_features
|
2023-01-22 19:53:21 +00:00
|
|
|
build_lib = get_option('build_lib') or get_option('compile_library') or build_tests or build_examples or build_tt
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# global_args
|
|
|
|
#
|
|
|
|
# these are the arguments common to everything in the project
|
|
|
|
# *** they are not forwarded to dependents when using this as a submodule. ***
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
global_args = cpp.get_supported_arguments(
|
|
|
|
# clang/gcc
|
|
|
|
'-ferror-limit=5',
|
|
|
|
'-fmax-errors=5',
|
|
|
|
'-Wno-unused-command-line-argument',
|
|
|
|
'-Wno-reserved-macro-identifier',
|
|
|
|
'-Wno-init-list-lifetime',
|
|
|
|
'-fchar8_t',
|
|
|
|
# msvc
|
|
|
|
'/bigobj',
|
|
|
|
'/Gy', # function-level linking
|
|
|
|
'/GF', # string pooling
|
|
|
|
'/openmp-',
|
|
|
|
'/permissive-',
|
|
|
|
'/utf-8',
|
|
|
|
'/volatile:iso',
|
|
|
|
'/Zc:__cplusplus',
|
|
|
|
'/Zc:inline',
|
|
|
|
'/Zc:externConstexpr',
|
|
|
|
'/Zc:preprocessor'
|
|
|
|
)
|
|
|
|
if has_exceptions
|
|
|
|
global_args += cpp.get_supported_arguments('/Zc:throwingNew', '-D_HAS_EXCEPTIONS=1')
|
|
|
|
else
|
|
|
|
global_args += cpp.get_supported_arguments('-D_HAS_EXCEPTIONS=0')
|
|
|
|
endif
|
|
|
|
if is_pedantic
|
|
|
|
global_args += cpp.get_supported_arguments(
|
|
|
|
# clang
|
|
|
|
'-Weverything',
|
|
|
|
# gcc
|
|
|
|
'-Wcast-align',
|
|
|
|
'-Wcast-qual',
|
|
|
|
'-Wctor-dtor-privacy',
|
|
|
|
'-Wdisabled-optimization',
|
|
|
|
'-Wfloat-equal',
|
|
|
|
'-Wimport',
|
|
|
|
'-Winit-self',
|
|
|
|
'-Wlogical-op',
|
|
|
|
'-Wmissing-declarations',
|
|
|
|
'-Wmissing-field-initializers',
|
|
|
|
'-Wmissing-format-attribute',
|
|
|
|
'-Wmissing-include-dirs',
|
|
|
|
'-Wmissing-noreturn',
|
|
|
|
'-Wold-style-cast',
|
|
|
|
'-Woverloaded-virtual',
|
|
|
|
'-Wpacked',
|
|
|
|
'-Wpointer-arith',
|
|
|
|
'-Wredundant-decls',
|
|
|
|
'-Wshadow',
|
|
|
|
'-Wsign-conversion',
|
|
|
|
'-Wsign-promo',
|
|
|
|
'-Wstack-protector',
|
|
|
|
'-Wstrict-null-sentinel',
|
|
|
|
'-Wswitch-default',
|
|
|
|
'-Wswitch-enum',
|
|
|
|
'-Wundef',
|
|
|
|
'-Wunreachable-code',
|
|
|
|
'-Wunused',
|
|
|
|
'-Wunused-parameter',
|
|
|
|
'-Wuseless-cast',
|
|
|
|
'-Wvariadic-macros',
|
|
|
|
'-Wwrite-strings',
|
2023-01-22 20:09:41 +00:00
|
|
|
'-Wmissing-noreturn'
|
2023-01-22 19:53:21 +00:00
|
|
|
)
|
2020-09-05 10:26:12 +00:00
|
|
|
endif
|
2023-01-22 20:09:41 +00:00
|
|
|
# unnecessary pedantry:
|
2023-01-22 19:53:21 +00:00
|
|
|
global_args += cpp.get_supported_arguments(
|
|
|
|
'-Wno-c++98-compat',
|
|
|
|
'-Wno-c++98-compat-pedantic',
|
|
|
|
'-Wno-documentation',
|
|
|
|
'-Wno-documentation-unknown-command',
|
|
|
|
'-Wno-switch-enum',
|
2023-01-22 20:09:41 +00:00
|
|
|
'-Wno-covered-switch-default',
|
|
|
|
'-Wno-padded',
|
|
|
|
'-Wno-float-equal'
|
2020-09-05 10:26:12 +00:00
|
|
|
)
|
2023-01-22 19:53:21 +00:00
|
|
|
if get_option('time_trace')
|
|
|
|
global_args += cpp.get_supported_arguments('-ftime-trace')
|
2020-09-05 10:26:12 +00:00
|
|
|
endif
|
2020-10-30 13:09:28 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# global_link_args
|
|
|
|
#
|
|
|
|
# these are the linker arguments common to everything in the projectwhen compiling shared libraries and executables.
|
|
|
|
# *** they are not forwarded to dependents when using this as a submodule. ***
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-10-30 13:09:28 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
global_link_args = []
|
2020-10-30 13:09:28 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
if is_release
|
|
|
|
global_link_args += cpp.get_supported_link_arguments(
|
|
|
|
# msvc
|
|
|
|
'/OPT:REF,ICF=3',
|
|
|
|
'/INCREMENTAL:NO',
|
|
|
|
)
|
2020-09-05 10:26:12 +00:00
|
|
|
endif
|
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# global_overrides
|
|
|
|
#
|
|
|
|
# these are the meson overrides common to everything in the project
|
|
|
|
# *** they are not forwarded to dependents when using this as a submodule. ***
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-09-05 10:26:12 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
global_overrides = [ ]
|
|
|
|
if is_pedantic
|
|
|
|
global_overrides += [
|
|
|
|
'warning_level=3',
|
|
|
|
'werror=true',
|
|
|
|
]
|
2020-09-05 10:26:12 +00:00
|
|
|
endif
|
2020-03-18 13:28:00 +00:00
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# subdirectories + files
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public_headers = []
|
|
|
|
internal_headers = []
|
2020-09-05 10:26:12 +00:00
|
|
|
|
2022-02-12 13:25:20 +00:00
|
|
|
# Empty dependency that will be filled either in src/ or include/
|
|
|
|
tomlplusplus_dep = dependency('', required: false)
|
|
|
|
|
2023-01-22 19:53:21 +00:00
|
|
|
subdir('include')
|
|
|
|
|
|
|
|
if build_lib
|
2022-02-12 13:25:20 +00:00
|
|
|
subdir('src')
|
|
|
|
endif
|
|
|
|
|
2020-09-05 10:26:12 +00:00
|
|
|
if build_tests
|
|
|
|
subdir('tests')
|
2020-03-04 11:01:46 +00:00
|
|
|
endif
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-09-05 10:26:12 +00:00
|
|
|
if build_examples
|
|
|
|
subdir('examples')
|
|
|
|
endif
|
|
|
|
|
2022-01-03 18:51:03 +00:00
|
|
|
if build_tt
|
|
|
|
subdir('toml-test')
|
|
|
|
endif
|
|
|
|
|
2022-02-12 13:25:20 +00:00
|
|
|
# Allow subproject usage
|
2022-02-02 14:01:52 +00:00
|
|
|
meson.override_dependency(meson.project_name(), tomlplusplus_dep)
|