Last active
January 6, 2025 18:58
-
-
Save likema/f5c04dad837d2f5068ae7a8860c180e7 to your computer and use it in GitHub Desktop.
CMake macro to detect glibc version by filename.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - 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) |
This will fail if the base file is libc.so.6
... which it often is.
This will fail if the base file is
libc.so.6
... which it often is.
What do you mean?
What do you mean?
I mean, that the filename doesn't include the glibc version - and this module assumes that it does and tries to parse the name to get the version.
Any suggestions ?
Well, one thing which often works - not sure whether it always works - is run libc.so.6
. Yes, it's typically executable - and prints version information.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check glibc version if it is composed of
0
, ...,9
and.