CMakeLists.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. project(zstd 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 to see if we have large file support
  10. set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
  11. # We add these other definitions here because CheckTypeSize.cmake
  12. # in CMake 2.4.x does not automatically do so and we want
  13. # compatibility with CMake 2.4.x.
  14. if(HAVE_SYS_TYPES_H)
  15. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
  16. endif()
  17. if(HAVE_STDINT_H)
  18. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
  19. endif()
  20. if(HAVE_STDDEF_H)
  21. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
  22. endif()
  23. check_type_size(off64_t OFF64_T)
  24. if(HAVE_OFF64_T)
  25. add_definitions(-D_LARGEFILE64_SOURCE=1)
  26. endif()
  27. set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
  28. # Check for fseeko
  29. check_function_exists(fseeko HAVE_FSEEKO)
  30. if(NOT HAVE_FSEEKO)
  31. add_definitions(-DNO_FSEEKO)
  32. endif()
  33. #
  34. # Check for unistd.h
  35. #
  36. check_include_file(unistd.h HAVE_UNISTD_H)
  37. if(HAVE_UNISTD_H)
  38. add_definitions(-DHAVE_UNISTD_H)
  39. endif()
  40. if(MSVC)
  41. add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  42. add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
  43. endif()
  44. # Always hide XXHash symbols
  45. add_definitions(-DXXH_NAMESPACE=ZSTD_)
  46. #============================================================================
  47. # zstd
  48. #============================================================================
  49. set(ZSTD_PUBLIC_HDRS
  50. lib/zstd.h
  51. )
  52. set(ZSTD_PRIVATE_HDRS
  53. lib/common/bitstream.h
  54. lib/common/compiler.h
  55. lib/common/cpu.h
  56. lib/common/debug.h
  57. lib/common/error_private.h
  58. lib/common/fse.h
  59. lib/common/huf.h
  60. lib/common/mem.h
  61. lib/common/pool.h
  62. lib/common/threading.h
  63. lib/common/xxhash.h
  64. lib/common/zstd_errors.h
  65. lib/common/zstd_internal.h
  66. lib/compress/hist.h
  67. lib/compress/zstd_compress_internal.h
  68. lib/compress/zstd_compress_literals.h
  69. lib/compress/zstd_compress_sequences.h
  70. lib/compress/zstd_cwksp.h
  71. lib/compress/zstd_double_fast.h
  72. lib/compress/zstd_fast.h
  73. lib/compress/zstd_lazy.h
  74. lib/compress/zstd_ldm.h
  75. lib/compress/zstd_opt.h
  76. lib/compress/zstdmt_compress.h
  77. lib/decompress/zstd_ddict.h
  78. lib/decompress/zstd_decompress_block.h
  79. lib/decompress/zstd_decompress_internal.h
  80. )
  81. set(ZSTD_SRCS
  82. lib/common/debug.c
  83. lib/common/entropy_common.c
  84. lib/common/error_private.c
  85. lib/common/fse_decompress.c
  86. lib/common/pool.c
  87. lib/common/threading.c
  88. lib/common/xxhash.c
  89. lib/common/zstd_common.c
  90. lib/compress/fse_compress.c
  91. lib/compress/hist.c
  92. lib/compress/huf_compress.c
  93. lib/compress/zstd_compress.c
  94. lib/compress/zstd_compress_literals.c
  95. lib/compress/zstd_compress_sequences.c
  96. lib/compress/zstd_double_fast.c
  97. lib/compress/zstd_fast.c
  98. lib/compress/zstd_lazy.c
  99. lib/compress/zstd_ldm.c
  100. lib/compress/zstd_opt.c
  101. lib/compress/zstdmt_compress.c
  102. lib/decompress/huf_decompress.c
  103. lib/decompress/zstd_ddict.c
  104. lib/decompress/zstd_decompress.c
  105. lib/decompress/zstd_decompress_block.c
  106. )
  107. add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS})
  108. dolphin_disable_warnings(zstd)
  109. add_library(zstd::zstd ALIAS zstd)
  110. target_include_directories(zstd
  111. PUBLIC
  112. ${CMAKE_CURRENT_SOURCE_DIR}/lib
  113. PRIVATE
  114. ${CMAKE_CURRENT_SOURCE_DIR}/lib/common
  115. ${CMAKE_CURRENT_SOURCE_DIR}/lib/compress
  116. ${CMAKE_CURRENT_SOURCE_DIR}/lib/decompress
  117. )