CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. project(zlib C)
  2. include(CheckTypeSize)
  3. include(CheckFunctionExists)
  4. include(CheckIncludeFile)
  5. include(CheckCSourceCompiles)
  6. check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  7. check_include_file(stdint.h HAVE_STDINT_H)
  8. check_include_file(stddef.h HAVE_STDDEF_H)
  9. check_include_file(unistd.h Z_HAVE_UNISTD_H)
  10. # Check to see if we have large file support
  11. set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
  12. if(HAVE_SYS_TYPES_H)
  13. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
  14. endif()
  15. if(HAVE_STDINT_H)
  16. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
  17. endif()
  18. if(HAVE_STDDEF_H)
  19. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
  20. endif()
  21. check_type_size(off64_t OFF64_T)
  22. if(HAVE_OFF64_T)
  23. add_definitions(-D_LARGEFILE64_SOURCE=1)
  24. endif()
  25. set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
  26. # Check for fseeko
  27. check_function_exists(fseeko HAVE_FSEEKO)
  28. if(NOT HAVE_FSEEKO)
  29. add_definitions(-DNO_FSEEKO)
  30. endif()
  31. if(MSVC)
  32. add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  33. add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
  34. endif()
  35. #============================================================================
  36. # zlib
  37. #============================================================================
  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(z STATIC ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})