spdlog/meson.build

185 lines
4.6 KiB
Meson
Raw Normal View History

2019-06-30 22:27:28 +08:00
project('spdlog', ['cpp'],
2019-11-05 06:16:45 +08:00
license : 'MIT',
version : run_command(find_program('scripts/extract_version.py')).stdout().strip(),
default_options : [
2019-06-30 22:48:20 +08:00
'warning_level=3',
'cpp_std=c++11',
'buildtype=release',
'b_colorout=always',
2019-11-05 06:16:45 +08:00
],
2019-06-30 22:27:28 +08:00
)
# ------------------------
# --- Dependencies ---
# ------------------------
dep_list = []
compile_args = []
# Threads
dep_list += dependency('threads')
# Check for FMT
2019-07-14 21:29:23 +08:00
if get_option('external_fmt')
2019-11-05 06:16:45 +08:00
if not meson.version().version_compare('>=0.49.0')
warning('Finding fmt can fail with meson versions before 0.49.0')
2019-11-05 06:16:45 +08:00
endif
dep_list += dependency('fmt')
compile_args += '-DSPDLOG_FMT_EXTERNAL'
2019-06-30 22:27:28 +08:00
endif
2019-09-18 20:01:23 +08:00
if get_option('no_exceptions')
compile_args += '-DSPDLOG_NO_EXCEPTIONS'
endif
2019-11-05 06:16:45 +08:00
if get_option('wchar_support')
if build_machine.system() != 'windows'
error('wchar_support only supported under windows')
endif
compile_args += '-DSPDLOG_WCHAR_TO_UTF8_SUPPORT'
endif
if get_option('wchar_filenames')
if build_machine.system() != 'windows'
2019-11-05 06:22:30 +08:00
error('wchar_filenames only supported under windows')
2019-11-05 06:16:45 +08:00
endif
compile_args += '-DSPDLOG_WCHAR_FILENAMES'
endif
if get_option('clock_coarse')
if build_machine.system() != 'linux'
error('clock_coarse only supported under linux')
endif
compile_args += '-DSPDLOG_CLOCK_COARSE'
endif
if get_option('prevent_child_fd')
compile_args += '-DSPDLOG_PREVENT_CHILD_FD'
endif
if get_option('no_thread_id')
compile_args += '-DSPDLOG_NO_THREAD_ID'
endif
if get_option('no_tls')
compile_args += '-DSPDLOG_NO_TLS'
endif
if get_option('no_atomic_levels')
compile_args += '-DSPDLOG_NO_ATOMIC_LEVELS'
endif
compile_args_compiled = compile_args + ['-DSPDLOG_COMPILED_LIB']
compile_args_ho = compile_args
2019-06-30 22:27:28 +08:00
# ------------------------------------
# --- Compiled library version ---
# ------------------------------------
spdlog_inc = include_directories('./include')
2019-09-18 20:01:23 +08:00
spdlog_srcs = files([
'src/async.cpp',
'src/color_sinks.cpp',
'src/file_sinks.cpp',
'src/spdlog.cpp',
2019-12-21 23:49:34 +08:00
'src/stdout_sinks.cpp',
2019-12-22 01:45:14 +08:00
'src/loaders.cpp'
2019-09-18 20:01:23 +08:00
])
2019-11-05 05:38:31 +08:00
if not get_option('external_fmt')
spdlog_srcs+= 'src/fmt.cpp'
endif
if get_option('library_type') == 'static'
2019-11-05 06:16:45 +08:00
spdlog = static_library(
2019-09-18 20:01:23 +08:00
'spdlog',
spdlog_srcs,
2019-11-05 06:16:45 +08:00
cpp_args : compile_args_compiled,
include_directories : spdlog_inc,
dependencies : dep_list,
2019-09-18 20:01:23 +08:00
install : not meson.is_subproject()
)
else
2019-11-05 06:16:45 +08:00
spdlog = shared_library('spdlog',
2019-09-18 20:01:23 +08:00
spdlog_srcs,
2019-11-05 06:16:45 +08:00
cpp_args : compile_args_compiled,
include_directories : spdlog_inc,
dependencies : dep_list,
install : not meson.is_subproject(),
2019-11-29 20:32:41 +08:00
version : meson.project_version(),
2019-11-05 06:16:45 +08:00
)
endif
2019-06-30 22:27:28 +08:00
spdlog_dep = declare_dependency(
2019-11-05 06:16:45 +08:00
link_with : spdlog,
include_directories : spdlog_inc,
compile_args : compile_args_compiled,
dependencies : dep_list,
version : meson.project_version(),
2019-06-30 22:27:28 +08:00
)
# ----------------------------------
# --- Header only dependency ---
# ----------------------------------
spdlog_headeronly_dep = declare_dependency(
2019-11-05 06:16:45 +08:00
include_directories : spdlog_inc,
compile_args : compile_args_ho,
dependencies : dep_list,
version : meson.project_version(),
2019-06-30 22:27:28 +08:00
)
# ------------------------
# --- Installation ---
# ------------------------
# Do not install when spdlog is used as a subproject
if not meson.is_subproject()
2019-11-05 06:16:45 +08:00
install_subdir('include/spdlog', install_dir: get_option('includedir'))
2019-11-05 06:16:45 +08:00
pkg = import('pkgconfig')
pkg.generate(spdlog,
name : 'spdlog',
description : 'Fast C++ logging library',
url : 'https://github.com/gabime/spdlog',
2019-11-05 06:16:45 +08:00
extra_cflags : compile_args_compiled
)
endif
2019-06-30 22:27:28 +08:00
# -------------------------------------
# --- Conditionally add subdirs ---
# -------------------------------------
2019-11-05 06:31:36 +08:00
if get_option('enable_tests') or get_option('enable_tests-ho')
2019-11-05 06:16:45 +08:00
subdir('tests')
2019-06-30 22:27:28 +08:00
endif
if get_option('enable_examples')
2019-11-05 06:16:45 +08:00
subdir('example')
2019-06-30 22:27:28 +08:00
endif
if get_option('enable_benchmarks')
2019-11-05 06:16:45 +08:00
subdir('bench')
2019-06-30 22:27:28 +08:00
endif
# -------------------
# --- Summary ---
# -------------------
summary_str = '''spdlog build summary:
2019-07-14 21:29:23 +08:00
- using external fmt: @0@
2019-06-30 22:27:28 +08:00
- building tests: @1@
- building examples: @2@
- building benchmarks: @3@
- library type: @4@
2019-09-18 20:01:23 +08:00
- no exceptions: @5@
2019-06-30 22:27:28 +08:00
'''.format(
2019-07-14 21:29:23 +08:00
get_option('external_fmt'),
2019-06-30 22:27:28 +08:00
get_option('enable_tests'),
get_option('enable_examples'),
get_option('enable_benchmarks'),
2019-09-18 20:01:23 +08:00
get_option('library_type'),
get_option('no_exceptions')
2019-06-30 22:27:28 +08:00
)
message(summary_str)