diff options
author | David Robillard <d@drobilla.net> | 2022-06-28 16:14:45 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-06-28 18:52:19 -0400 |
commit | acb8ea62ac287efcfb50f20cd419b70f6c5a15a9 (patch) | |
tree | 657337f0bf6566b40e3a07002697347b5e35a0d9 /meson.build | |
parent | 58d7fe43076a9825cf1f99d94ce224445ab9e405 (diff) | |
download | zix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.tar.gz zix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.tar.bz2 zix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.zip |
Clean up build configuration
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/meson.build b/meson.build index e6f17b4..92525e8 100644 --- a/meson.build +++ b/meson.build @@ -26,20 +26,49 @@ cc = meson.get_compiler('c') # Set global warning flags if get_option('strict') and not meson.is_subproject() subdir('meson/warnings') + add_project_arguments(all_c_warnings, language: ['c']) endif subdir('meson/suppressions') +add_project_arguments(c_suppressions, language: ['c']) -add_project_arguments(all_c_warnings + c_suppressions, language: ['c']) +########################## +# Platform Configuration # +########################## -################ -# Dependencies # -################ +platform_c_args = [] -# Check for mlock() (used by ZixRing) -mlock_fragment = '''#include <sys/mman.h> - int main(void) { return mlock(0, 0); }''' -if cc.compiles(mlock_fragment, name: 'mlock') - add_project_arguments(['-DHAVE_MLOCK'], language: 'c') +# Determine whether to use POSIX +no_posix = get_option('posix').disabled() or host_machine.system() == 'windows' +if no_posix + platform_c_args += ['-DZIX_NO_POSIX'] +else + platform_c_args += ['-D_POSIX_C_SOURCE=200809L'] +endif + +# Check for platform features with the build system +if get_option('checks') + platform_c_args += ['-DZIX_NO_DEFAULT_CONFIG'] + + mlock_code = '''#include <sys/mman.h> +int main(void) { return mlock(0, 0); }''' + + posix_memalign_code = '''#include <stdlib.h> +int main(void) { void* mem; posix_memalign(&mem, 8, 8); }''' + + platform_c_args += '-DHAVE_MLOCK=@0@'.format( + cc.compiles(mlock_code, + args: platform_c_args, + name: 'mlock').to_int()) + + platform_c_args += '-DHAVE_POSIX_MEMALIGN=@0@'.format( + cc.compiles(posix_memalign_code, + args: platform_c_args, + name: 'posix_memalign').to_int()) +endif + +# Build as C++ on MSVC +if cc.get_id() == 'msvc' + add_project_arguments(['/TP'], language: ['c']) endif ########### @@ -81,7 +110,7 @@ if get_option('default_library') == 'static' endif # Set any additional arguments required for building libraries or programs -library_c_args = ['-DZIX_INTERNAL'] +library_c_args = platform_c_args + ['-DZIX_INTERNAL'] library_link_args = [] program_c_args = [] program_link_args = [] @@ -215,15 +244,15 @@ if not get_option('benchmarks').disabled() if glib_dep.found() build_benchmarks = true + benchmark_c_args = platform_c_args - benchmark_c_args = [] if cc.get_id() == 'clang' - benchmark_c_args += [ + benchmark_c_suppressions = [ '-Wno-reserved-identifier', ] - endif - benchmark_c_args = cc.get_supported_arguments(benchmark_c_args) + benchmark_c_args += cc.get_supported_arguments(benchmark_c_suppressions) + endif foreach benchmark : benchmarks benchmark(benchmark, |