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

Jordan Justen jljusten at gmail.com
Tue Oct 15 01:37:44 CEST 2013


Chad,

I wanted a similar feature, but I was also thinking of adding a
piglit-util function (piglit_get_microseconds). I think it should be
easy to port this function to windows.

I also had the cmake parts a little different, but I don't really have
a preference on that.

http://cgit.freedesktop.org/~jljusten/piglit/commit/?id=d1a9c3fb

-Jordan


On Mon, Oct 14, 2013 at 11:06 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> 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
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list