Skip to content

Commit 2617138

Browse files
committed
cmake: Work around broken sys/random.h in old macOS SDKs
Fixes #820.
1 parent de918d4 commit 2617138

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ if (NOT MSVC)
149149
check_function_exists(stat HAVE_STAT)
150150
check_include_files(stdint.h HAVE_STDINT_H)
151151
check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
152-
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
152+
if (APPLE)
153+
# In old macOS SDKs (ex: 10.15), sys/random.h fails to include header files it needs, so add them here.
154+
check_include_files("Availability.h;stddef.h;sys/random.h" HAVE_SYS_RANDOM_H)
155+
else()
156+
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
157+
endif()
153158
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
154159
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
155160
check_include_files(sys/stat.h HAVE_SYS_STAT_H)

0 commit comments

Comments
 (0)