summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c8
-rw-r--r--CMakeLists.txt12
2 files changed, 10 insertions, 10 deletions
diff --git a/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c b/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c
new file mode 100644
index 000000000..ad460a1af
--- /dev/null
+++ b/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c
@@ -0,0 +1,8 @@
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+int main(int argc, char** argv)
+{
+ struct timespec tval;
+ return clock_gettime(CLOCK_MONOTONIC, &tval);
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83e021fc3..4a1a06b2b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,19 +209,11 @@ endif()
# (ref. bugreport:1003).
#
message( STATUS "Check for monotonic clock" )
-set( SOURCECODE
- "#include <sys/time.h>\n"
- "#include <time.h>\n"
- "#include <unistd.h>\n"
- "int main(int argc, char** argv){\n"
- " struct timespec tval;\n"
- " return clock_gettime(CLOCK_MONOTONIC, &tval);\n"
- "}\n"
- )
find_library( RT_LIBRARY rt )# (optional, rt on Debian)
mark_as_advanced( RT_LIBRARY )
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
-CHECK_C_SOURCE_RUNS( "${SOURCECODE}" HAVE_MONOTONIC_CLOCK )
+file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE )
+CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_MONOTONIC_CLOCK )
if( HAVE_MONOTONIC_CLOCK )
message( STATUS "Check for monotonic clock - yes" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )