-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
154 lines (115 loc) · 3.64 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
cmake_minimum_required(VERSION 2.8.3)
project(GhostFS)
#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(Boost REQUIRED)
find_package(Boost COMPONENTS system filesystem REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
set(
GHOST_LIBRARIES
${FUSE_LIBRARIES}
${CURL_LIBRARIES}
${PYTHON_LIBRARIES}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
)
#Define compilation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --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)
set(INSTALL_LIB_DIR /usr/lib)
#Add source codes and generate executables
include_directories(
${FUSE_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
)
set(BUILD_SHARED_LIBS FALSE)
add_library(ghostfs_lib
ghost_file.cc
block_info.cc
cache.cc
ghost_fs.cc
utils.cc
protocol/base_protocol.cc
protocol/http_protocol.cc
protocol/load_drivers.cc
protocol/python_driver.cc
ghost_file.h
block_info.h
cache.h
ghost_fs.h
utils.h
protocol/base_protocol.h
protocol/http_protocol.h
protocol/load_drivers.h
protocol/python_driver.h
)
add_executable(ghostfs
main.cc
)
target_link_libraries(
ghostfs
${GHOST_LIBRARIES}
ghostfs_lib
dl
)
install(
TARGETS ghostfs
DESTINATION "${INSTALL_BIN_DIR}"
COMPONENT application
)
install(
TARGETS ghostfs_lib
DESTINATION "${INSTALL_LIB_DIR}"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/gmount
DESTINATION "${INSTALL_BIN_DIR}"
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_WRITE WORLD_EXECUTE
)
#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)")
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)