[Piglit] [PATCH 12/13] cmake: Check for pthreads

Chad Versace chad.versace at linux.intel.com
Wed Mar 26 10:40:28 PDT 2014


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 <chad.versace at linux.intel.com>
---
 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



More information about the Piglit mailing list