From 6b9575d07636b7bb5919d23bb298adc4b59066c0 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 25 Feb 2022 20:59:20 +0000 Subject: [PATCH] Expat: build on older GLibC versions getrandom() is only in GLibC >= 2.2.5, and CentOS 7 uses an older GCC version, so add CMake logic to fallback to /dev/urandom as the Expat entroy source. --- 3rdparty/expat/CMakeLists.txt | 16 +++++++++++++++- 3rdparty/expat/expat_config_cmake.in | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/3rdparty/expat/CMakeLists.txt b/3rdparty/expat/CMakeLists.txt index b225166d..4b232414 100644 --- a/3rdparty/expat/CMakeLists.txt +++ b/3rdparty/expat/CMakeLists.txt @@ -1,7 +1,21 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(HAVE_GETRANDOM YES) + check_cxx_source_compiles( + "#include + int main(void) { + return 0; + } + " + HAVE_GETRANDOM) + + if (NOT HAVE_GETRANDOM) + # on older (GLibC < 2.25) fall back to /dev/urandom + set(XML_DEV_URANDOM 1) + else() + message(STATUS "Found ") + endif() endif() + configure_file ( "${PROJECT_SOURCE_DIR}/3rdparty/expat/expat_config_cmake.in" "${PROJECT_BINARY_DIR}/3rdparty/expat/simgear_expat_config.h" diff --git a/3rdparty/expat/expat_config_cmake.in b/3rdparty/expat/expat_config_cmake.in index 15a76fcc..b17e2e24 100644 --- a/3rdparty/expat/expat_config_cmake.in +++ b/3rdparty/expat/expat_config_cmake.in @@ -11,6 +11,7 @@ #endif #cmakedefine HAVE_GETRANDOM +#cmakedefine XML_DEV_URANDOM // we can assume > 10.7 macOS so always set this #ifdef __APPLE__