[Piglit] [PATCH 1/2] cmake: Detect if system has POSIX MONOTONIC clocks
Jordan Justen
jordan.l.justen at intel.com
Thu Oct 17 19:52:18 CEST 2013
From: Chad Versace <chad.versace at linux.intel.com>
Set CMake cache var PIGLIT_HAS_POSIX_CLOCK_MONOTONIC if
clock_gettime() is available with CLOCK_MONOTONIC.
Tests that need to measure time, such as GL_ARB_sync tests, will use
Posix clocks.
v2: (jordan.l.justen at intel.com)
* PIGLIT_HAS_POSIX_CLOCKS => PIGLIT_HAS_POSIX_CLOCK_MONOTONIC
* Link with librt. On older systems, clocks_gettime may be in
librt rather than glibc.
CC: Nicholas Mack <nichmack at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
Cc: Chad Versace <chad.versace at linux.intel.com>
Cc: Ian Romanick <idr at freedesktop.org>
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
CMakeLists.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ec5ddf..7404287 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,24 @@ else (APPLE)
)
endif (APPLE)
+FIND_LIBRARY(HAVE_LIBRT NAMES rt)
+if(HAVE_LIBRT)
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
+endif()
+check_c_source_compiles(
+ "
+ #define _POSIX_C_SOURCE 199309L
+ #include <time.h>
+ int main() { return clock_gettime(CLOCK_MONOTONIC, NULL); }
+ "
+ PIGLIT_HAS_POSIX_CLOCK_MONOTONIC
+)
+set(CMAKE_REQUIRED_LIBRARIES)
+
+if(PIGLIT_HAS_POSIX_CLOCK_MONOTONIC)
+ add_definitions(-DPIGLIT_HAS_POSIX_CLOCK_MONOTONIC)
+endif()
+
FIND_LIBRARY(OPENGL_egl_LIBRARY
NAMES EGL
PATHS /usr/lib
--
1.7.10.4
More information about the Piglit
mailing list