1343d3ff514a9dc9c981888274ee4e8304f847cf
[rrq/fuse_xattrs.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(fuse_xattrs C)
3
4 # Check xattr headers
5 include (CheckIncludeFile)
6 check_include_file (sys/xattr.h HAVE_SYS_XATTR_H)
7 if(NOT HAVE_SYS_XATTR_H)
8     message(FATAL_ERROR "sys/xattr.h not found")
9 endif()
10
11 include (CheckCSourceCompiles)
12 check_c_source_compiles ("
13   #include <sys/types.h>
14   #include <attr/xattr.h>
15   int main() { return 1; }
16   " HAVE_ATTR_XATTR_H)
17 if(NOT HAVE_ATTR_XATTR_H)
18     message(FATAL_ERROR "attr/xattr.h not found")
19 endif()
20
21 # set required definitions
22 add_definitions (-D_FILE_OFFSET_BITS=64)
23
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
25
26 option(ENABLE_CODECOVERAGE "Enable code coverage testing support" )
27 if(ENABLE_CODECOVERAGE)
28     include (CodeCoverage)
29     set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
30     setup_target_for_coverage(
31             fuse_xattrs_coverage
32             ./run_tests.sh
33             coverage
34     )
35 endif(ENABLE_CODECOVERAGE)
36
37 set(SOURCE_FILES
38         compat/fuse_opt.c
39         compat/fuse_opt.h
40         fuse_xattrs.c
41         passthrough.c
42         passthrough.h
43         binary_storage.c
44         binary_storage.h
45         utils.c
46         utils.h
47         const.h
48 )
49
50 add_executable(fuse_xattrs ${SOURCE_FILES})
51
52 target_link_libraries (
53         fuse_xattrs
54         fuse
55 )
56
57 install (TARGETS fuse_xattrs DESTINATION bin)
58
59 enable_testing()
60 configure_file(run_tests.sh run_tests.sh COPYONLY)
61 configure_file(test/tests.py test/tests.py COPYONLY)
62 add_test(NAME integration
63         COMMAND run_tests.sh)