CMake: Only add -lrt link dependency if glibc is detected.

This commit is contained in:
Nicholas J. Kain 2015-02-12 13:05:30 -05:00
parent 6f6aad211e
commit 8e4ea0be72

View File

@ -110,17 +110,16 @@ try_run(GLIBC_DETECTION GLIBC_COMPILE
RUN_OUTPUT_VARIABLE GLIBC_VERSION) RUN_OUTPUT_VARIABLE GLIBC_VERSION)
if (GLIBC_VERSION AND GLIBC_COMPILE) if (GLIBC_VERSION AND GLIBC_COMPILE)
message("glibc version detected as ${GLIBC_VERSION}") message("glibc version detected as ${GLIBC_VERSION}")
COMPARE_VERSION_STRINGS(${GLIBC_VERSION} "2.17" GLIBC_MUST_LINK_RT)
if (${GLIBC_MUST_LINK_RT} LESS 0)
message("glibc <2.17 detected; linking against librt.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lrt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
endif()
else() else()
message("Could not detect glibc version.") message("Could not detect glibc version.")
endif() endif()
COMPARE_VERSION_STRINGS(${GLIBC_VERSION} "2.17" GLIBC_MUST_LINK_RT)
if (${GLIBC_MUST_LINK_RT} LESS 0)
message("glibc <2.17 detected; linking against librt.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lrt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
endif()
execute_process( execute_process(
COMMAND uname -m COMMAND uname -m
COMMAND tr "\n" " " COMMAND tr "\n" " "