project cleanup.
[rrq/fuse_xattrs.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(fuse_xattrs C)
3
4 set(FUSE_XATTRS_VERSION_MAJOR 0)
5 set(FUSE_XATTRS_VERSION_MINOR 2)
6
7 set(BINARY_SIDECAR_EXT \".xattr\")
8
9 set(MAX_METADATA_SIZE "8*1024*1024")  # 8 MiB
10 set(XATTR_NAME_MAX 255)               # chars in an extended attribute name
11 set(XATTR_SIZE_MAX 65536)             # size of an extended attribute value (64k)
12 set(XATTR_LIST_MAX 65536)             # size of extended attribute namelist (64k)
13
14 configure_file (
15         "${PROJECT_SOURCE_DIR}/fuse_xattrs_config.h.in"
16         "${PROJECT_BINARY_DIR}/fuse_xattrs_config.h"
17 )
18 include_directories(
19         "${PROJECT_BINARY_DIR}"
20 )
21
22 # Check xattr headers
23 include (CheckIncludeFile)
24 check_include_file (sys/xattr.h HAVE_SYS_XATTR_H)
25 if(NOT HAVE_SYS_XATTR_H)
26     message(FATAL_ERROR "sys/xattr.h not found")
27 endif()
28
29 include (CheckCSourceCompiles)
30 check_c_source_compiles ("
31   #include <sys/types.h>
32   #include <attr/xattr.h>
33   int main() { return 1; }
34   " HAVE_ATTR_XATTR_H)
35 if(NOT HAVE_ATTR_XATTR_H)
36     message(FATAL_ERROR "attr/xattr.h not found")
37 endif()
38
39 # set required definitions
40 add_definitions (-D_FILE_OFFSET_BITS=64)
41
42 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
43
44 option(ENABLE_CODECOVERAGE "Enable code coverage testing support" )
45 if(ENABLE_CODECOVERAGE)
46     include (CodeCoverage)
47     set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
48     setup_target_for_coverage(
49             fuse_xattrs_coverage
50             ./run_tests.sh
51             coverage
52     )
53 endif(ENABLE_CODECOVERAGE)
54
55 set(SOURCE_FILES
56         fuse_xattrs.c
57         passthrough.c
58         binary_storage.c
59         utils.c
60 )
61
62 add_executable(fuse_xattrs ${SOURCE_FILES})
63
64 target_link_libraries (
65         fuse_xattrs
66         fuse
67 )
68
69 install (TARGETS fuse_xattrs DESTINATION bin)
70
71 enable_testing()
72 configure_file(run_tests.sh run_tests.sh COPYONLY)
73 configure_file(test/tests.py test/tests.py COPYONLY)
74 add_test(NAME integration
75         COMMAND run_tests.sh)