pthread_checks.cmake raw
1 # Copyright (c) The Bitcoin Core developers
2 # Distributed under the MIT software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 # Define HAVE_PTHREAD_* variables depending on what pthread functions are
6 # available.
7
8 include(CMakePushCheckState)
9 include(CheckCXXSourceCompiles)
10
11 cmake_push_check_state()
12 set(CMAKE_REQUIRED_LIBRARIES Threads::Threads)
13 check_cxx_source_compiles("
14 #include <pthread.h>
15 int main(int argc, char** argv)
16 {
17 char thread_name[16];
18 return pthread_getname_np(pthread_self(), thread_name, sizeof(thread_name));
19 }"
20 HAVE_PTHREAD_GETNAME_NP)
21
22 check_cxx_source_compiles("
23 #include <cstdint>
24 #include <pthread.h>
25 int main(int argc, char** argv)
26 {
27 uint64_t tid;
28 pthread_threadid_np(nullptr, &tid);
29 return 0;
30 }"
31 HAVE_PTHREAD_THREADID_NP)
32
33 check_cxx_source_compiles("
34 #include <pthread.h>
35 #include <pthread_np.h>
36 int main(int argc, char** argv)
37 {
38 return pthread_getthreadid_np();
39 }"
40 HAVE_PTHREAD_GETTHREADID_NP)
41 cmake_pop_check_state()
42