forked from vesoft-inc/nebula-storage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
144 lines (127 loc) · 4.84 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
# Copyright (c) 2018 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
#
# The build can be controlled by defining following variables on the
# <cmake> command line
#
# CMAKE_C_COMPILER -- Specify the compiler for C language
# CMAKE_CXX_COMPILER -- Specify the compiler for C++ language
#
# NEBULA_THIRDPARTY_ROOT -- Specify the root directory for third-party
# NEBULA_OTHER_ROOT -- Specify the root directory for user build
# -- Split with ":", exp: DIR:DIR
#
# NEBULA_COMMON_SOURCE_DIR -- Path to nebula-common source directory
# NEBULA_COMMON_BUILD_DIR -- Path to nebula-common build directory
# NEBULA_COMMON_REPO_URL -- Git URL for the nebula-common repo
# NEBULA_COMMON_REPO_TAG -- Tag/branch of the nebula-common repo
#
# ENABLE_JEMALLOC -- Link jemalloc into all executables
# ENABLE_TESTING -- Build unit test
# ENABLE_PACK_ONE -- Package to one or multi packages
#
cmake_minimum_required(VERSION 3.9.0)
project("Nebula Storage" C CXX)
option(ENABLE_PACK_ONE "Whether to package into one" ON)
option(ENABLE_MODULE_UPDATE "Automatically update module" OFF)
message(STATUS "ENABLE_PACK_ONE : ${ENABLE_PACK_ONE}")
message(STATUS "ENABLE_MODULE_UPDATE : ${ENABLE_MODULE_UPDATE}")
add_definitions(-DNEBULA_HOME=${CMAKE_SOURCE_DIR})
# Submodules
if("${NEBULA_COMMON_REPO_URL}" STREQUAL "")
SET(NEBULA_COMMON_REPO_URL "https://github.com/vesoft-inc/nebula-common.git")
endif()
if("${NEBULA_COMMON_REPO_TAG}" STREQUAL "")
SET(NEBULA_COMMON_REPO_TAG "master")
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
if(NOT NEBULA_COMMON_SOURCE_DIR)
include(FetchModule)
nebula_fetch_module(
NAME
common
URL
${NEBULA_COMMON_REPO_URL}
TAG
${NEBULA_COMMON_REPO_TAG}
UPDATE
${ENABLE_MODULE_UPDATE}
)
set(nebula_common_source_dir ${CMAKE_SOURCE_DIR}/modules/common)
set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common)
else()
message(STATUS "NEBULA_COMMON_SOURCE_DIR: " ${NEBULA_COMMON_SOURCE_DIR})
set(nebula_common_source_dir ${NEBULA_COMMON_SOURCE_DIR})
if(NOT NEBULA_COMMON_BUILD_DIR)
set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common)
else()
set(nebula_common_build_dir ${NEBULA_COMMON_BUILD_DIR})
endif()
endif()
list(APPEND CMAKE_MODULE_PATH ${nebula_common_source_dir}/cmake)
list(APPEND CMAKE_MODULE_PATH ${nebula_common_source_dir}/cmake/nebula)
include(PlatformCheck)
include(NebulaCMakeMacros)
include(GeneralCMakeOptions)
include(GeneralCMakeConfig)
include(GeneralCompilerConfig)
include(LinkerConfig)
include(CcacheConfig)
include(ThirdPartyConfig)
include(SanitizerConfig)
include(GitHooksConfig)
include(GitInfoConfig)
include(ConfigNebulaCommon)
config_nebula_common(
SOURCE_DIR ${nebula_common_source_dir}
BUILD_DIR ${nebula_common_build_dir}
)
# For simplicity, we make all ordinary libraries depend on the compile-time generated files,
# including the precompiled header, a.k.a Base.h.gch, and thrift headers.
macro(nebula_add_library name type)
add_library(${name} ${type} ${ARGN})
add_dependencies(
${name}
common_project
)
endmacro()
include_directories(AFTER ${CMAKE_SOURCE_DIR}/src)
include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/src)
include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/src/kvstore/plugins)
include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/src/kvstore/plugins/hbase)
nebula_add_subdirectory(src)
nebula_add_subdirectory(conf)
nebula_add_subdirectory(scripts)
add_custom_target(
clean-modules
COMMAND "rm" "-fr" "modules/*"
)
add_custom_target(
clean-build
COMMAND ${CMAKE_MAKE_PROGRAM} clean
COMMAND "find" "." "-name" "Testing" "|" "xargs" "rm" "-fr"
)
add_custom_target(
clean-all
COMMAND ${CMAKE_MAKE_PROGRAM} clean
COMMAND "find" "." "-name" "Testing" "|" "xargs" "rm" "-fr"
DEPENDS clean-modules
)
add_custom_target(
distclean
COMMAND "find" "." "-name" "CMakeFiles" "|" "xargs" "rm" "-fr"
COMMAND "find" "." "-name" "CMakeCache.txt" "|" "xargs" "rm" "-f"
COMMAND "find" "." "-name" "cmake_install.cmake" "|" "xargs" "rm" "-f"
COMMAND "find" "." "-name" "CTestTestfile.cmake" "|" "xargs" "rm" "-f"
COMMAND "find" "." "-name" "CPackConfig.cmake" "|" "xargs" "rm" "-f"
COMMAND "find" "." "-name" "CPackSourceConfig.cmake" "|" "xargs" "rm" "-f"
COMMAND "find" "." "-name" "Makefile" "|" "xargs" "rm" "-f"
DEPENDS clean-all
)
include(CPackage)
package(${ENABLE_PACK_ONE}
"nebula-storage"
"https://github.com/vesoft-inc/nebula-storage/releases"
${CMAKE_SOURCE_DIR}/package)