|
1 | | -# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | | -# |
| 1 | + |
| 2 | +# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. |
| 3 | +# |
3 | 4 | # This program is free software; you can redistribute it and/or modify |
4 | | -# it under the terms of the GNU General Public License as published by |
5 | | -# the Free Software Foundation; version 2 of the License. |
6 | | -# |
| 5 | +# it under the terms of the GNU General Public License, version 2.0, |
| 6 | +# as published by the Free Software Foundation. |
| 7 | +# |
7 | 8 | # This program is distributed in the hope that it will be useful, |
8 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | | -# GNU General Public License for more details. |
11 | | -# |
| 11 | +# GNU General Public License, version 2.0, for more details. |
| 12 | +# |
12 | 13 | # You should have received a copy of the GNU General Public License |
13 | 14 | # along with this program; if not, write to the Free Software |
14 | | -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | + |
| 17 | +cmake_minimum_required(VERSION 2.4.4) |
| 18 | +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 19 | + |
| 20 | +project(zlib C) |
| 21 | + |
| 22 | +set(VERSION "1.2.11") |
| 23 | + |
| 24 | +include(CheckTypeSize) |
| 25 | +include(CheckFunctionExists) |
| 26 | +include(CheckIncludeFile) |
| 27 | +include(CheckCSourceCompiles) |
| 28 | + |
| 29 | +check_include_file(sys/types.h HAVE_SYS_TYPES_H) |
| 30 | +check_include_file(stdint.h HAVE_STDINT_H) |
| 31 | +check_include_file(stddef.h HAVE_STDDEF_H) |
| 32 | + |
| 33 | +# |
| 34 | +# Check to see if we have large file support |
| 35 | +# |
| 36 | +set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) |
| 37 | +# We add these other definitions here because CheckTypeSize.cmake |
| 38 | +# in CMake 2.4.x does not automatically do so and we want |
| 39 | +# compatibility with CMake 2.4.x. |
| 40 | +if(HAVE_SYS_TYPES_H) |
| 41 | + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) |
| 42 | +endif() |
| 43 | +if(HAVE_STDINT_H) |
| 44 | + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) |
| 45 | +endif() |
| 46 | +if(HAVE_STDDEF_H) |
| 47 | + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) |
| 48 | +endif() |
| 49 | +check_type_size(off64_t OFF64_T) |
| 50 | +if(HAVE_OFF64_T) |
| 51 | + add_definitions(-D_LARGEFILE64_SOURCE=1) |
| 52 | +endif() |
| 53 | +set(CMAKE_REQUIRED_DEFINITIONS) # clear variable |
| 54 | + |
| 55 | +# |
| 56 | +# Check for fseeko |
| 57 | +# |
| 58 | +check_function_exists(fseeko HAVE_FSEEKO) |
| 59 | +if(NOT HAVE_FSEEKO) |
| 60 | + add_definitions(-DNO_FSEEKO) |
| 61 | +endif() |
| 62 | + |
| 63 | +# |
| 64 | +# Check for unistd.h |
| 65 | +# |
| 66 | +check_include_file(unistd.h Z_HAVE_UNISTD_H) |
15 | 67 |
|
16 | | -INCLUDE_DIRECTORIES( |
17 | | -${CMAKE_SOURCE_DIR}/include |
18 | | -${CMAKE_SOURCE_DIR}/zlib |
| 68 | + |
| 69 | +configure_file( |
| 70 | + ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein |
| 71 | + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY |
| 72 | + ) |
| 73 | +include_directories( |
| 74 | + SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} |
| 75 | + ) |
| 76 | + |
| 77 | +#============================================================================ |
| 78 | +# zlib |
| 79 | +#============================================================================ |
| 80 | + |
| 81 | +set(ZLIB_PUBLIC_HDRS |
| 82 | + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h |
| 83 | + zlib.h |
| 84 | +) |
| 85 | +set(ZLIB_PRIVATE_HDRS |
| 86 | + crc32.h |
| 87 | + deflate.h |
| 88 | + gzguts.h |
| 89 | + inffast.h |
| 90 | + inffixed.h |
| 91 | + inflate.h |
| 92 | + inftrees.h |
| 93 | + trees.h |
| 94 | + zutil.h |
19 | 95 | ) |
20 | | -SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h |
21 | | - inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h |
22 | | - zutil.c zutil.h) |
23 | | -ADD_CONVENIENCE_LIBRARY(zlib ${ZLIB_SOURCES}) |
24 | | -RESTRICT_SYMBOL_EXPORTS(zlib) |
| 96 | +set(ZLIB_SRCS |
| 97 | + adler32.c |
| 98 | + compress.c |
| 99 | + crc32.c |
| 100 | + deflate.c |
| 101 | + gzclose.c |
| 102 | + gzlib.c |
| 103 | + gzread.c |
| 104 | + gzwrite.c |
| 105 | + inflate.c |
| 106 | + infback.c |
| 107 | + inftrees.c |
| 108 | + inffast.c |
| 109 | + trees.c |
| 110 | + uncompr.c |
| 111 | + zutil.c |
| 112 | +) |
| 113 | + |
| 114 | +if(NOT MINGW) |
| 115 | + set(ZLIB_DLL_SRCS |
| 116 | + win32/zlib1.rc # If present will override custom build rule below. |
| 117 | + ) |
| 118 | +endif() |
| 119 | + |
| 120 | +# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
| 121 | +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) |
| 122 | +string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
| 123 | + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) |
| 124 | + |
| 125 | +ADD_CONVENIENCE_LIBRARY(zlib STATIC |
| 126 | + ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
25 | 127 |
|
26 | | -IF(MSVC) |
27 | | - INSTALL_DEBUG_TARGET(zlib DESTINATION ${INSTALL_LIBDIR}/debug) |
28 | | -ENDIF() |
| 128 | +if(NOT CYGWIN) |
| 129 | + # This property causes shared libraries on Linux to have the full version |
| 130 | + # encoded into their final filename. We disable this on Cygwin because |
| 131 | + # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll |
| 132 | + # seems to be the default. |
| 133 | + # |
| 134 | + # This has no effect with MSVC, on that platform the version info for |
| 135 | + # the DLL comes from the resource file win32/zlib1.rc |
| 136 | + set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) |
| 137 | +endif() |
29 | 138 |
|
| 139 | +if(CMAKE_SYSTEM_NAME MATCHES "SunOS") |
| 140 | + # On unix-like platforms the library is almost always called libz |
| 141 | + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) |
| 142 | +elseif(UNIX) |
| 143 | + # On unix-like platforms the library is almost always called libz |
| 144 | + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) |
| 145 | + if(NOT APPLE) |
| 146 | + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") |
| 147 | + endif() |
| 148 | +endif() |
0 commit comments