1# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License, version 2.0, 5# as published by the Free Software Foundation. 6# 7# This program is also distributed with certain software (including 8# but not limited to OpenSSL) that is licensed under separate terms, 9# as designated in a particular file or component or in included license 10# documentation. The authors of MySQL hereby grant you an additional 11# permission to link the program and your derivative works with the 12# separately licensed software that they have included with MySQL. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License, version 2.0, for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program; if not, write to the Free Software 21# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 23MACRO (MYSQL_USE_BUNDLED_ZLIB) 24 SET(BUILD_BUNDLED_ZLIB 1) 25 SET(ZLIB_LIBRARY zlib CACHE INTERNAL "Bundled zlib library") 26 SET(ZLIB_FOUND TRUE) 27 SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib") 28 ADD_SUBDIRECTORY(zlib) 29ENDMACRO() 30 31# MYSQL_CHECK_ZLIB_WITH_COMPRESS 32# 33# Provides the following configure options: 34# WITH_ZLIB_BUNDLED 35# If this is set,we use bindled zlib 36# If this is not set,search for system zlib. 37# if system zlib is not found, use bundled copy 38# ZLIB_LIBRARIES, ZLIB_INCLUDE_DIR and ZLIB_SOURCES 39# are set after this macro has run 40 41MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) 42 43 IF(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR 44 CMAKE_SYSTEM_NAME STREQUAL "AIX" OR 45 CMAKE_SYSTEM_NAME STREQUAL "Windows") 46 # Use bundled zlib on some platforms by default (system one is too 47 # old or not existent) 48 IF (NOT WITH_ZLIB) 49 SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform") 50 ENDIF() 51 ENDIF() 52 53 IF(WITH_ZLIB STREQUAL "bundled") 54 MYSQL_USE_BUNDLED_ZLIB() 55 ELSE() 56 SET(ZLIB_FIND_QUIETLY TRUE) 57 INCLUDE(FindZLIB) 58 IF(ZLIB_FOUND) 59 INCLUDE(CheckFunctionExists) 60 SET(CMAKE_REQUIRED_LIBRARIES z) 61 CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32) 62 CHECK_FUNCTION_EXISTS(compressBound HAVE_COMPRESSBOUND) 63 CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) 64 SET(CMAKE_REQUIRED_LIBRARIES) 65 IF(HAVE_CRC32 AND HAVE_COMPRESSBOUND AND HAVE_DEFLATEBOUND) 66 SET(ZLIB_LIBRARY ${ZLIB_LIBRARIES} CACHE INTERNAL "System zlib library") 67 SET(WITH_ZLIB "system" CACHE STRING 68 "Which zlib to use (possible values are 'bundled' or 'system')") 69 SET(ZLIB_SOURCES "") 70 ELSE() 71 SET(ZLIB_FOUND FALSE CACHE INTERNAL "Zlib found but not usable") 72 MESSAGE(STATUS "system zlib found but not usable") 73 ENDIF() 74 ENDIF() 75 IF(NOT ZLIB_FOUND) 76 MYSQL_USE_BUNDLED_ZLIB() 77 ENDIF() 78 ENDIF() 79 SET(HAVE_COMPRESS 1) 80ENDMACRO() 81