From f934c9fa821244ecb1058e54a3f8494d593a4684 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Tue, 30 Jul 2024 19:03:37 +1000 Subject: [PATCH] CMakeList check includes if building zlib --- CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e59bb3..5c677f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,38 @@ if(BUILD_LIBTIFF) endif() if(BUILD_ZLIB) + check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(stddef.h HAVE_STDDEF_H) + if(HAVE_SYS_TYPES_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) + endif() + if(HAVE_STDINT_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) + endif() + if(HAVE_STDDEF_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) + endif() + check_type_size(off64_t OFF64_T) + if(HAVE_OFF64_T) + add_definitions(-D_LARGEFILE64_SOURCE=1) + endif() + set(CMAKE_REQUIRED_DEFINITIONS) + + # Check for fseeko + check_function_exists(fseeko HAVE_FSEEKO) + if(NOT HAVE_FSEEKO) + add_definitions(-DNO_FSEEKO) + endif() + + # Check for unistd.h + check_include_file(unistd.h Z_HAVE_UNISTD_H) + if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + endif() set(FreeImage_ZLIB_SRCS Source/ZLib/adler32.c Source/ZLib/compress.c Source/ZLib/crc32.c Source/ZLib/deflate.c Source/ZLib/gzclose.c Source/ZLib/gzlib.c Source/ZLib/gzread.c Source/ZLib/gzwrite.c