From 7c763222150cdf1cb0d79c68f11421fae7b2c457 Mon Sep 17 00:00:00 2001 From: tuxuser <462620+tuxuser@users.noreply.github.com> Date: Wed, 25 May 2022 07:46:34 +0200 Subject: [PATCH] CMake: build-time test - backwards compatibility with older glibc (#1467) --- libsrc/leddevice/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 82be7df2..4da16a1d 100644 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -139,6 +139,22 @@ if (ENABLE_DEV_USB_HID) else() target_link_libraries(leddevice ${LIBUSB_1_LIBRARIES} hidapi-libusb) endif() + if(NOT WIN32) + include(CheckCSourceCompiles) + # Glibc compatibilty check + check_c_source_compiles(" + #include + #include + + int main() { + struct timespec t; + return clock_gettime(CLOCK_REALTIME, &t); + } + " GLIBC_HAS_CLOCK_GETTIME) + IF(NOT GLIBC_HAS_CLOCK_GETTIME) + target_link_libraries(leddevice rt) + endif() + endif() endif() if(ENABLE_MDNS)