project('libalabaster', 'c', version: '0.01', meson_version: '>=0.63.0', default_options: ['warning_level=2', 'c_std=c99'], license: 'GPL-3.0-only') compiler = meson.get_compiler('c') is_debug = get_option('debug') is_msvc = compiler.get_id() == 'msvc' or compiler.get_id() == 'clang-cl' is_msvc_specifically = compiler.cmd_array()[0] == 'cl' supports_needed_gnu_extensions = not is_msvc_specifically have_builtin_expect = compiler.has_function('__builtin_expect') have_typeof = compiler.compiles('__typeof__(1) j;') if not have_typeof error('Compiler support for \'__typeof__()\' is required.') endif have_posix_memalign = compiler.has_function( 'posix_memalign', prefix: '#define _POSIX_C_SOURCE 200112L\n#include ') have_wide_string = compiler.has_function('wcsrtombs') have_wide_string_width = compiler.has_function('wcswidth') # For testing: '-Wshadow', '-Wconversion', '-Wc++-compat' alabaster_args = ['-fstrict-aliasing', '-Wstrict-aliasing'] if is_debug alabaster_args += ['-DAL_DEBUG'] endif if is_msvc_specifically alabaster_args += ['/arch:AVX'] endif if supports_needed_gnu_extensions alabaster_args += ['-DAL_HAVE_GNU_EXTENSIONS'] endif if have_builtin_expect alabaster_args += ['-DAL_HAVE_BUILTIN_EXPECT'] endif if have_posix_memalign alabaster_args += ['-DAL_HAVE_POSIX_MEMALIGN'] endif if have_wide_string alabaster_args += ['-DAL_HAVE_WIDE_STRING'] endif if have_wide_string_width alabaster_args += ['-DAL_HAVE_WIDE_STRING_WIDTH'] endif c89atomic = subproject('c89atomic').get_variable('c89atomic') alabaster_src = [ 'src/lib.c', 'src/random.c', 'src/str.c', 'src/log.c', 'src/ring_buffer.c' ] alabaster_inc = include_directories('include') alabaster_deps = [c89atomic] alabaster = declare_dependency(include_directories: alabaster_inc, dependencies: alabaster_deps, sources: alabaster_src, compile_args: alabaster_args) if get_option('tests').allowed() and not meson.is_subproject() tests_src = [ 'tests/main.c', 'tests/lib.c', 'tests/array.c', 'tests/str.c', 'tests/ring_buffer.c' ] if supports_needed_gnu_extensions tests_src += ['tests/array_typed.c'] endif executable('tests', tests_src, dependencies: alabaster, install: false) endif