aboutsummaryrefslogtreecommitdiff
path: root/ConfigureChecks.cmake
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2014-10-20 10:17:03 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-02-08 10:29:16 +0100
commit4b68c98d420fffd06d205179734c84b67959deae (patch)
tree923719302472faa853600ac46b311a1eb87cdce1 /ConfigureChecks.cmake
parent5c315f7e720daa45796b5f82493b0c4624fbb7e0 (diff)
downloadcmocka-4b68c98d420fffd06d205179734c84b67959deae.tar.gz
cmocka-4b68c98d420fffd06d205179734c84b67959deae.tar.xz
cmocka-4b68c98d420fffd06d205179734c84b67959deae.zip
cmocka: Add correct checks for clock_gettime().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r--ConfigureChecks.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 5540b53..761af94 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -61,6 +61,7 @@ check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+check_include_file(time.h HAVE_TIME_H)
check_include_file(unistd.h HAVE_UNISTD_H)
@@ -80,6 +81,7 @@ check_function_exists(strsignal HAVE_STRSIGNAL)
check_function_exists(sprintf HAVE_SNPRINTF)
check_function_exists(strcmp HAVE_STRCMP)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if (WIN32)
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
@@ -88,6 +90,11 @@ if (WIN32)
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
endif (WIN32)
+find_library(RT_LIBRARY rt)
+if (RT_LIBRARY)
+ set(CMAKE_REQUIRED_LIBRARIES ${RT_LIBRARY})
+endif (RT_LIBRARY)
+
set(CMOCKA_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "cmocka required system libraries")
# OPTIONS
@@ -107,6 +114,23 @@ int main(void) {
}" HAVE_MSVC_THREAD_LOCAL_STORAGE)
endif(WIN32)
+if (HAVE_TIME_H AND HAVE_CLOCK_GETTIME)
+ set(CMAKE_REQUIRED_LIBRARIES ${RT_LIBRARY})
+
+ message(STATUS "CMAKE_REQUIRED_INCLUDES=${CMAKE_REQUIRED_INCLUDES} CMAKE_REQUIRED_LIBRARIES=${CMAKE_REQUIRED_LIBRARIES}")
+ check_c_source_compiles("
+#include <time.h>
+
+int main(void) {
+ struct timespec ts;
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+
+ return 0;
+}" HAVE_CLOCK_GETTIME_REALTIME)
+ set(CMAKE_REQUIRED_INCLUDES)
+endif (HAVE_TIME_H AND HAVE_CLOCK_GETTIME)
+
# ENDIAN
if (NOT WIN32)
set(WORDS_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})