[Piglit] [PATCH] cmake: Detect if system has POSIX clocks

Chad Versace chad.versace at linux.intel.com
Mon Oct 14 20:06:55 CEST 2013


Set CMake cache var PIGLIT_HAS_POSIX_CLOCKS if if clock_gettime() is
available.

Tests that need to measure time, such as GL_ARB_sync tests, will use
Posix clocks.

CC: Nicholas Mack <nichmack at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 CMakeLists.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ec5ddf..ac66152 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.6)
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
 
 INCLUDE (CheckCCompilerFlag)
+INCLUDE (CheckCSourceCompiles)
 INCLUDE (CheckCXXCompilerFlag)
 INCLUDE (CheckFunctionExists)
 INCLUDE (CheckIncludeFile)
@@ -266,6 +267,16 @@ else (APPLE)
 	)
 endif (APPLE)
 
+check_c_source_compiles(
+	"
+	#define POSIX_C_SOURCE >= 199309L
+	#include <time.h>
+	int main() { return clock_gettime(CLOCK_MONOTONIC, NULL); }
+	"
+
+	PIGLIT_HAS_POSIX_CLOCKS
+)
+
 FIND_LIBRARY(OPENGL_egl_LIBRARY
       NAMES EGL
       PATHS /usr/lib
-- 
1.8.3.1



More information about the Piglit mailing list