summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt59
1 files changed, 40 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81c6c40..79bd891 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,16 @@
-project(fastwriter)
+project(fastwriter C)
+set(RELEASE "0")
set(FASTWRITER_VERSION "0.0.2")
set(FASTWRITER_ABI_VERSION "0")
cmake_minimum_required(VERSION 2.8)
+set(DISABLE_AIO TRUE CACHE BOOL "Use kernel AIO writer")
set(DISABLE_XFS_REALTIME FALSE CACHE BOOL "Disable support of RealTime XFS partition")
+set(USE_CUSTOM_MEMCPY FALSE CACHE BOOL "Use custom memcpy routine instead of stanadrd")
-
+include(GNUInstallDirs)
include(CheckIncludeFiles)
check_include_files("linux/falloc.h" HAVE_LINUX_FALLOC_H)
@@ -31,7 +34,21 @@ include_directories(
add_definitions("-fPIC --std=c99 -Wall -O2 -pthread")
set(HEADERS fastwriter.h sysinfo.h default.h private.h)
-add_library(fastwriter SHARED fastwriter.c sysinfo.c default.c)
+set(SOURCES fastwriter.c sysinfo.c default.c)
+
+if (USE_CUSTOM_MEMCPY)
+ set(HEADERS ${HEADERS} memcpy.h)
+ set(SOURCES ${SOURCES} memcpy.c)
+endif (USE_CUSTOM_MEMCPY)
+
+if (NOT DISABLE_AIO)
+ check_include_files("libaio.h" HAVE_LIBAIO_H)
+ if (NOT HAVE_LIBAIO_H)
+ message(FATAL_ERROR "error: libaio.h is not found...")
+ endif (NOT HAVE_LIBAIO_H)
+endif (NOT DISABLE_AIO)
+
+add_library(fastwriter SHARED ${SOURCES})
set_target_properties(fastwriter PROPERTIES
VERSION ${FASTWRITER_VERSION}
@@ -39,6 +56,10 @@ set_target_properties(fastwriter PROPERTIES
LINK_FLAGS "-pthread"
)
+if (NOT DISABLE_AIO)
+ target_link_libraries(fastwriter aio)
+endif (NOT DISABLE_AIO)
+
set(TARNAME "fastwriter")
set(PACKAGE_VERSION ${FASTWRITER_VERSION})
set(PACKAGE_NAME "${TARNAME}")
@@ -46,34 +67,34 @@ set(PACKAGE_TARNAME "${TARNAME}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
-if(NOT DEFINED BIN_INSTALL_DIR)
- set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
-endif(NOT DEFINED BIN_INSTALL_DIR)
-
-if(NOT DEFINED LIB_INSTALL_DIR)
- set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
-endif(NOT DEFINED LIB_INSTALL_DIR)
+set(CPACK_SOURCE_GENERATOR "TBZ2")
+set(CPACK_PACKAGE_CONTACT "Suren A. Chilingaryan <csa@suren.me>")
+if (${RELEASE} GREATER 0)
+ set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}.${RELEASE}")
+else (${RELEASE} GREATER 0)
+ set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
+endif (${RELEASE} GREATER 0)
+set(CPACK_SOURCE_IGNORE_FILES "/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;config.h$;.pc$;Makefile;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
+include(CPack)
-if(NOT DEFINED INCLUDE_INSTALL_DIR)
- set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
-endif(NOT DEFINED INCLUDE_INSTALL_DIR)
+add_custom_target(dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR})
+add_custom_target(dist DEPENDS dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
-if(NOT DEFINED LOCALE_INSTALL_DIR)
- set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
-endif(NOT DEFINED LOCALE_INSTALL_DIR)
configure_file(fastwriter.pc.in ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc)
+configure_file(fastwriter.spec.in ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.spec)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
install(TARGETS fastwriter
- LIBRARY DESTINATION lib${LIB_SUFFIX}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES fastwriter.h
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc
- DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)