summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-21 23:57:05 -0400
committerDavid Robillard <d@drobilla.net>2022-10-14 17:53:49 -0400
commit03a4eb365c510fcbc8aa88f6a393067b2796755c (patch)
tree0d4c6df2e4e226a2c8fe89545744e18c9f2a023a /meson.build
parent36e3327b032e64f19ba1c0e1dc06cb40b7b79d02 (diff)
downloadzix-03a4eb365c510fcbc8aa88f6a393067b2796755c.tar.gz
zix-03a4eb365c510fcbc8aa88f6a393067b2796755c.tar.bz2
zix-03a4eb365c510fcbc8aa88f6a393067b2796755c.zip
Clean up platform configuration checks
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build48
1 files changed, 22 insertions, 26 deletions
diff --git a/meson.build b/meson.build
index 972b324..a231cee 100644
--- a/meson.build
+++ b/meson.build
@@ -34,6 +34,8 @@ subdir('meson/suppressions')
# Platform Configuration #
##########################
+thread_dep = dependency('threads', required: get_option('tests'))
+
platform_c_args = []
# Determine whether to use POSIX
@@ -46,8 +48,6 @@ endif
# Check for platform features with the build system
if get_option('checks')
- platform_c_args += ['-DZIX_NO_DEFAULT_CONFIG']
-
clock_gettime_code = '''#include <time.h>
int main(void) { struct timespec t; return clock_gettime(CLOCK_MONOTONIC, &t); }
'''
@@ -62,33 +62,29 @@ int main(void) { void* mem; posix_memalign(&mem, 8, 8); }'''
#include <time.h>
int main(void) { sem_t s; struct timespec t; return sem_timedwait(&s, &t); }'''
- platform_c_args += '-DHAVE_CLOCK_GETTIME=@0@'.format(
- cc.compiles(clock_gettime_code,
- args: platform_c_args,
- name: 'clock_gettime').to_int())
-
- 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,
+ platform_c_args += [
+ '-DZIX_NO_DEFAULT_CONFIG',
+ '-DHAVE_CLOCK_GETTIME=@0@'.format(
+ cc.links(clock_gettime_code,
+ args: platform_c_args,
+ name: 'clock_gettime').to_int()),
+ '-DHAVE_MLOCK=@0@'.format(
+ cc.links(mlock_code,
+ args: platform_c_args,
+ name: 'mlock').to_int()),
+ '-DHAVE_POSIX_MEMALIGN=@0@'.format(
+ cc.links(posix_memalign_code,
+ args: platform_c_args,
+ name: 'posix_memalign').to_int()),
+ '-DHAVE_SEM_TIMEDWAIT=@0@'.format(
+ (host_machine.system() not in ['darwin', 'windows'] and
+ cc.links(sem_timedwait_code,
args: platform_c_args,
- name: 'posix_memalign').to_int())
-
- platform_c_args += '-DHAVE_SEM_TIMEDWAIT=@0@'.format(
- cc.compiles(sem_timedwait_code,
- args: platform_c_args,
- name: 'sem_timedwait').to_int())
+ dependencies: [thread_dep],
+ name: 'sem_timedwait')).to_int()),
+ ]
endif
-################
-# Dependencies #
-################
-
-thread_dep = dependency('threads', include_type: 'system')
-
###########
# Library #
###########