-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
113 lines (79 loc) · 2.98 KB
/
CMakeLists.txt
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
cmake_minimum_required(VERSION 2.8.3)
project(GhostFS-plugins)
#Define cmake modules location
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
#Use ccache if available
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "Using ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
#Find dependencies
find_package(fuse REQUIRED)
find_package(CURL REQUIRED)
find_package(Ghostfs REQUIRED)
find_package(Boost REQUIRED)
find_package(Boost COMPONENTS system filesystem REQUIRED)
set(
GHOST_LIBRARIES
${FUSE_LIBRARIES}
${CURL_LIBRARIES}
${GHOST_FS_LIBRARIES}
)
#Define compilation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC --std=c++11 -Wall -pthread -D_FILE_OFFSET_BITS=64")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -fno-inline -ggdb -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG")
#Configure instalation settings
set(INSTALL_BIN_DIR /usr/bin/ghostfs_driver)
set(INSTALL_LIB_DIR /usr/lib/ghostfs_driver)
#Add source codes and generate executables
include_directories(
${FUSE_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${GHOST_FS_INCLUDE_DIRS}
)
add_definitions(-DGHOST_FS_PLUGINS_EXPORT)
set(BUILD_SHARED_LIBS TRUE)
add_library(ghostfs_plugin
drivers_init.cc
test/test_protocol.cc
ghostfs_plugins.h
test/test_protocol.h
)
install(
TARGETS ghostfs_plugin
DESTINATION "${INSTALL_BIN_DIR}"
COMPONENT application
)
#create packages
set(ALLOW_BUILD_PACKAGE ON CACHE BOOL "checkbox")
if (ALLOW_BUILD_PACKAGE)
set(PACKAGE_MAINTAINER "Péricles Lopes Machado <[email protected]>")
set(PACKAGE_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(PACKAGE_VERSION_MAJOR "1")
set(PACKAGE_VERSION_MINOR "0")
set(PACKAGE_VERSION_PATCH "0")
set(PACKAGE_SYSTEM_NAME "amd64")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${PACKAGE_MAINTAINER})
set(CPACK_PACKAGE_DESCRIPTION_FILE ${PACKAGE_DESCRIPTION_FILE})
set(CPACK_RESOURCE_FILE_LICENSE ${PACKAGE_LICENSE_FILE})
set(CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION_PATCH})
set(CPACK_SYSTEM_NAME ${PACKAGE_SYSTEM_NAME})
set(PACKAGE_TYPE "DEB") # DEB or RPM
# DEB SPECIFIC
if (PACKAGE_TYPE STREQUAL "DEB")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) # autogenerate dependency information (package d-shlibs should be installed)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "fuse (>= 2.6), attr (>= 2.0.0), curl (>= 7.0.0), boost-all (>= 1.57.0)")
endif (PACKAGE_TYPE STREQUAL "DEB")
# RPM SPECIFIC
if (PACKAGE_TYPE STREQUAL "RPM")
set(CPACK_GENERATOR "RPM")
endif (PACKAGE_TYPE STREQUAL "RPM")
include(CPack)
endif (ALLOW_BUILD_PACKAGE)