diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-07-24 14:44:39 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-11-19 05:49:35 +0800 |
commit | 7661b1fae982da029ef56e58a1df2a4d6fd48444 (patch) | |
tree | a803e98a92ee72c0175a922ba334e2373c5ba921 /meson.build | |
parent | e9db26898b8aae8737dddb11f5ba2abb6ec6ca5f (diff) | |
download | pixman-7661b1fae982da029ef56e58a1df2a4d6fd48444.tar.gz |
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()
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/meson.build b/meson.build index 8f062bc..5e9f221 100644 --- a/meson.build +++ b/meson.build @@ -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 |