Skip to content

Instantly share code, notes, and snippets.

@likema

likema/glibc.cmake

Last active Oct 14, 2020
Embed
What would you like to do?
CMake macro to detect glibc version by filename.
# - Check glibc version
# CHECK_GLIBC_VERSION()
#
# Once done this will define
#
# GLIBC_VERSION - glibc version
#
MACRO (CHECK_GLIBC_VERSION)
EXECUTE_PROCESS (
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.so.6
OUTPUT_VARIABLE GLIBC
OUTPUT_STRIP_TRAILING_WHITESPACE)
GET_FILENAME_COMPONENT (GLIBC ${GLIBC} REALPATH)
GET_FILENAME_COMPONENT (GLIBC_VERSION ${GLIBC} NAME)
STRING (REPLACE "libc-" "" GLIBC_VERSION ${GLIBC_VERSION})
STRING (REPLACE ".so" "" GLIBC_VERSION ${GLIBC_VERSION})
IF (NOT GLIBC_VERSION MATCHES "^[0-9.]+$")
MESSAGE (FATAL_ERROR "Unknown glibc version: ${GLIBC_VERSION}")
ENDIF (NOT GLIBC_VERSION MATCHES "^[0-9.]+$")
ENDMACRO (CHECK_GLIBC_VERSION)
@likema

This comment has been minimized.

Copy link
Owner Author

@likema likema commented Apr 25, 2019

Check glibc version if it is composed of 0, ..., 9 and .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment