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,15 +110,14 @@ 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}")
else() COMPARE_VERSION_STRINGS(${GLIBC_VERSION} "2.17" GLIBC_MUST_LINK_RT)
message("Could not detect glibc version.") if (${GLIBC_MUST_LINK_RT} LESS 0)
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.") message("glibc <2.17 detected; linking against librt.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lrt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lrt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
endif()
else()
message("Could not detect glibc version.")
endif() endif()
execute_process( execute_process(