CMake: Do not try to test for the glibc version when cross-compiling.
This commit is contained in:
parent
b792162113
commit
9d8d653877
@ -96,7 +96,8 @@ if (NOT (${OSNAME} STREQUAL "Linux"))
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(GLIBC_DETECT_TEST_C
|
||||
if (NOT CMAKE_CROSSCOMPILE)
|
||||
set(GLIBC_DETECT_TEST_C
|
||||
"
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -104,11 +105,11 @@ set(GLIBC_DETECT_TEST_C
|
||||
return 0;
|
||||
}
|
||||
")
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/detect/glibc.c "${GLIBC_DETECT_TEST_C}\n")
|
||||
try_run(GLIBC_DETECTION GLIBC_COMPILE
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/detect/glibc.c "${GLIBC_DETECT_TEST_C}\n")
|
||||
try_run(GLIBC_DETECTION GLIBC_COMPILE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/detect ${CMAKE_CURRENT_BINARY_DIR}/detect/glibc.c
|
||||
RUN_OUTPUT_VARIABLE GLIBC_VERSION)
|
||||
if (GLIBC_VERSION AND GLIBC_COMPILE)
|
||||
if (GLIBC_VERSION AND GLIBC_COMPILE)
|
||||
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)
|
||||
@ -116,8 +117,9 @@ if (GLIBC_VERSION AND GLIBC_COMPILE)
|
||||
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.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("$ENV{CROSSCOMPILE_MACHINENAME}" STREQUAL "")
|
||||
|
Loading…
Reference in New Issue
Block a user