Home | History | Annotate | Download | only in zlib
      1 # ----------------------------------------------------------------------------
      2 #  CMake file for zlib. See root CMakeLists.txt
      3 #
      4 # ----------------------------------------------------------------------------
      5 
      6 project(${ZLIB_LIBRARY} C)
      7 
      8 include(CheckFunctionExists)
      9 include(CheckIncludeFile)
     10 include(CheckCSourceCompiles)
     11 include(CheckTypeSize)
     12 
     13 #
     14 # Check for fseeko
     15 #
     16 check_function_exists(fseeko HAVE_FSEEKO)
     17 if(NOT HAVE_FSEEKO)
     18   add_definitions(-DNO_FSEEKO)
     19 endif()
     20 
     21 #
     22 # Check for unistd.h
     23 #
     24 check_include_file(unistd.h Z_HAVE_UNISTD_H)
     25 
     26 if(MSVC)
     27   add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
     28   add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
     29 endif()
     30 
     31 #
     32 # Check to see if we have large file support
     33 #
     34 check_type_size(off64_t OFF64_T)
     35 if(HAVE_OFF64_T)
     36   add_definitions(-D_LARGEFILE64_SOURCE=1)
     37 endif()
     38 
     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     zlib.h
     46 )
     47 set(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 )
     58 set(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 
     76 add_library(${ZLIB_LIBRARY} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
     77 set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
     78 
     79 if(UNIX)
     80   if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
     81      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
     82   endif()
     83 endif()
     84 
     85 ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations)
     86 
     87 set_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 
     93 if(ENABLE_SOLUTION_FOLDERS)
     94   set_target_properties(${ZLIB_LIBRARY} PROPERTIES FOLDER "3rdparty")
     95 endif()
     96 
     97 if(NOT BUILD_SHARED_LIBS)
     98   ocv_install_target(${ZLIB_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
     99 endif()
    100