CMake/Utilities/cmexpat/CMakeLists.txt
Raul Tambre 019af62294 expat: Activate POSIX APIs even without compiler extensions
Compile with the preprocessor definitions necessary for the `arc4random`
family so it's available even when compiler extensions are not enabled.
Similar things are done in cmbzip2, cmcurl, cmlibarchive, cmliblizma and
cmlibuv.

This issue surfaced on a nightly bot after glibc 2.36 added arc4random
functions. cmlibarchive defines the necessary macro, but also relies on
`HAVE_ARC4RANDOM_BUF`.  cmlibarchive's check with the necessary macro
defined was skipped due to cmexpat running the same check before, but
without the macros, and it being cached.

This extends commit c7c3e39e4f (Utilities: Activate POSIX APIs even
without compiler extensions, 2022-06-02, v3.24.0-rc1~34^2) to cover our
build of expat too.

Issue: #20454
2022-11-10 16:04:38 -05:00

34 lines
893 B
CMake

# Disable warnings to avoid changing 3rd party code.
IF(CMAKE_C_COMPILER_ID MATCHES
"^(GNU|LCC|Clang|AppleClang|IBMClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
ENDIF()
# Activate POSIX APIs.
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux)$")
add_definitions(-D_DEFAULT_SOURCE -D_BSD_SOURCE)
string(APPEND CMAKE_REQUIRED_DEFINITIONS " -D_DEFAULT_SOURCE -D_BSD_SOURCE")
endif()
include(ConfigureChecks.cmake)
configure_file(expat_config.h.cmake expat_config.h @ONLY)
if(NOT WIN32)
add_definitions(-DXML_DEV_URANDOM)
endif()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib
)
add_library(cmexpat STATIC
lib/xmlparse.c
lib/xmlrole.c
lib/xmltok.c
lib/xmltok_impl.c
lib/xmltok_ns.c
)