-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
191 lines (142 loc) · 4.98 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
cmake_minimum_required (VERSION 2.8.12)
project (Residue-C++)
option (test "Builds all tests" ON)
option (build_sample_app "Builds detailed-cmake sample" OFF)
option (profiling "Turns profiling on for various scenarios" OFF)
option (travis "Whether its travis build or not" OFF)
option (BUILD_SHARED_LIBS "build shared libraries" ON)
option (special_edition "Special edition build" OFF)
set (RESIDUE_MAJOR "2")
set (RESIDUE_MINOR "1")
set (RESIDUE_PATCH "4")
set (RESIDUE_SOVERSION "${RESIDUE_MAJOR}.${RESIDUE_MINOR}.${RESIDUE_PATCH}")
set (RESIDUE_NAME "Residue-C++")
add_definitions (-DRESIDUE_SOVERSION="${RESIDUE_SOVERSION}")
add_definitions (-DRIPE_VERSION="4.1.1-static")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(residue-dev)
if (profiling)
add_definitions (-DRESIDUE_PROFILING)
endif()
if (special_edition)
add_definitions (-DRESIDUE_SPECIAL_EDITION)
endif()
add_definitions (-DASIO_STANDALONE)
include (FindPackageHandleStandardArgs)
check_apple()
list (APPEND CMAKE_CXX_FLAGS " -std=c++14 -O3 -Wall -Wno-unused-variable -Wno-unused-local-typedef -Wno-undefined-var-template -Wno-unknown-warning-option -Wno-pessimizing-move -Wno-deprecated-declarations ")
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
message ("-- libz: " ${ZLIB_LIBRARIES} " version: " ${ZLIB_VERSION_STRING})
else()
message ("--==> libz not found")
endif(ZLIB_FOUND)
include_directories(${CMAKE_SOURCE_DIR}/deps)
# Check for cryptopp (static)
set(CryptoPP_USE_STATIC_LIBS ON)
find_package(CryptoPP REQUIRED)
message ("-- Crypto++ binary: " ${CRYPTOPP_LIBRARY})
include_directories (${CRYPTOPP_INCLUDE_DIRS})
thread_packages_check()
set (THIRD_PARTY_REQUIRED_LIBS
${ZLIB_LIBRARIES}
${CRYPTOPP_LIBRARIES}
)
############# RESIDUE (STATIC) CLIENT LIB ###############
set(LIB_RESIDUE_SOURCE_FILES
deps/ripe/Ripe.cc
src/dispatcher.cc
src/network-client.cc
src/internal-logger.cc
src/residue.cc
src/easylogging++.cc
)
add_library (residue-static STATIC ${LIB_RESIDUE_SOURCE_FILES})
set_target_properties (residue-static PROPERTIES
VERSION ${RESIDUE_SOVERSION}
)
target_link_libraries (residue-static ${THIRD_PARTY_REQUIRED_LIBS})
target_compile_definitions (residue-static PUBLIC
ELPP_FORCE_USE_STD_THREAD
ELPP_THREAD_SAFE
ELPP_NO_LOG_TO_FILE
ELPP_NO_DEFAULT_LOG_FILE
ELPP_DEFAULT_LOGGING_FLAGS=4096
ELPP_FEATURE_ALL
ELPP_STL_LOGGING
ELPP_LOG_STD_ARRAY
ELPP_LOG_UNORDERED_MAP
ELPP_LOG_UNORDERED_SET
)
# Set RPATH to library install path.
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
install (TARGETS residue-static DESTINATION lib)
############## RESIDUE (SHARED) CLIENT LIB #################
if (BUILD_SHARED_LIBS)
add_library (residue-lib ${LIB_RESIDUE_SOURCE_FILES})
set_target_properties (residue-lib PROPERTIES
VERSION ${RESIDUE_SOVERSION}
)
target_link_libraries (residue-lib
residue-static
)
target_compile_definitions (residue-lib PRIVATE
ELPP_FORCE_USE_STD_THREAD
ELPP_THREAD_SAFE
ELPP_NO_LOG_TO_FILE
ELPP_NO_DEFAULT_LOG_FILE
ELPP_DEFAULT_LOGGING_FLAGS=4096
ELPP_FEATURE_ALL
ELPP_STL_LOGGING
ELPP_LOG_STD_ARRAY
ELPP_LOG_UNORDERED_MAP
ELPP_LOG_UNORDERED_SET
)
set_target_properties (residue-lib PROPERTIES OUTPUT_NAME "residue")
install (TARGETS residue-lib DESTINATION lib)
endif()
############# INCLUDES ###############
install (FILES include/residue.h DESTINATION "include/residue/")
install (FILES include/easylogging++.h DESTINATION "include/residue/")
############# SAMPLE CLIENT APP ###############
if (build_sample_app)
add_definitions (-DROOT_SAMPLE_BUILD)
add_subdirectory (samples/detailed-cmake/)
endif()
############## Cmake Package #################
# Packaging config.
set (CPACK_PACKAGE_NAME "Residue")
set (CPACK_PACKAGE_VERSION_MAJOR ${RESIDUE_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${RESIDUE_MINOR})
set (CPACK_SOURCE_GENERATOR TGZ)
set (CPACK_SOURCE_IGNORE_FILES
"/build/"
)
include (CPack)
# Compile-time configuration.
configure_file (
${CMAKE_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_BINARY_DIR}/config.h
)
include_directories (${CMAKE_BINARY_DIR})
include_directories (${CMAKE_SOURCE_DIR})
################# Test #####################
if (test)
find_package (gtest REQUIRED)
include_directories (${GTEST_INCLUDE_DIRS})
enable_testing()
add_executable (residue-cpp-unit-tests
test/main.cc
src/easylogging++.cc
)
target_compile_definitions (residue-cpp-unit-tests PUBLIC
ELPP_FEATURE_ALL
ELPP_DEFAULT_LOG_FILE="/tmp/logs/residue_cpp_unit_tests.log"
ELPP_DEFAULT_LOGGING_FLAGS=4096
)
# Standard linking to gtest stuff.
target_link_libraries (residue-cpp-unit-tests ${GTEST_LIBRARIES})
target_link_libraries (residue-cpp-unit-tests residue-lib)
add_test (NAME residueCppUnitTests COMMAND residue-cpp-unit-tests)
endif() ## test