Skip to content
Snippets Groups Projects
Commit 7661b1fa authored by Chun-wei Fan's avatar Chun-wei Fan
Browse files

build: Don't assume PThreads if threading support is found

Look also for pthread.h if threading support is found by Meson, as the
underlying threading support may not be PThreads, depending on platform.

For now, disable the thread-test test program if pthread.h and if
necessary, the PThreads library, cannot be found, as the current
implementation assumes the use of PThreads.

Also bump the required Meson version to 0.50.0 since we need it for
-cc.get_argument_syntax()
-For a later commit, the has_headers sub-method for cc.find_library()
parent e9db2689
No related branches found
No related tags found
Loading
......@@ -23,7 +23,7 @@ project(
['c'],
version : '0.38.5',
license : 'MIT',
meson_version : '>= 0.47.2',
meson_version : '>= 0.50.0',
default_options : ['buildtype=debugoptimized'],
)
......@@ -393,7 +393,29 @@ if dep_png.found()
endif
dep_m = cc.find_library('m', required : false)
dep_threads = dependency('threads')
if dep_threads.found()
# MSVC-style compilers do not come with pthreads, so we must link
# to it explicitly, currently pthreads-win32 is supported
pthreads_found = false
if dep_threads.found() and cc.has_header('pthread.h')
if cc.get_argument_syntax() == 'msvc'
pthread_lib = null_dep
foreach pthread_type : ['VC3', 'VSE3', 'VCE3', 'VC2', 'VSE2', 'VCE2']
if not pthread_lib.found()
pthread_lib = cc.find_library('pthread@0@'.format(pthread_type), required : false)
endif
endforeach
if pthread_lib.found()
pthreads_found = true
dep_threads = pthread_lib
endif
else
pthreads_found = true
endif
endif
if pthreads_found
config.set('HAVE_PTHREADS', 1)
endif
......
......@@ -34,7 +34,6 @@ tests = [
'scaling-crash-test',
'alpha-loop',
'scaling-helpers-test',
'thread-test',
'rotate-test',
'alphamap',
'gradient-crash-test',
......@@ -54,6 +53,12 @@ tests = [
'tolerance-test',
]
# Remove/update this once thread-test.c supports threading methods
# other than PThreads
if pthreads_found
tests += 'thread-test'
endif
progs = [
'lowlevel-blt-bench',
'radial-perf-test',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment