-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
146 lines (95 loc) · 2.86 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
#####################
# START CMAKE SETUP #
#####################
cmake_minimum_required(VERSION 3.0)
project(libcp2p LANGUAGES C)
set(CMAKE_C_COMPILER /usr/bin/gcc)
# handle debug build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# -g indicates to include debug symbols
list(APPEND flags -std=c17 -Wall -Wextra -Werror -pedantic -g)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Analyze")
# override gcc compiler to v10 for static analysis
set(CMAKE_C_COMPILER /usr/bin/gcc-10)
list(APPEND flags -std=c17 -Wall -Wextra -Werror -pedantic -g -fanalyzer)
message(STATUS "enabling static analysis")
endif()
# handle ci build type
if(CMAKE_BUILD_TYPE STREQUAL "CI")
set(CMAKE_BUILD_TYPE "Release")
list(APPEND flags -std=c17 -Wall -Wextra -Werror -pedantic -I/home/travis/build/RTradeLtd/libcp2p/destdir/usr/include/ -I /home/travis/build/RTradeLtd/libcp2p/tinycbor -I/usr/local/lib/libtinycbor.so.0.5 -I/usr/local/lib)
# override the previous C compiler choice
set(CMAKE_C_COMPILER /usr/bin/gcc-9)
endif()
# handle no build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
list(APPEND flags -std=c17 -Wall -Wextra -Werror -pedantic)
endif()
list(APPEND flags -D_POSIX_C_SOURCE=201112L)
set(CMAKE_C_FLAGS_RELEASE "")
include_directories(${PROJECT_SOURCE_DIR}/include)
include(${PROJECT_SOURCE_DIR}/cmake/pkgs/doxygen.cmake)
###################
# END CMAKE SETUP #
###################
###########################
# START COMPILE LIBRARIES #
###########################
# multiaddr #
include(cmake/libraries/multiaddr.cmake)
# multihash #
include(cmake/libraries/multihash.cmake)
# protobuf #
include(cmake/libraries/protobuf.cmake)
# crypto #
include(cmake/libraries/crypto.cmake)
# multibase #
include(cmake/libraries/multibase.cmake)
# cid #
include(cmake/libraries/cid.cmake)
# encoding #
include(cmake/libraries/encoding.cmake)
# utils #
include(cmake/libraries/utils.cmake)
# valgrind #
include(cmake/pkgs/valgrind.cmake)
# multicodec #
include(cmake/libraries/multicodec.cmake)
# networking #
include(cmake/libraries/network.cmake)
# tinycbor #
include(cmake/libraries/tinycbor.cmake)
# peerstore #
include(cmake/libraries/peerstore.cmake)
# cli #
include(cmake/libraries/cli.cmake)
# testutils #
include(cmake/libraries/testutils.cmake)
# thirdparty #
include(cmake/thirdparty/argtable3.cmake)
include(cmake/thirdparty/logger.cmake)
include(cmake/thirdparty/thread_pool.cmake)
#########################
# END COMPILE LIBRARIES #
#########################
##############
# MISC TASKS #
##############
# build documentation
add_doxygen_doc(
BUILD_DIR
${PROJECT_SOURCE_DIR}/build
DOXY_FILE
${PROJECT_SOURCE_DIR}/docs/Doxyfile.in
TARGET_NAME
doxygen-docs
COMMENT
"HTML documentation"
)
#################
# TESTING SETUP #
#################
define_setup_valgrind()
enable_testing()