2010-05-12 01:44:00 +08:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# CMake file for zlib. See root CMakeLists.txt
|
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
project(${ZLIB_LIBRARY} C)
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2012-02-22 23:52:23 +08:00
|
|
|
include(CheckFunctionExists)
|
|
|
|
include(CheckIncludeFile)
|
|
|
|
include(CheckCSourceCompiles)
|
2012-06-26 16:48:45 +08:00
|
|
|
include(CheckTypeSize)
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2012-02-22 23:52:23 +08:00
|
|
|
#
|
|
|
|
# Check for fseeko
|
|
|
|
#
|
|
|
|
check_function_exists(fseeko HAVE_FSEEKO)
|
|
|
|
if(NOT HAVE_FSEEKO)
|
|
|
|
add_definitions(-DNO_FSEEKO)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check for unistd.h
|
|
|
|
#
|
2017-02-10 20:28:50 +08:00
|
|
|
if(NOT MSVC)
|
|
|
|
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
|
|
|
endif()
|
2010-05-12 01:44:00 +08:00
|
|
|
|
|
|
|
if(MSVC)
|
2012-02-22 23:52:23 +08:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
2010-05-12 01:44:00 +08:00
|
|
|
endif()
|
|
|
|
|
2012-06-26 16:48:45 +08:00
|
|
|
#
|
|
|
|
# Check to see if we have large file support
|
|
|
|
#
|
|
|
|
check_type_size(off64_t OFF64_T)
|
|
|
|
if(HAVE_OFF64_T)
|
|
|
|
add_definitions(-D_LARGEFILE64_SOURCE=1)
|
|
|
|
endif()
|
|
|
|
|
2024-03-05 17:40:21 +08:00
|
|
|
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
|
|
|
|
|
|
|
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
|
2012-02-22 23:52:23 +08:00
|
|
|
|
|
|
|
set(ZLIB_PUBLIC_HDRS
|
2024-03-05 17:40:21 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
|
2012-02-22 23:52:23 +08:00
|
|
|
zlib.h
|
|
|
|
)
|
|
|
|
set(ZLIB_PRIVATE_HDRS
|
|
|
|
crc32.h
|
|
|
|
deflate.h
|
|
|
|
gzguts.h
|
|
|
|
inffast.h
|
|
|
|
inffixed.h
|
|
|
|
inflate.h
|
|
|
|
inftrees.h
|
|
|
|
trees.h
|
|
|
|
zutil.h
|
|
|
|
)
|
|
|
|
set(ZLIB_SRCS
|
|
|
|
adler32.c
|
|
|
|
compress.c
|
|
|
|
crc32.c
|
|
|
|
deflate.c
|
|
|
|
gzclose.c
|
|
|
|
gzlib.c
|
|
|
|
gzread.c
|
|
|
|
gzwrite.c
|
|
|
|
inflate.c
|
|
|
|
infback.c
|
|
|
|
inftrees.c
|
|
|
|
inffast.c
|
|
|
|
trees.c
|
|
|
|
uncompr.c
|
|
|
|
zutil.c
|
|
|
|
)
|
|
|
|
|
2020-10-28 03:00:25 +08:00
|
|
|
add_library(${ZLIB_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
2012-02-24 20:23:34 +08:00
|
|
|
set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
2012-02-22 23:52:23 +08:00
|
|
|
|
2017-10-06 00:54:13 +08:00
|
|
|
ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshift-negative-value
|
|
|
|
-Wundef # _LFS64_LARGEFILE is not defined
|
|
|
|
/wd4267 # MSVS 2015 (x64) + zlib 1.2.11
|
2018-04-20 00:54:03 +08:00
|
|
|
-Wimplicit-fallthrough
|
2022-04-05 19:29:36 +08:00
|
|
|
/wd4244 # MSVS + zlib 1.2.12: warning C4244: '=': conversion from 'ush' to 'uchf', possible loss of data
|
2017-10-06 00:54:13 +08:00
|
|
|
)
|
2012-02-23 04:22:29 +08:00
|
|
|
|
2012-02-24 20:23:34 +08:00
|
|
|
set_target_properties(${ZLIB_LIBRARY} PROPERTIES
|
2017-10-06 00:54:13 +08:00
|
|
|
OUTPUT_NAME ${ZLIB_LIBRARY}
|
|
|
|
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
|
|
|
COMPILE_PDB_NAME ${ZLIB_LIBRARY}
|
|
|
|
COMPILE_PDB_NAME_DEBUG "${ZLIB_LIBRARY}${OPENCV_DEBUG_POSTFIX}"
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
|
|
|
)
|
2010-09-22 10:01:54 +08:00
|
|
|
|
2011-05-17 17:40:06 +08:00
|
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
2012-02-24 20:23:34 +08:00
|
|
|
set_target_properties(${ZLIB_LIBRARY} PROPERTIES FOLDER "3rdparty")
|
2011-05-11 21:37:20 +08:00
|
|
|
endif()
|
2012-06-08 11:15:08 +08:00
|
|
|
|
2010-12-05 07:02:36 +08:00
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
2014-01-17 20:30:31 +08:00
|
|
|
ocv_install_target(${ZLIB_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
2010-12-05 07:02:36 +08:00
|
|
|
endif()
|
2018-02-27 02:10:21 +08:00
|
|
|
|
2022-11-16 12:05:08 +08:00
|
|
|
ocv_install_3rdparty_licenses(zlib LICENSE)
|