From dfef43bf9ba78d6d198aefe08488a230fb98e28e Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 9 Jul 2019 22:53:04 +0200 Subject: [PATCH] CMake: Support bypassing auto-detection of syscall SYS_getrandom --- expat/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index e864786e..65592cf9 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -61,6 +61,8 @@ endif() if (NOT WIN32) set(USE_GETRANDOM "AUTO" CACHE STRING "Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]") + set(USE_SYS_GETRANDOM "AUTO" CACHE STRING + "Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]") endif() option(XML_UNICODE "Use UTF-16 encoded chars (two bytes) instead of UTF-8" OFF) option(XML_UNICODE_WCHAR_T "Use wchar_t to represent UTF-16 instead of unsigned short" OFF) @@ -115,6 +117,15 @@ if(NOT WIN32) message("Function getrandom was found but it will not be used due to USE_GETRANDOM=OFF.") set(HAVE_GETRANDOM 0) endif() + + + if(USE_SYS_GETRANDOM AND NOT (USE_SYS_GETRANDOM STREQUAL "AUTO") AND NOT HAVE_SYSCALL_GETRANDOM) + message(SEND_ERROR + "Use of syscall SYS_getrandom was enforced by USE_SYS_GETRANDOM=ON but it could not be found.") + elseif(NOT USE_SYS_GETRANDOM AND HAVE_SYSCALL_GETRANDOM) + message("Syscall SYS_getrandom was found but it will not be used due to USE_SYS_GETRANDOM=OFF.") + set(HAVE_SYSCALL_GETRANDOM 0) + endif() endif()