CMakeLists.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. project(fastwriter)
  2. set(FASTWRITER_VERSION "0.0.2")
  3. set(FASTWRITER_ABI_VERSION "0")
  4. cmake_minimum_required(VERSION 2.8)
  5. set(DISABLE_AIO TRUE CACHE BOOL "Use kernel AIO writer")
  6. set(DISABLE_XFS_REALTIME FALSE CACHE BOOL "Disable support of RealTime XFS partition")
  7. set(USE_CUSTOM_MEMCPY FALSE CACHE BOOL "Use custom memcpy routine instead of stanadrd")
  8. include(CheckIncludeFiles)
  9. check_include_files("linux/falloc.h" HAVE_LINUX_FALLOC_H)
  10. if (NOT DISABLE_XFS_REALTIME)
  11. check_include_files("xfs/xfs.h" HAVE_XFS_H)
  12. if (NOT HAVE_XFS_H)
  13. message(FATAL_ERROR "error: xfs/xfs.h is not found...")
  14. endif (NOT HAVE_XFS_H)
  15. endif (NOT DISABLE_XFS_REALTIME)
  16. include_directories(
  17. ${CMAKE_SOURCE_DIR}/src
  18. ${CMAKE_CURRENT_BINARY_DIR}
  19. )
  20. add_definitions("-fPIC --std=c99 -Wall -O2 -pthread")
  21. set(HEADERS fastwriter.h sysinfo.h default.h private.h)
  22. set(SOURCES fastwriter.c sysinfo.c default.c)
  23. if (USE_CUSTOM_MEMCPY)
  24. set(HEADERS ${HEADERS} memcpy.h)
  25. set(SOURCES ${SOURCES} memcpy.c)
  26. endif (USE_CUSTOM_MEMCPY)
  27. if (NOT DISABLE_AIO)
  28. check_include_files("libaio.h" HAVE_LIBAIO_H)
  29. if (NOT HAVE_LIBAIO_H)
  30. message(FATAL_ERROR "error: libaio.h is not found...")
  31. endif (NOT HAVE_LIBAIO_H)
  32. endif (NOT DISABLE_AIO)
  33. add_library(fastwriter SHARED ${SOURCES})
  34. set_target_properties(fastwriter PROPERTIES
  35. VERSION ${FASTWRITER_VERSION}
  36. SOVERSION ${FASTWRITER_ABI_VERSION}
  37. LINK_FLAGS "-pthread"
  38. )
  39. if (NOT DISABLE_AIO)
  40. target_link_libraries(fastwriter aio)
  41. endif (NOT DISABLE_AIO)
  42. set(TARNAME "fastwriter")
  43. set(PACKAGE_VERSION ${FASTWRITER_VERSION})
  44. set(PACKAGE_NAME "${TARNAME}")
  45. set(PACKAGE_TARNAME "${TARNAME}")
  46. set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
  47. set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
  48. if(NOT DEFINED BIN_INSTALL_DIR)
  49. set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
  50. endif(NOT DEFINED BIN_INSTALL_DIR)
  51. if(NOT DEFINED LIB_INSTALL_DIR)
  52. set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
  53. endif(NOT DEFINED LIB_INSTALL_DIR)
  54. if(NOT DEFINED INCLUDE_INSTALL_DIR)
  55. set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
  56. endif(NOT DEFINED INCLUDE_INSTALL_DIR)
  57. if(NOT DEFINED LOCALE_INSTALL_DIR)
  58. set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
  59. endif(NOT DEFINED LOCALE_INSTALL_DIR)
  60. configure_file(fastwriter.pc.in ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc)
  61. configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  62. install(TARGETS fastwriter
  63. LIBRARY DESTINATION lib${LIB_SUFFIX}
  64. )
  65. install(FILES fastwriter.h
  66. DESTINATION include
  67. )
  68. install(FILES
  69. ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc
  70. DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
  71. )