From 99e071cf2c3c3557c2e755911f69b7372c66fe09 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Sat, 24 Aug 2019 21:24:56 +0800 Subject: [PATCH] Link with -lrt for older glibc Quoted from Linux Programmer's Manual (2017-09-15): #include int clock_gettime(clockid_t clk_id, struct timespec *tp); Link with -lrt (only for glibc versions before 2.17). This patch adds additional checks for librt availability and append target_link_libraries accordingly. librt is absent on macOS. Fixed #139 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9de861..d44b340 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,10 @@ if(WIN32) list(APPEND mi_libraries psapi shell32 user32) else() list(APPEND mi_libraries pthread) + find_library(LIBRT rt) + if(LIBRT) + list(APPEND mi_libraries ${LIBRT}) + endif() endif() # -----------------------------------------------------------------------------