forked from maidsafe-archive/MaidSafe-Common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
210 lines (176 loc) · 11 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#==================================================================================================#
# #
# Copyright 2012 MaidSafe.net limited #
# #
# This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License, #
# version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which #
# licence you accepted on initial access to the Software (the "Licences"). #
# #
# By contributing code to the MaidSafe Software, or to this project generally, you agree to be #
# bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root #
# directory of this project at LICENSE, COPYING and CONTRIBUTOR respectively and also available #
# at: http://www.maidsafe.net/licenses #
# #
# Unless required by applicable law or agreed to in writing, the MaidSafe Software distributed #
# under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF #
# ANY KIND, either express or implied. #
# #
# See the Licences for the specific language governing permissions and limitations relating to #
# use of the MaidSafe Software. #
# #
#==================================================================================================#
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake_modules/standard_setup.cmake")
cmake_minimum_required(VERSION 2.8) # To suppress warning cluttering error message
set(Msg "\nThis project can currently only be build as part of the MaidSafe super-project. For")
set(Msg "${Msg} full details, see https://github.com/maidsafe/MaidSafe/wiki/Build-Instructions\n")
message(FATAL_ERROR "${Msg}")
endif()
project(common)
include(../../cmake_modules/standard_setup.cmake)
#==================================================================================================#
# Set up all files as GLOBs #
#==================================================================================================#
set(CommonSourcesDir ${PROJECT_SOURCE_DIR}/src/maidsafe/common)
ms_glob_dir(Common ${CommonSourcesDir} Common)
set(TestLibAllFiles ${CommonSourcesDir}/test.cc ${PROJECT_SOURCE_DIR}/include/maidsafe/common/test.h)
list(REMOVE_ITEM CommonAllFiles ${TestLibAllFiles})
ms_glob_dir(CommonTests ${CommonSourcesDir}/tests "Tests")
ms_glob_dir(BoostTests ${CommonSourcesDir}/tests/boost "Boost Tests")
ms_glob_dir(CommonAuthentication ${CommonSourcesDir}/authentication "Authentication")
ms_glob_dir(CommonAuthenticationDetail ${CommonSourcesDir}/authentication/detail "Authentication Detail")
ms_glob_dir(CommonAuthenticationTests ${CommonSourcesDir}/authentication/tests "Authentication Tests")
ms_glob_dir(CommonDataTypes ${CommonSourcesDir}/data_types "Data Types")
ms_glob_dir(CommonDataTypesTests ${CommonSourcesDir}/data_types/tests "Data Types Tests")
ms_glob_dir(CommonTools ${CommonSourcesDir}/tools Tools)
ms_glob_dir(CommonToolsTests ${CommonSourcesDir}/tools/tests "Tools Tests")
ms_glob_dir(CommonTcp ${CommonSourcesDir}/tcp "TCP")
ms_glob_dir(CommonTcpTests ${CommonSourcesDir}/tcp/tests "TCP Tests")
set(TestsMain ${CommonSourcesDir}/tests/tests_main.cc)
set(IpcChildProcess ${CommonSourcesDir}/tests/ipc_child_process.cc)
set(ConfigTestFile ${CommonSourcesDir}/tests/config_test.cc)
set(VlogTestFile ${CommonSourcesDir}/tests/visualiser_log_test.cc)
list(REMOVE_ITEM CommonTestsAllFiles ${IpcChildProcess} ${ConfigTestFile} ${VlogTestFile} ${CommonAuthenticationTestsAllFiles})
#==================================================================================================#
# Define MaidSafe libraries and executables #
#==================================================================================================#
# Common library
ms_add_static_library(maidsafe_common
${CommonAllFiles}
${CommonAuthenticationAllFiles}
${CommonAuthenticationDetailAllFiles}
${CommonDataStoresAllFiles}
${CommonDataTypesAllFiles}
${CommonTcpAllFiles})
add_dependencies(maidsafe_common boost_process)
target_include_directories(maidsafe_common
PUBLIC
${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/GeneratedProtoFiles
PRIVATE
${PROJECT_SOURCE_DIR}/src
)
ms_target_include_system_dirs(maidsafe_common PUBLIC ${BoostSourceDir})
if(JustThread_FOUND)
ms_target_include_system_dirs(maidsafe_common PUBLIC ${JustThread_INCLUDE_DIR})
endif()
if(MSVC12 AND CMAKE_CL_64)
message(AUTHOR_WARNING "Remove the \"/GS-\" flag from ipc.cc once https://svn.boost.org/trac/boost/ticket/9666 is resolved (probably in Boost v1.56).")
set_property(SOURCE ${CommonSourcesDir}/ipc.cc APPEND_STRING PROPERTY COMPILE_FLAGS " /GS-")
endif()
if(${CMAKE_VERSION} VERSION_LESS 3.0)
set(CerealLib)
else()
set(CerealLib cereal)
endif()
target_link_libraries(maidsafe_common
maidsafe_passport
${CerealLib}
cryptopp
protobuf_lite
sqlite
${BoostChronoLibs}
${BoostDateTimeLibs}
${BoostFilesystemLibs}
${BoostLocaleLibs}
${BoostRegexLibs}
${BoostSystemLibs}
${BoostThreadLibs}
${BoostProgramOptionsLibs}
${JustThread_LIBRARIES}
${SYS_LIB})
if(TARGET check_sanitizer_blacklist)
add_dependencies(maidsafe_common check_sanitizer_blacklist)
endif()
# Network Viewer library
ms_add_static_library(maidsafe_network_viewer
"${CommonSourcesDir}/tools/network_viewer.cc"
"${PROJECT_SOURCE_DIR}/include/maidsafe/common/tools/network_viewer.h"
"${CMAKE_BINARY_DIR}/GeneratedProtoFiles/maidsafe/common/tools/network_viewer.pb.cc"
"${CMAKE_BINARY_DIR}/GeneratedProtoFiles/maidsafe/common/tools/network_viewer.pb.h"
"${CommonSourcesDir}/tools/network_viewer.proto")
target_include_directories(maidsafe_network_viewer PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(maidsafe_network_viewer maidsafe_common)
# Signing tool
ms_add_executable(signing_tool "Tools/Common" "${CommonSourcesDir}/tools/signing_tool.cc")
target_link_libraries(signing_tool maidsafe_common maidsafe_passport)
# Qa tool
ms_add_executable(qa_tool "Tools/Common" "${CommonSourcesDir}/tools/qa_tool.cc"
"${CommonSourcesDir}/tools/tests/sqlite3_wrapper_benchmark.cc")
target_link_libraries(qa_tool maidsafe_common maidsafe_passport maidsafe_test)
# SQLite wrapper benchmark test tool
ms_add_executable(sqlite_wrapper_benchmark "Tools/Common" "${CommonSourcesDir}/tools/sqlite_wrapper_benchmark.cc"
"${CommonSourcesDir}/tools/tests/sqlite3_wrapper_benchmark.cc")
target_link_libraries(sqlite_wrapper_benchmark maidsafe_common maidsafe_passport maidsafe_test)
# Bootstrap file tool
ms_add_executable(bootstrap_file_tool "Tools/Common"
"${CommonSourcesDir}/tools/bootstrap_file_tool.cc"
"${CMAKE_BINARY_DIR}/GeneratedProtoFiles/maidsafe/common/tools/bootstrap_file_tool.pb.cc"
"${CMAKE_BINARY_DIR}/GeneratedProtoFiles/maidsafe/common/tools/bootstrap_file_tool.pb.h")
target_link_libraries(bootstrap_file_tool maidsafe_common)
# Address space tool
ms_add_executable(address_space_tool "Tools/Common" "${CommonSourcesDir}/tools/address_space_tool.cc")
target_link_libraries(address_space_tool maidsafe_common)
# Tests
if(MaidsafeTesting)
ms_add_static_library(maidsafe_test ${TestLibAllFiles})
target_compile_definitions(maidsafe_test PRIVATE MAIDSAFE_DISABLED_TEST_RETURN_CODE=${SkipReturnCodeValue})
target_link_libraries(maidsafe_test maidsafe_common gtest)
ms_add_executable(test_common "Tests/Common" ${CommonTestsAllFiles} ${CommonAuthenticationTestsAllFiles} ${CommonTcpTestsAllFiles})
target_link_libraries(test_common maidsafe_test)
ms_add_executable(ipc_child_process "Tests/Common" ${IpcChildProcess})
target_link_libraries(ipc_child_process maidsafe_common)
add_dependencies(test_common ipc_child_process)
ms_add_executable(test_common_config "Tests/Common" ${ConfigTestFile})
target_link_libraries(test_common_config maidsafe_common)
ms_add_executable(test_vlog "Tests/Common" ${VlogTestFile} ${TestLibAllFiles} ${TestsMain})
target_compile_definitions(test_vlog PRIVATE VLOG_TEST MAIDSAFE_DISABLED_TEST_RETURN_CODE=${SkipReturnCodeValue})
target_link_libraries(test_vlog maidsafe_common gtest)
endif()
ms_rename_outdated_built_exes()
#==================================================================================================#
# Set compiler and linker flags #
#==================================================================================================#
include(${CMAKE_CURRENT_SOURCE_DIR}/common_flags.cmake)
include(standard_flags)
#==================================================================================================#
# Tests #
#==================================================================================================#
if(MaidsafeTesting)
ms_add_default_tests()
ms_add_gtests(test_common)
ms_add_gtests(test_common_config)
ms_test_summary_output()
endif()
#==================================================================================================#
# Package #
#==================================================================================================#
install(TARGETS maidsafe_common maidsafe_network_viewer COMPONENT Development CONFIGURATIONS Debug Release ARCHIVE DESTINATION lib)
install(TARGETS signing_tool qa_tool bootstrap_file_tool address_space_tool COMPONENT Tools CONFIGURATIONS Debug RUNTIME DESTINATION bin/debug)
install(TARGETS signing_tool qa_tool bootstrap_file_tool address_space_tool COMPONENT Tools CONFIGURATIONS Release RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ COMPONENT Development DESTINATION include)
if(MaidsafeTesting)
install(TARGETS ipc_child_process test_common_config test_common COMPONENT Tests CONFIGURATIONS Debug RUNTIME DESTINATION bin/debug)
install(TARGETS ipc_child_process test_common_config test_common COMPONENT Tests CONFIGURATIONS Release RUNTIME DESTINATION bin)
endif()