This repository has been archived by the owner on Jan 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
133 lines (108 loc) · 7.57 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
#==================================================================================================#
# #
# 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(routing)
include(../../cmake_modules/standard_setup.cmake)
#==================================================================================================#
# Set up all files as GLOBs #
#==================================================================================================#
set(RoutingSourcesDir ${PROJECT_SOURCE_DIR}/src/maidsafe/routing)
ms_glob_dir(Routing ${RoutingSourcesDir} Routing)
ms_glob_dir(RoutingMessages ${RoutingSourcesDir}/messages "Routing Messages")
ms_glob_dir(RoutingTestUtils ${RoutingSourcesDir}/tests/utils "Routing Test Utils")
#==================================================================================================#
# Define MaidSafe libraries and executables #
#==================================================================================================#
ms_add_static_library(maidsafe_routing ${RoutingAllFiles} ${RoutingMessagesAllFiles})
target_include_directories(maidsafe_routing PUBLIC ${PROJECT_SOURCE_DIR}/include PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(maidsafe_routing maidsafe_crux maidsafe_passport ${BoostCoroutineLibs} ${BoostContextLibs})
if(INCLUDE_TESTS)
ms_add_static_library(maidsafe_test_routing ${RoutingTestUtilsAllFiles})
target_include_directories(maidsafe_test_routing PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(maidsafe_test_routing maidsafe_routing maidsafe_test)
file(GLOB TestFiles ${RoutingSourcesDir}/tests/*.cc)
file(GLOB MessagesTestFiles ${RoutingSourcesDir}/messages/tests/*.cc)
file(GLOB MessagesTestFileHeaders ${RoutingSourcesDir}/messages/tests/*.h)
foreach(TestFile ${TestFiles} ${MessagesTestFiles})
get_filename_component(TestName ${TestFile} NAME_WE)
ms_add_executable(${TestName} "Tests/Routing" ${TestFile})
target_link_libraries(${TestName} maidsafe_test_routing)
list(APPEND RoutingTests ${TestName})
endforeach()
# TODO - remove these targets - only added to avoid changing installers for now.
ms_add_executable(test_routing "Tests/Routing" ${RoutingSourcesDir}/tests/utils/test_main.cc)
ms_add_executable(test_routing_api "Tests/Routing" ${RoutingSourcesDir}/tests/utils/test_main.cc)
target_include_directories(test_routing PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_include_directories(test_routing_api PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(test_routing maidsafe_routing maidsafe_test)
target_link_libraries(test_routing_api maidsafe_routing maidsafe_test)
endif()
ms_rename_outdated_built_exes()
#==================================================================================================#
# Set compiler and linker flags #
#==================================================================================================#
include(standard_flags)
#==================================================================================================#
# Tests #
#==================================================================================================#
function(ms_add_test TestTarget)
add_test(NAME ${TestTarget} COMMAND ${TestTarget})
set(AllGtests ${AllGtests} ${TestTarget} PARENT_SCOPE)
set_property(TEST ${TestTarget} PROPERTY LABELS ${CamelCaseProjectName} Behavioural ${NetworkTestLabel} ${TASK_LABEL})
endfunction()
if(INCLUDE_TESTS)
enable_testing()
foreach(RoutingTest ${RoutingTests})
ms_add_test("${RoutingTest}")
endforeach()
ms_add_default_tests()
ms_test_summary_output()
endif()
#==================================================================================================#
# Check messages.h includes all message headers #
#==================================================================================================#
# Remove messages.h and messages_fwd.h from the previously globbed list since these won't be #included by messages.h
list(REMOVE_ITEM RoutingMessagesHeaders "${RoutingSourcesDir}/messages/messages.h" "${RoutingSourcesDir}/messages/messages_fwd.h")
# Change the paths to relative ones
string(REPLACE "${PROJECT_SOURCE_DIR}/src/" "" RoutingMessagesHeaders "${RoutingMessagesHeaders}")
# Gather list of #included files from messages.h
file(STRINGS "${RoutingSourcesDir}/messages/messages.h" IncludedHeaders REGEX "#include.*")
# Check each file has a corresponding #include "[file]" statement
unset(WarningMessage)
foreach(Header ${RoutingMessagesHeaders})
list(FIND IncludedHeaders "#include \"${Header}\"" Found)
if(Found EQUAL -1)
set(WarningMessage "${WarningMessage}\n#include \"${Header}\"")
endif()
endforeach()
# Output the warning message if any were missing
if(WarningMessage)
set(WarningMessage "\n\nrouting/messages/messages.h doesn't #include all the message headers. It is missing:${WarningMessage}\n\n")
message(AUTHOR_WARNING "${WarningMessage}")
endif()