From b382e5fb0f152f816e3b0cb7e2f5c0a211065798 Mon Sep 17 00:00:00 2001 From: wb2osz Date: Fri, 29 Nov 2019 16:40:27 -0500 Subject: [PATCH] Add -lrt to Linux link so it will work with CentOS 6. --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f184b3..4014cae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,8 +180,17 @@ if (C_CLANG OR C_GCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wvla -ffast-math -ftree-vectorize -D_GNU_SOURCE ${EXTRA_FLAGS}") # # - # for math.h - link_libraries("-lm") + # -lm is needed for functins in math.h + if (LINUX) + # We have another problem with CentOS 6. clock_gettime() is in librt so we need -lrt. + # The clock_* functions were moved into gnu libc for version 2.17. + # https://sourceware.org/ml/libc-announce/2012/msg00001.html + # If using gnu libc 2.17, or later, the -lrt is no longer needed but doesn't hurt. + # I'm making this conditional on LINUX because it is not needed for BSD and MacOSX. + link_libraries("-lrt -lm") + else() + link_libraries("-lm") + endif() elseif (C_MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W3 -MP ${EXTRA_FLAGS}") endif()