-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
118 lines (101 loc) · 3.17 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
#------------------------------------------------------------------------------
# CMake file for Bigbang
#
# Copyright (c) 2019-2020 The Bigbang developers
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.5.1)
project(Bigbang LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_DIR})
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE vGitCommitID
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(GIT_VERSION ${vGitCommitID}:d)
else()
set(GIT_VERSION ${vGitCommitID}:r)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/src/bigbang/git_version.h.in"
"${PROJECT_BINARY_DIR}/src/bigbang/git_version.h")
if(CYGWIN)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
elseif(UNIX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
message(FATAL_ERROR "Unsupported plantform")
endif()
# build type
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -rdynamic")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()
# warnings
if(UNIX AND NOT CYGWIN)
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Werror -Wno-char-subscripts -Wno-unused-parameter -Wno-sign-compare -Wno-reorder -Wno-unused-local-typedefs -Wno-implicit-fallthrough -Wno-overloaded-virtual -Wno-strict-aliasing")
if (APPLE)
string(APPEND CMAKE_CXX_FLAGS " -fvisibility-inlines-hidden -fvisibility=hidden")
endif()
endif()
# libs & linkings
if(UNIX AND NOT APPLE)
string(APPEND CMAKE_CXX_FLAGS " -lrt")
if(NOT CYGWIN)
link_libraries(-ldl)
endif()
endif()
# packages
if(UNIX AND NOT CYGWIN)
set(Boost_USE_STATIC_LIBS ON)
set(OPENSSL_USE_STATIC_LIBS ON)
set(sodium_USE_STATIC_LIBS ON)
set(Readline_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Protobuf_USE_STATIC_LIBS ON)
endif()
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.58.0 REQUIRED COMPONENTS
program_options
filesystem
system
thread
date_time
regex
unit_test_framework
timer
chrono
log
locale
)
find_package(OpenSSL 1.0.0 REQUIRED)
find_package(sodium 1.0.18 REQUIRED)
find_package(Readline 5.0 REQUIRED)
find_package(Protobuf 3.0.0 REQUIRED)
if(OPENSSL_VERSION VERSION_EQUAL 1.1.0 OR
(OPENSSL_VERSION VERSION_GREATER 1.1.0 AND OPENSSL_VERSION VERSION_LESS 1.2.0))
add_definitions(-DUSE_SSL_110)
endif()
if(CYGWIN)
add_definitions(-DBOOST_LOG_DYN_LINK)
add_definitions(-DBOOST_CYGWIN_FS_PATH)
endif()
if(TESTNET)
add_definitions(-DBIGBANG_TESTNET)
endif()
# sub directories
add_subdirectory(src)
add_subdirectory(test)