CMakeLists.txt 2.4 KB

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