-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
105 lines (86 loc) · 3.47 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
# -- project setup -------------------------------------------------------------
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(packet-routing CXX)
include(FetchContent)
# -- set useful CMake options --------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
add_compile_options(-Wall -Wextra -pedantic)
# -- fetch actor-framework repo ------------------------------------------------
FetchContent_Declare(
actor_framework
GIT_REPOSITORY https://github.com/actor-framework/actor-framework.git
GIT_TAG master
)
FetchContent_Populate(actor_framework)
foreach(varname CAF_ENABLE_EXAMPLES CAF_ENABLE_IO_MODULE CAF_ENABLE_TESTING
CAF_ENABLE_TOOLS CAF_ENABLE_OPENSSL_MODULE)
set(${varname} OFF CACHE INTERNAL "")
endforeach()
set(CAF_SANITIZERS "${SANITIZERS}" CACHE INTERNAL "")
add_subdirectory(${actor_framework_SOURCE_DIR} ${actor_framework_BINARY_DIR})
# -- project files -------------------------------------------------------------
# Find the packet-routing headers
file(GLOB_RECURSE PACKET_ROUTING_HEADERS "header/*.hpp")
# New source files have to be added here
set(
PACKET_ROUTING_SOURCES
src/actors/message_generator.cpp
src/actors/node.cpp
src/actors/topology_manager.cpp
src/actors/transition.cpp
src/benchmark/result.cpp
src/graph/transition.cpp
src/graph/undirected_graph.cpp
src/routing/ant.cpp
src/routing/message.cpp
src/routing/entry.cpp
src/routing/random.cpp
src/benchmark/benchmarker.cpp
)
set(obj_lib_target "packet_routing_obj")
set(tst_bin_target "packet_routing_test")
add_library(${obj_lib_target} OBJECT
${PACKET_ROUTING_HEADERS} ${PACKET_ROUTING_SOURCES})
set_property(TARGET ${obj_lib_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(${obj_lib_target} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/header")
caf_target_link_libraries(${obj_lib_target} CAF::core)
# -- add executables -----------------------------------------------------------
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
macro(add_target name)
add_executable(${name} "src/${name}.cpp")
target_include_directories(${name} PRIVATE "header")
target_link_libraries(${name} PRIVATE packet_routing_obj)
endmacro()
add_target(main) # This is the main project file
# -- test setup ----------------------------------------------------------------
enable_testing()
function(add_test_suites target)
foreach(suiteName ${ARGN})
string(REPLACE "." "/" suitePath ${suiteName})
target_sources(${target} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/test/${suitePath}.cpp")
add_test(NAME ${suiteName}
COMMAND ${target} -r300 -n -v5 -s${suiteName})
endforeach()
endfunction()
add_executable(${tst_bin_target}
"${CMAKE_CURRENT_SOURCE_DIR}/test/packet_routing_test.cpp"
$<TARGET_OBJECTS:${obj_lib_target}>)
target_link_libraries(${tst_bin_target} PRIVATE
packet_routing_obj CAF::test)
target_include_directories(${tst_bin_target} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/header")
add_test_suites(${tst_bin_target}
actors.message_generator
actors.node
actors.topology_manager
actors.transition
graph.undirected_graph
routing.ant
routing.entry
routing.message
routing.random)