forked from lizardfs/lizardfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
150 lines (133 loc) · 4.95 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
cmake_minimum_required(VERSION 2.8)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
project(lizardfs)
set(PACKAGE_VERSION_MAJOR 1)
set(PACKAGE_VERSION_MINOR 6)
set(PACKAGE_VERSION_MICRO 28)
set(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_MICRO}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(CMAKE_CXX_FLAGS "-std=c++0x -Wall -Wextra -pedantic -fwrapv")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
add_definitions(-D_LARGEFILE_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-D__STDC_CONSTANT_MACROS)
add_definitions(-D__STDC_FORMAT_MACROS)
# XXX(lamvak): what about OS X?
set(DEFAULT_USER "mfs" CACHE STRING "Default user to run daemons as")
set(DEFAULT_GROUP "mfs" CACHE STRING "Default group to run daemons as")
option(ENABLE_LIGHTMFS "Enable light version of LizardFS" OFF)
option(ENABLE_DEBIAN_PATHS "Enable Debian-style install paths" OFF)
option(ENABLE_UTILS "Enable building additional binaries used e.g. in tests" OFF)
option(ENABLE_TESTS "Enable building unit and functional tests" OFF)
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "DEFAULT_USER: ${DEFAULT_USER}")
message(STATUS "DEFAULT_GROUP: ${DEFAULT_GROUP}")
message(STATUS "ENABLE_LIGHTMFS: ${ENABLE_LIGHTMFS}")
message(STATUS "ENABLE_DEBIAN_PATHS: ${ENABLE_DEBIAN_PATHS}")
message(STATUS "ENABLE_UTILS: ${ENABLE_UTILS}")
message(STATUS "ENABLE_TESTS: ${ENABLE_TESTS}")
## All the environment tests (libs, includes, etc.) live here:
include(EnvTests.cmake)
if(ENABLE_DEBIAN_PATHS)
if (NOT CMAKE_INSTALL_PREFIX STREQUAL "/")
message(WARNING "Debian paths enabled, but CMAKE_INSTALL_PREFIX is different than /")
endif()
set(BIN_SUBDIR "usr/bin")
set(SBIN_SUBDIR "usr/sbin")
set(ETC_SUBDIR "etc")
set(RUN_SUBDIR "var/run/mfs")
set(DATA_SUBDIR "var/lib/mfs")
set(MAN_SUBDIR "usr/share/man")
set(CGI_SUBDIR "usr/share/mfscgi")
else()
set(BIN_SUBDIR "bin")
set(SBIN_SUBDIR "sbin")
set(ETC_SUBDIR "etc")
set(RUN_SUBDIR "var/run/mfs")
set(DATA_SUBDIR "var/lib/mfs")
set(MAN_SUBDIR "share/man")
set(CGI_SUBDIR "share/mfscgi")
endif()
set(BIN_PATH ${CMAKE_INSTALL_PREFIX}/${BIN_SUBDIR})
set(SBIN_PATH ${CMAKE_INSTALL_PREFIX}/${SBIN_SUBDIR})
set(ETC_PATH ${CMAKE_INSTALL_PREFIX}/${ETC_SUBDIR})
set(RUN_PATH ${CMAKE_INSTALL_PREFIX}/${RUN_SUBDIR})
set(DATA_PATH ${CMAKE_INSTALL_PREFIX}/${DATA_SUBDIR})
set(MAN_PATH ${CMAKE_INSTALL_PREFIX}/${MAN_SUBDIR})
set(CGI_PATH ${CMAKE_INSTALL_PREFIX}/${CGI_SUBDIR})
if(ENABLE_LIGHTMFS)
set(PROTO_BASE 65536)
set(LIGHT_MFS 1)
else()
set(PROTO_BASE 0)
set(LIGHT_MFS 0)
endif()
if(ENABLE_TESTS)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost is required by LizardFS tests")
endif()
set(BUILD_TESTS ON)
set(BUILD_UTILS ON)
endif()
set(CHARTS_CSV_CHARTID_BASE 90000)
# Create config.h file
set(DATA_PATH "${CMAKE_INSTALL_PREFIX}/${DATA_SUBDIR}")
set(ETC_PATH "${CMAKE_INSTALL_PREFIX}/${ETC_SUBDIR}")
set(RUN_PATH "${CMAKE_INSTALL_PREFIX}/${RUN_SUBDIR}")
configure_file(config.h.in config.h)
include_directories(${CMAKE_BINARY_DIR}) # Here we have generated config.h
# main.cc shared by some LizardFS applications
set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/main/main.cc)
# functions & macros
macro(collect_sources VAR_PREFIX)
file(GLOB ${VAR_PREFIX}_TESTS *_unittest.cc)
file(GLOB ${VAR_PREFIX}_SOURCES *.cc *.h)
file(GLOB ${VAR_PREFIX}_MAIN main.cc)
if(${VAR_PREFIX}_MAIN OR ${VAR_PREFIX}_TESTS)
list(REMOVE_ITEM ${VAR_PREFIX}_SOURCES ${${VAR_PREFIX}_TESTS} ${${VAR_PREFIX}_MAIN})
endif()
endmacro(collect_sources)
function(add_tests TESTED_LIBRARY)
if(NOT BUILD_TESTS OR ARGC EQUAL 1)
return()
endif()
list(REMOVE_AT ARGV 0)
set(TEST_LIBRARY_NAME ${TESTED_LIBRARY}_tests)
include_directories(${GTEST_INCLUDE_DIRS})
add_library(${TEST_LIBRARY_NAME} ${ARGV})
target_link_libraries(${TEST_LIBRARY_NAME} ${TESTED_LIBRARY})
set(TMP ${TEST_LIBRARIES})
list(APPEND TMP ${TEST_LIBRARY_NAME})
set(TEST_LIBRARIES ${TMP} CACHE INTERNAL "" FORCE)
endfunction(add_tests)
include_directories(src) # Allow paths relative to src, eg. #include common/crc.h
add_subdirectory(external)
add_subdirectory(src/common)
add_subdirectory(src/chunkserver)
add_subdirectory(src/master)
add_subdirectory(src/metadump)
add_subdirectory(src/metalogger)
add_subdirectory(src/metarestore)
add_subdirectory(src/tools)
if (FUSE_LIBRARY)
add_subdirectory(src/mount)
endif()
add_subdirectory(src/data)
add_subdirectory(src/cgi)
if(BUILD_UTILS)
add_subdirectory(utils)
endif()
if(BUILD_TESTS)
add_subdirectory(src/unittests)
add_subdirectory(tests)
endif()
add_subdirectory(doc)
include(Packages.cmake)