meson: Don't define HAVE_PTHREAD only on linux
[mesa.git] / meson.build
index e4d0e0f80cb2275b984f6a170e7a1fa93c1dbb8a..383ebb366625edf9f26256db160a7eab35fdb3af 100644 (file)
@@ -154,6 +154,29 @@ if _drivers != ''
   with_gallium = true
 endif
 
+with_intel_vk = false
+with_amd_vk = false
+with_any_vk = false
+_vulkan_drivers = get_option('vulkan-drivers')
+if _vulkan_drivers == 'auto'
+  if not ['darwin', 'windows'].contains(host_machine.system())
+    if host_machine.cpu_family().startswith('x86')
+      _vulkan_drivers = 'amd,intel'
+    else
+      error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
+    endif
+  else
+    # No vulkan driver supports windows or macOS currently
+    _vulkan_drivers = ''
+  endif
+endif
+if _vulkan_drivers != ''
+  _split = _vulkan_drivers.split(',')
+  with_intel_vk = _split.contains('intel')
+  with_amd_vk = _split.contains('amd')
+  with_any_vk = with_amd_vk or with_intel_vk
+endif
+
 if with_dri_swrast and with_gallium_softpipe
   error('Only one swrast provider can be built')
 endif
@@ -285,29 +308,6 @@ if with_vulkan_icd_dir == ''
   with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
 endif
 
-with_intel_vk = false
-with_amd_vk = false
-with_any_vk = false
-_vulkan_drivers = get_option('vulkan-drivers')
-if _vulkan_drivers == 'auto'
-  if not ['darwin', 'windows'].contains(host_machine.system())
-    if host_machine.cpu_family().startswith('x86')
-      _vulkan_drivers = 'amd,intel'
-    else
-      error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
-    endif
-  else
-    # No vulkan driver supports windows or macOS currently
-    _vulkan_drivers = ''
-  endif
-endif
-if _vulkan_drivers != ''
-  _split = _vulkan_drivers.split(',')
-  with_intel_vk = _split.contains('intel')
-  with_amd_vk = _split.contains('amd')
-  with_any_vk = with_amd_vk or with_intel_vk
-endif
-
 with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
 with_dri3 = get_option('dri3')
 if with_dri3 == 'auto'
@@ -578,7 +578,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
   endif
 endforeach
 
-foreach f : ['strtof', 'mkostemp', 'posix_memalign']
+foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get']
   if cc.has_function(f)
     pre_args += '-DHAVE_@0@'.format(f.to_upper())
   endif
@@ -668,7 +668,7 @@ endif
 # TODO: some of these may be conditional
 dep_zlib = dependency('zlib', version : '>= 1.2.3')
 dep_thread = dependency('threads')
-if dep_thread.found() and host_machine.system() == 'linux'
+if dep_thread.found() and host_machine.system() != 'windows'
   pre_args += '-DHAVE_PTHREAD'
 endif
 dep_elf = dependency('libelf', required : false)
@@ -922,7 +922,7 @@ endif
 if dep_m.found()
   gl_priv_libs += '-lm'
 endif
-if dep_dl.found()
+if dep_dl != [] and dep_dl.found()
   gl_priv_libs += '-ldl'
 endif