spdlog/meson.build

142 lines
3.4 KiB
Meson
Raw Normal View History

2019-06-30 10:27:28 -04:00
project('spdlog', ['cpp'],
license : 'MIT',
2019-07-01 06:37:18 -04:00
version : run_command(find_program('scripts/extract_version.py')).stdout().strip(),
2019-06-30 10:48:20 -04:00
default_options : [
'warning_level=3',
'cpp_std=c++11',
'buildtype=release',
'b_colorout=always',
],
2019-06-30 10:27:28 -04:00
)
# ------------------------
# --- Dependencies ---
# ------------------------
dep_list = []
compile_args = []
# Threads
dep_list += dependency('threads')
# Check for FMT
2019-07-14 09:29:23 -04:00
if get_option('external_fmt')
2019-06-30 10:27:28 -04:00
if not meson.version().version_compare('>=0.49.0')
warning('Finding fmt can fail wit meson versions before 0.49.0')
endif
dep_list += dependency('fmt')
compile_args += '-DSPDLOG_FMT_EXTERNAL'
endif
2019-09-18 08:01:23 -04:00
if get_option('no_exceptions')
compile_args += '-DSPDLOG_NO_EXCEPTIONS'
endif
2019-06-30 10:27:28 -04:00
# ------------------------------------
# --- Compiled library version ---
# ------------------------------------
spdlog_inc = include_directories('./include')
2019-09-18 08:01:23 -04:00
spdlog_srcs = files([
'src/async.cpp',
'src/color_sinks.cpp',
'src/file_sinks.cpp',
'src/fmt.cpp',
'src/spdlog.cpp',
'src/stdout_sinks.cpp'
])
if get_option('library_type') == 'static'
2019-09-18 08:01:23 -04:00
spdlog = static_library(
'spdlog',
spdlog_srcs,
cpp_args : [compile_args] + ['-DSPDLOG_COMPILED_LIB'],
include_directories : spdlog_inc,
dependencies : dep_list,
2019-09-18 08:01:23 -04:00
install : not meson.is_subproject()
)
else
2019-09-18 08:01:23 -04:00
spdlog = shared_library('spdlog',
spdlog_srcs,
cpp_args : [compile_args] + ['-DSPDLOG_COMPILED_LIB'],
include_directories : spdlog_inc,
dependencies : dep_list,
install : not meson.is_subproject(),
)
endif
2019-06-30 10:27:28 -04:00
spdlog_dep = declare_dependency(
link_with : spdlog,
include_directories : spdlog_inc,
compile_args : compile_args + ['-DSPDLOG_COMPILED_LIB'],
dependencies : dep_list,
version : meson.project_version(),
)
# ----------------------------------
# --- Header only dependency ---
# ----------------------------------
spdlog_headeronly_dep = declare_dependency(
include_directories : spdlog_inc,
compile_args : compile_args,
dependencies : dep_list,
version : meson.project_version(),
)
# ------------------------
# --- Installation ---
# ------------------------
# Do not install when spdlog is used as a subproject
if not meson.is_subproject()
install_subdir('include/spdlog', install_dir: get_option('includedir'))
pkg = import('pkgconfig')
pkg.generate(spdlog,
name : 'spdlog',
description : 'Fast C++ logging library',
url : 'https://github.com/gabime/spdlog',
extra_cflags : ['-DSPDLOG_COMPILED_LIB']
)
endif
2019-06-30 10:27:28 -04:00
# -------------------------------------
# --- Conditionally add subdirs ---
# -------------------------------------
if get_option('enable_tests')
subdir('tests')
endif
if get_option('enable_examples')
subdir('example')
endif
if get_option('enable_benchmarks')
subdir('bench')
endif
# -------------------
# --- Summary ---
# -------------------
summary_str = '''spdlog build summary:
2019-07-14 09:29:23 -04:00
- using external fmt: @0@
2019-06-30 10:27:28 -04:00
- building tests: @1@
- building examples: @2@
- building benchmarks: @3@
- library type: @4@
2019-09-18 08:01:23 -04:00
- no exceptions: @5@
2019-06-30 10:27:28 -04:00
'''.format(
2019-07-14 09:29:23 -04:00
get_option('external_fmt'),
2019-06-30 10:27:28 -04:00
get_option('enable_tests'),
get_option('enable_examples'),
get_option('enable_benchmarks'),
2019-09-18 08:01:23 -04:00
get_option('library_type'),
get_option('no_exceptions')
2019-06-30 10:27:28 -04:00
)
message(summary_str)