diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-05 14:18:57 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-06 15:24:07 +0000 |
commit | bebbb410301f388af1a85de30e6a05588c3ab4d0 (patch) | |
tree | 808033754fb5ef297f17a2115a6a810ab5d4b840 /cmake/FindWrapRt.cmake | |
parent | df2975236dcf522cf9f70097ac6fbfa467439664 (diff) |
CMake: Find librt
Change-Id: Ibc39ba7a385146cd0428b78e12a793f0ddbfae91
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'cmake/FindWrapRt.cmake')
-rw-r--r-- | cmake/FindWrapRt.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/FindWrapRt.cmake b/cmake/FindWrapRt.cmake new file mode 100644 index 0000000000..221399b259 --- /dev/null +++ b/cmake/FindWrapRt.cmake @@ -0,0 +1,27 @@ +include(CheckCXXSourceCompiles) + +find_library(LIBRT rt) + +set(_libraries "${CMAKE_REQUIRED_LIBRARIES}") +if(LIBRT_FOUND) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}") +endif() + +check_cxx_source_compiles(" +#include <unistd.h> +#include <time.h> + +int main(int argc, char *argv[]) { + timespec ts; clock_gettime(CLOCK_REALTIME, &ts); +}" HAVE_GETTIME) + +set(CMAKE_REQUIRED_LIBRARIES "${_libraries}") +unset(_libraries) + +add_library(WrapRt INTERFACE) +if (LIBRT_FOUND) + target_link_libraries(WrapRt INTERFACE "${LIBRT}") +endif() + +set(WrapRt_FOUND "${HAVE_GETTIME}") + |