CMakeLists.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. project(bzip2 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. #============================================================================
  45. # bzip2
  46. #============================================================================
  47. set(BZIP2_PUBLIC_HDRS
  48. bzlib.h
  49. )
  50. set(BZIP2_PRIVATE_HDRS
  51. bzlib_private.h
  52. )
  53. set(BZIP2_SRCS
  54. blocksort.c
  55. huffman.c
  56. crctable.c
  57. randtable.c
  58. compress.c
  59. decompress.c
  60. bzlib.c
  61. )
  62. add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS})
  63. add_library(BZip2::BZip2 ALIAS bzip2)
  64. dolphin_disable_warnings(bzip2)
  65. target_include_directories(bzip2
  66. PUBLIC
  67. ${CMAKE_CURRENT_SOURCE_DIR}
  68. )