CMakeLists.txt 2.39 KB
Newer Older
1 2 3 4 5
# ----------------------------------------------------------------------------
#  CMake file for zlib. See root CMakeLists.txt
#
# ----------------------------------------------------------------------------

6
project(${ZLIB_LIBRARY} C)
7

8 9 10
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
11
include(CheckTypeSize)
12

13 14 15 16 17 18 19 20 21 22 23 24
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
  add_definitions(-DNO_FSEEKO)
endif()

#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
25 26

if(MSVC)
27 28
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
29 30
endif()

31 32 33 34 35 36 37 38
#
# 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()

39
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein"
40
               "${CMAKE_CURRENT_BINARY_DIR}/zconf.h" @ONLY)
41
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
42 43

set(ZLIB_PUBLIC_HDRS
44
    "${CMAKE_CURRENT_BINARY_DIR}/zconf.h"
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    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
)

76 77
add_library(${ZLIB_LIBRARY} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
78

79 80 81 82 83 84
if(UNIX)
  if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
  endif()
endif()

85
ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations)
86

87 88
set_target_properties(${ZLIB_LIBRARY} PROPERTIES
        OUTPUT_NAME ${ZLIB_LIBRARY}
89
        DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
90 91
        COMPILE_PDB_NAME ${ZLIB_LIBRARY}
        COMPILE_PDB_NAME_DEBUG "${ZLIB_LIBRARY}${OPENCV_DEBUG_POSTFIX}"
92
        ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
93
    )
94

95
if(ENABLE_SOLUTION_FOLDERS)
96
  set_target_properties(${ZLIB_LIBRARY} PROPERTIES FOLDER "3rdparty")
97
endif()
Andrey Kamaev's avatar
Andrey Kamaev committed
98

99
if(NOT BUILD_SHARED_LIBS)
100
  ocv_install_target(${ZLIB_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
101
endif()