forked from Beldex-Coin/beldex-storage-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (105 loc) · 4.24 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
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
foreach(lang C CXX)
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache")
message(STATUS "Enabling ccache for ${lang}")
set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
endif()
endforeach()
endif()
cmake_minimum_required(VERSION 3.10)
project(storage_server
VERSION 2.2.1
LANGUAGES CXX C)
option(INTEGRATION_TEST "build for integration test" OFF)
option(DISABLE_MNODE_SIGNATURE "Generate and verify signatures for inter-mnode communication"
OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
cmake_policy(SET CMP0069 NEW) # Do LTO properly
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
option(USE_LTO "Use Link-Time Optimization" ON)
if(USE_LTO AND NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_ENABLED OUTPUT ipo_error)
if(IPO_ENABLED)
message(STATUS "LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(WARNING "LTO not supported by compiler: ${ipo_error}")
endif()
else()
message(STATUS "LTO disabled")
set(IPO_ENABLED OFF)
endif()
if (INTEGRATION_TEST)
add_definitions(-DINTEGRATION_TEST)
endif()
if (DISABLE_MNODE_SIGNATURE)
add_definitions(-DDISABLE_MNODE_SIGNATURE)
endif()
option(BUILD_TESTS "build storage server unit tests" OFF)
find_package(Git)
option(MANUAL_SUBMODULES "Don't check for out-of-date submodules" OFF)
if(NOT GIT_FOUND)
message(WARNING "Git not found, unable to check that submodules are up-to-date")
else()
function (check_submodule relative_path)
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE localHead)
execute_process(COMMAND git rev-parse "HEAD:${relative_path}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE checkedHead)
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
if (upToDate)
message(STATUS "Submodule '${relative_path}' is up-to-date")
elseif(MANUAL_SUBMODULES)
message(WARNING "Submodule '${relative_path}' is not up-to-date")
else()
message(FATAL_ERROR "Submodule '${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DMANUAL_SUBMODULES=1")
endif()
# Extra arguments check nested submodules
foreach(submod ${ARGN})
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path}/${submod} OUTPUT_VARIABLE localHead)
execute_process(COMMAND git rev-parse "HEAD:${submod}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE checkedHead)
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
if (NOT upToDate)
if(MANUAL_SUBMODULES)
message(WARNING "Nested submodule '${relative_path}/${submod}' is not up-to-date")
else()
message(FATAL_ERROR "Nested submodule '${relative_path}/${submod}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DMANUAL_SUBMODULES=1")
endif()
endif()
endforeach()
endfunction ()
message(STATUS "Checking submodules")
check_submodule(vendors/spdlog)
check_submodule(vendors/oxen-mq cppzmq)
check_submodule(vendors/nlohmann_json)
check_submodule(vendors/uWebSockets uSockets)
check_submodule(vendors/cpr)
if(BUILD_TESTS)
check_submodule(unit_test/Catch2)
endif()
endif()
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
option(BUILD_STATIC_DEPS "Download, build and statically link against core dependencies" OFF)
if(BUILD_STATIC_DEPS)
include(StaticBuild)
else()
find_package(PkgConfig REQUIRED)
find_package(Boost REQUIRED program_options)
find_package(OpenSSL REQUIRED)
endif()
include(cmake/check_atomic.cmake)
link_libatomic()
include(cmake/check_for_std_filesystem.cmake)
add_subdirectory(common)
add_subdirectory(utils)
add_subdirectory(crypto)
add_subdirectory(storage)
add_subdirectory(httpserver)
add_subdirectory(vendors)
if (BUILD_TESTS)
add_subdirectory(unit_test)
endif ()
include(cmake/archive.cmake)