1 cmake_minimum_required(VERSION 2.4.4)
2 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
7 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/1.2.11)
9 option(ASM686 "Enable building i686 assembly implementation")
10 option(AMD64 "Enable building amd64 assembly implementation")
12 include(CheckTypeSize)
13 include(CheckFunctionExists)
14 include(CheckIncludeFile)
15 include(CheckCSourceCompiles)
18 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
19 check_include_file(stdint.h HAVE_STDINT_H)
20 check_include_file(stddef.h HAVE_STDDEF_H)
23 # Check to see if we have large file support
25 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
26 # We add these other definitions here because CheckTypeSize.cmake
27 # in CMake 2.4.x does not automatically do so and we want
28 # compatibility with CMake 2.4.x.
30 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
33 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
36 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
38 check_type_size(off64_t OFF64_T)
40 add_definitions(-D_LARGEFILE64_SOURCE=1)
42 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
47 check_function_exists(fseeko HAVE_FSEEKO)
49 add_definitions(-DNO_FSEEKO)
55 check_include_file(unistd.h Z_HAVE_UNISTD_H)
58 set(CMAKE_DEBUG_POSTFIX "d")
59 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
60 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
61 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
64 if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
65 # If we're doing an out of source build and the user has a zconf.h
66 # in their source tree...
67 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
68 message(STATUS "Renaming")
69 message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
70 message(STATUS "to 'zconf.h.included' because this file is included with zlib")
71 message(STATUS "but CMake generates it automatically in the build directory.")
72 file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
76 #set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
77 #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
79 configure_file(${SRCDIR}/zconf.h.cmakein ${CMAKE_BINARY_DIR}/zconf.h @ONLY)
80 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
83 #============================================================================
85 #============================================================================
88 ${CMAKE_BINARY_DIR}/zconf.h
121 if(CMAKE_COMPILER_IS_GNUCC)
123 set(ZLIB_ASMS contrib/asm686/match.S)
125 set(ZLIB_ASMS contrib/amd64/amd64-match.S)
129 add_definitions(-DASMV)
130 set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
136 ENABLE_LANGUAGE(ASM_MASM)
138 contrib/masmx86/inffas32.asm
139 contrib/masmx86/match686.asm
142 ENABLE_LANGUAGE(ASM_MASM)
144 contrib/masmx64/gvmat64.asm
145 contrib/masmx64/inffasx64.asm
150 add_definitions(-DASMV -DASMINF)
154 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
157 set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
158 set(ZLIB_INCLUDE_DIR ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
159 set(ZLIB_FOUND CACHE STRING "Zlib found" FORCE )
161 set_target_properties(zlibstatic PROPERTIES FOLDER "3rd_party")