summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 19fa71cb1ad59926f79d73ec836b34691aeafc25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
project(fastwriter)

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(CheckIncludeFiles)
check_include_files("linux/falloc.h" HAVE_LINUX_FALLOC_H)

if (NOT DISABLE_XFS_REALTIME)
    check_include_files("xfs/xfs.h" HAVE_XFS_H)
    if (NOT HAVE_XFS_H)
	message(FATAL_ERROR "error: xfs/xfs.h is not found...")
    endif (NOT HAVE_XFS_H)
endif (NOT DISABLE_XFS_REALTIME)

include_directories(
    ${CMAKE_SOURCE_DIR}/src 
    ${CMAKE_CURRENT_BINARY_DIR}
)

add_definitions("-fPIC --std=c99 -Wall -O2 -pthread")

set(HEADERS fastwriter.h sysinfo.h default.h private.h)
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}
    SOVERSION ${FASTWRITER_ABI_VERSION}
    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}")
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)

if(NOT DEFINED INCLUDE_INSTALL_DIR)
    set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)

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(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

install(TARGETS fastwriter
    LIBRARY DESTINATION lib${LIB_SUFFIX}
)

install(FILES fastwriter.h
    DESTINATION include
)

install(FILES 
    ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc 
    DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
)