CMakeLists.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #based on zlib-1.2.5/CMakeLists.txt
  2. #
  3. cmake_minimum_required(VERSION 2.6)
  4. set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
  5. project(zlib C)
  6. include(CheckTypeSize)
  7. include(CheckFunctionExists)
  8. include(CheckIncludeFile)
  9. include(CheckCSourceCompiles)
  10. CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
  11. CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
  12. CHECK_INCLUDE_FILE(stddef.h HAVE_STDDEF_H)
  13. #
  14. # Check to see if we have large file support
  15. #
  16. set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
  17. # We add these other definitions here because CheckTypeSize.cmake
  18. # in CMake 2.4.x does not automatically do so and we want
  19. # compatibility with CMake 2.4.x.
  20. if(HAVE_SYS_TYPES_H)
  21. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
  22. endif()
  23. if(HAVE_STDINT_H)
  24. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
  25. endif()
  26. if(HAVE_STDDEF_H)
  27. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
  28. endif()
  29. CHECK_TYPE_SIZE(off64_t OFF64_T)
  30. if(HAVE_OFF64_T)
  31. add_definitions(-D_LARGEFILE64_SOURCE=1)
  32. endif()
  33. set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
  34. #
  35. # Check for fseeko
  36. #
  37. CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
  38. if(NOT HAVE_FSEEKO)
  39. add_definitions(-DNO_FSEEKO)
  40. endif()
  41. #
  42. # Check for unistd.h
  43. #
  44. CHECK_INCLUDE_FILE(unistd.h Z_HAVE_UNISTD_H)
  45. include_directories(
  46. ${CMAKE_CURRENT_SOURCE_DIR}
  47. ${OPENJPEG_SOURCE_DIR}/thirdparty/include
  48. )
  49. #
  50. set(EXT_HDRS
  51. ${OPENJPEG_SOURCE_DIR}/thirdparty/include/zlib.h
  52. ${OPENJPEG_SOURCE_DIR}/thirdparty/include/zconf.h
  53. )
  54. set(HDRS
  55. crc32.h
  56. deflate.h
  57. gzguts.h
  58. inffast.h
  59. inffixed.h
  60. inflate.h
  61. inftrees.h
  62. trees.h
  63. zutil.h
  64. )
  65. set(SRCS
  66. adler32.c
  67. compress.c
  68. crc32.c
  69. deflate.c
  70. gzclose.c
  71. gzlib.c
  72. gzread.c
  73. gzwrite.c
  74. inflate.c
  75. infback.c
  76. inftrees.c
  77. inffast.c
  78. trees.c
  79. uncompr.c
  80. zutil.c
  81. )
  82. set(LIBTARGET "z")
  83. #
  84. add_library(${LIBTARGET} STATIC ${SRCS} ${EXT_HDRS} ${HDRS})
  85. #
  86. if(MSVC)
  87. set_target_properties(${LIBTARGET} PROPERTIES PREFIX "lib")
  88. endif(MSVC)
  89. set_target_properties(${LIBTARGET}
  90. PROPERTIES
  91. OUTPUT_NAME "${LIBTARGET}"
  92. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/lib
  93. )
  94. #