CMakeLists.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. project(zlib C)
  2. include(CheckTypeSize)
  3. include(CheckFunctionExists)
  4. include(CheckIncludeFile)
  5. check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  6. check_include_file(stdint.h HAVE_STDINT_H)
  7. check_include_file(stddef.h HAVE_STDDEF_H)
  8. # Check to see if we have large file support
  9. set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
  10. # We add these other definitions here because CheckTypeSize.cmake
  11. # in CMake 2.4.x does not automatically do so and we want
  12. # compatibility with CMake 2.4.x.
  13. if(HAVE_SYS_TYPES_H)
  14. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
  15. endif()
  16. if(HAVE_STDINT_H)
  17. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
  18. endif()
  19. if(HAVE_STDDEF_H)
  20. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
  21. endif()
  22. check_type_size(off64_t OFF64_T)
  23. if(HAVE_OFF64_T)
  24. add_definitions(-D_LARGEFILE64_SOURCE=1)
  25. endif()
  26. set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
  27. # Check for fseeko
  28. check_function_exists(fseeko HAVE_FSEEKO)
  29. if(NOT HAVE_FSEEKO)
  30. add_definitions(-DNO_FSEEKO)
  31. endif()
  32. # Check for unistd.h
  33. check_include_file(unistd.h HAVE_UNISTD_H)
  34. if(HAVE_UNISTD_H)
  35. add_definitions(-DHAVE_UNISTD_H)
  36. endif()
  37. if(MSVC)
  38. add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  39. add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
  40. endif()
  41. add_library(z STATIC
  42. zlib/adler32.c
  43. zlib/compress.c
  44. zlib/crc32.c
  45. zlib/crc32.h
  46. zlib/deflate.c
  47. zlib/deflate.h
  48. zlib/gzclose.c
  49. zlib/gzguts.h
  50. zlib/gzlib.c
  51. zlib/gzread.c
  52. zlib/gzwrite.c
  53. zlib/inffast.h
  54. zlib/inffixed.h
  55. zlib/inflate.c
  56. zlib/inflate.h
  57. zlib/infback.c
  58. zlib/inftrees.c
  59. zlib/inftrees.h
  60. zlib/inffast.c
  61. zlib/trees.c
  62. zlib/trees.h
  63. zlib/uncompr.c
  64. zlib/zconf.h
  65. zlib/zlib.h
  66. zlib/zutil.c
  67. zlib/zutil.h
  68. )
  69. add_library(ZLIB::ZLIB ALIAS z)
  70. target_include_directories(z
  71. PUBLIC
  72. zlib/
  73. )