1 cmake_minimum_required(VERSION 3.1)
4 cmake_policy(SET CMP0069 NEW)
7 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
12 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/1.2.11)
14 option(ASM686 "Enable building i686 assembly implementation")
15 option(AMD64 "Enable building amd64 assembly implementation")
17 include(CheckTypeSize)
18 include(CheckFunctionExists)
19 include(CheckIncludeFile)
20 include(CheckCSourceCompiles)
23 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
24 check_include_file(stdint.h HAVE_STDINT_H)
25 check_include_file(stddef.h HAVE_STDDEF_H)
28 # Check to see if we have large file support
30 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
31 # We add these other definitions here because CheckTypeSize.cmake
32 # in CMake 2.4.x does not automatically do so and we want
33 # compatibility with CMake 2.4.x.
35 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
38 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
41 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
43 check_type_size(off64_t OFF64_T)
45 add_definitions(-D_LARGEFILE64_SOURCE=1)
47 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
52 check_function_exists(fseeko HAVE_FSEEKO)
54 add_definitions(-DNO_FSEEKO)
60 check_include_file(unistd.h Z_HAVE_UNISTD_H)
63 set(CMAKE_DEBUG_POSTFIX "d")
64 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
65 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
66 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
69 if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
70 # If we're doing an out of source build and the user has a zconf.h
71 # in their source tree...
72 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
73 message(STATUS "Renaming")
74 message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
75 message(STATUS "to 'zconf.h.included' because this file is included with zlib")
76 message(STATUS "but CMake generates it automatically in the build directory.")
77 file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
81 #set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
82 #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
84 configure_file(${SRCDIR}/zconf.h.cmakein ${CMAKE_BINARY_DIR}/zconf.h @ONLY)
85 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
88 #============================================================================
90 #============================================================================
93 ${CMAKE_BINARY_DIR}/zconf.h
126 if(CMAKE_COMPILER_IS_GNUCC)
128 set(ZLIB_ASMS contrib/asm686/match.S)
130 set(ZLIB_ASMS contrib/amd64/amd64-match.S)
134 add_definitions(-DASMV)
135 set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
141 ENABLE_LANGUAGE(ASM_MASM)
143 contrib/masmx86/inffas32.asm
144 contrib/masmx86/match686.asm
147 ENABLE_LANGUAGE(ASM_MASM)
149 contrib/masmx64/gvmat64.asm
150 contrib/masmx64/inffasx64.asm
155 add_definitions(-DASMV -DASMINF)
159 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
162 set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
163 set(ZLIB_INCLUDE_DIR ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
164 set(ZLIB_FOUND CACHE STRING "Zlib found" FORCE )
166 set_target_properties(zlibstatic PROPERTIES FOLDER "3rd_party")