1# ---------------------------------------------------------------------------- 2# CMake file for zlib. See root CMakeLists.txt 3# 4# ---------------------------------------------------------------------------- 5 6project(${ZLIB_LIBRARY} C) 7 8include(CheckFunctionExists) 9include(CheckIncludeFile) 10include(CheckCSourceCompiles) 11include(CheckTypeSize) 12 13# 14# Check for fseeko 15# 16check_function_exists(fseeko HAVE_FSEEKO) 17if(NOT HAVE_FSEEKO) 18 add_definitions(-DNO_FSEEKO) 19endif() 20 21# 22# Check for unistd.h 23# 24check_include_file(unistd.h Z_HAVE_UNISTD_H) 25 26if(MSVC) 27 add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 28 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 29endif() 30 31# 32# Check to see if we have large file support 33# 34check_type_size(off64_t OFF64_T) 35if(HAVE_OFF64_T) 36 add_definitions(-D_LARGEFILE64_SOURCE=1) 37endif() 38 39configure_file("${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein" 40 "${CMAKE_CURRENT_BINARY_DIR}/zconf.h" @ONLY) 41ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 42 43set(ZLIB_PUBLIC_HDRS 44 "${CMAKE_CURRENT_BINARY_DIR}/zconf.h" 45 zlib.h 46) 47set(ZLIB_PRIVATE_HDRS 48 crc32.h 49 deflate.h 50 gzguts.h 51 inffast.h 52 inffixed.h 53 inflate.h 54 inftrees.h 55 trees.h 56 zutil.h 57) 58set(ZLIB_SRCS 59 adler32.c 60 compress.c 61 crc32.c 62 deflate.c 63 gzclose.c 64 gzlib.c 65 gzread.c 66 gzwrite.c 67 inflate.c 68 infback.c 69 inftrees.c 70 inffast.c 71 trees.c 72 uncompr.c 73 zutil.c 74) 75 76add_library(${ZLIB_LIBRARY} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 77set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 78 79if(UNIX) 80 if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) 81 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") 82 endif() 83endif() 84 85ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations) 86 87set_target_properties(${ZLIB_LIBRARY} PROPERTIES 88 OUTPUT_NAME ${ZLIB_LIBRARY} 89 DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" 90 ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} 91 ) 92 93if(ENABLE_SOLUTION_FOLDERS) 94 set_target_properties(${ZLIB_LIBRARY} PROPERTIES FOLDER "3rdparty") 95endif() 96 97if(NOT BUILD_SHARED_LIBS) 98 ocv_install_target(${ZLIB_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev) 99endif() 100