Set PIGLIT_HAS_PTHREADS as a CMake variable and cpp feature macro if
CMake succeeds in compiling a small test file that uses pthread_self(),

Future EGL_KHR_fence_sync tests will be multi-threaded.

Signed-off-by: Chad Versace <[email protected]>
---
 CMakeLists.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bef9c35..88a1483 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -318,6 +318,24 @@ if(PIGLIT_HAS_POSIX_CLOCK_MONOTONIC)
        add_definitions(-DPIGLIT_HAS_POSIX_CLOCK_MONOTONIC)
 endif()
 
+# Set PIGLIT_HAS_PTHREADS.
+FIND_LIBRARY(HAVE_PTHREADS pthread)
+if(HAVE_PTHREADS)
+       set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
+endif()
+check_c_source_compiles(
+       "
+       #include <pthread.h>
+       int main() { return (int) pthread_self(); }
+       "
+       PIGLIT_HAS_PTHREADS
+)
+set(CMAKE_REQUIRED_LIBRARIES)
+
+if(PIGLIT_HAS_PTHREADS)
+       add_definitions(-DPIGLIT_HAS_PTHREADS)
+endif()
+
 if(PIGLIT_USE_WAFFLE AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
        pkg_check_modules(EGL egl)
 endif()
-- 
1.8.5.3

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to