Revert #7257 (#7337)
authorGereon Kremer <nafur42@gmail.com>
Mon, 11 Oct 2021 17:48:09 +0000 (10:48 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 17:48:09 +0000 (17:48 +0000)
This PR reverts #7257 and restores compatibility with ancient glibc versions.

cmake/ConfigureCvc5.cmake
src/CMakeLists.txt

index 2b8e5cedc6d252c5d26473a39a1219166607534d..009e9969bafeaae8593f3778ab15470fb747aaad 100644 (file)
@@ -68,6 +68,11 @@ if(CVC5_WINDOWS_BUILD)
   endif()
 else()
   check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
+  if(NOT HAVE_CLOCK_GETTIME)
+    unset(HAVE_CLOCK_GETTIME CACHE)
+    check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
+    find_library(RT_LIBRARIES NAMES rt)
+  endif()
 endif()
 check_symbol_exists(ffs "strings.h" HAVE_FFS)
 check_symbol_exists(optreset "getopt.h" HAVE_DECL_OPTRESET)
index 4c418d9284fe73e48a1c9ea673f7d95f52f86970..583ce8bc5d53e9e5caae53ff0cce6af45a2b3efc 100644 (file)
@@ -1349,6 +1349,14 @@ if(ENABLE_STATIC_LIBRARY)
   target_link_libraries(cvc5-static PUBLIC GMP_STATIC)
 endif()
 
+# Add rt library
+# Note: For glibc < 2.17 we have to additionally link against rt (man clock_gettime).
+#       RT_LIBRARIES should be empty for glibc >= 2.17
+target_link_libraries(cvc5-shared PRIVATE ${RT_LIBRARIES})
+if(ENABLE_STATIC_LIBRARY)
+  target_link_libraries(cvc5-static PRIVATE ${RT_LIBRARIES})
+endif()
+
 if(ENABLE_VALGRIND)
   target_include_directories(cvc5-obj PUBLIC ${Valgrind_INCLUDE_DIR})
 endif()