Skip to content

Commit ea76ce7

Browse files
authored
Fix compilation warnings with ZLib (#2317)
1 parent 960d8c5 commit ea76ce7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

runtime/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ project(runtime)
22

33
cmake_minimum_required(VERSION 2.8.9)
44

5+
include(CheckIncludeFile)
6+
57
# Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
68
if(NOT LDC_EXE)
79
if(NOT LDC_EXE_FULL)
@@ -296,7 +298,7 @@ foreach(target ${LLVM_TARGETS_TO_BUILD})
296298
endforeach()
297299

298300
# Always build zlib and other C parts of the runtime in release mode, regardless
299-
# of what the user chose for LDC itself.
301+
# of what the user chose for LDC itself. Also add other C_FLAGS here.
300302
# 1) Set up CMAKE_C_FLAGS_RELEASE
301303
if("${TARGET_SYSTEM}" MATCHES "MSVC")
302304
# Omit all references to the default C runtime libs.
@@ -308,6 +310,11 @@ if("${TARGET_SYSTEM}" MATCHES "MSVC")
308310
# warning C4996: zlib uses 'deprecated' POSIX names
309311
append("/wd4131 /wd4206 /wd4996" CMAKE_C_FLAGS_RELEASE)
310312
endif()
313+
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
314+
if (HAVE_UNISTD_H)
315+
# Needed for zlib
316+
append("-DHAVE_UNISTD_H" CMAKE_C_FLAGS_RELEASE)
317+
endif()
311318
# 2) Set all other CMAKE_C_FLAGS variants to CMAKE_C_FLAGS_RELEASE
312319
set(variables
313320
CMAKE_C_FLAGS_DEBUG

0 commit comments

Comments
 (0)