-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
141 lines (110 loc) · 4.7 KB
/
CMakeLists.txt
File metadata and controls
141 lines (110 loc) · 4.7 KB
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
cmake_minimum_required(VERSION 3.20)
cmake_policy(VERSION 3.20...3.31)
project(Artery LANGUAGES CXX C)
enable_testing()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
##################
# Artery Options #
##################
# These are essential componets that are better to be turned on.
option(WITH_INET "Build Artery with INET framework integration" ON)
option(WITH_VEINS "Build Artery with Veins framework integration" ON)
# Various extensions, adjust them as needed.
option(WITH_SIMULTE "Build Artery with SimuLTE integration" OFF)
option(WITH_OTS "Build Artery with support for OpenTrafficSim" OFF)
option(WITH_TESTBED "Build Artery with testbed feature" OFF)
option(WITH_ENVMOD "Build Artery with environment model feature" ON)
option(WITH_STORYBOARD "Build Artery with storyboard feature" ON)
option(WITH_TRANSFUSION "Build Artery with transfusion feature" OFF)
# Miscellaneous stuff, does not affect functionality directly.
option(WITH_SCENARIOS "Build Artery with scenarios" ON)
option(VSCODE_LAUNCH_INTEGRATION "Generate VS Code configuration for debugging Artery (requires debug build)" OFF)
##############################
# Artery build configuration #
##############################
# use "RelWithDebInfo" as default build type
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "CMake build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# running simulations with opp_run requires shared libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "Cached for propagation to sub-projects with older CMake versions")
###############################
# Required packages & scripts #
###############################
find_package(OmnetPP 5.5.1 MODULE REQUIRED)
find_package(Boost 1.69 REQUIRED COMPONENTS date_time CONFIG)
include(AddOppRun)
include(AddOppTarget)
include(AddVSCode)
include(CheckGitSubmodule)
include(ArteryCodegen)
include(AddArterySubdirectory)
include(GNUInstallDirs)
# Packages below are needed by various
# optional components. They should be used
# with add_artery_subdirectory() to trigger
# checks on them only if variables (WITH*)
# are set.
find_package(Protobuf QUIET)
find_package(PkgConfig MODULE QUIET)
find_package(SEA_V2X CONFIG QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(ZEROMQ QUIET IMPORTED_TARGET libzmq)
endif()
if(SEA_V2X_FOUND)
mark_as_advanced(SEA_V2X_DIR)
endif()
add_subdirectory(extern)
##########################
# Primary Artery targets #
##########################
add_library(artery INTERFACE)
add_library(core SHARED)
add_library(Artery::Core ALIAS core)
macro(add_artery_feature name)
add_library(${name} SHARED ${ARGN})
add_library(Artery::${name} ALIAS ${name})
get_target_property(ned_folder ${name} SOURCE_DIR)
set_target_properties(${name} PROPERTIES
OUTPUT_NAME artery_${name}
OMNETPP_LIBRARY ON
NED_FOLDERS ${ned_folder})
target_link_libraries(${name} PRIVATE core)
target_link_libraries(artery INTERFACE Artery::${name})
install(TARGETS ${name} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endmacro()
##########
# Artery #
##########
add_subdirectory(src/traci)
add_subdirectory(src/artery)
add_artery_subdirectory(src/ots REQUIRES INET PkgConfig::ZEROMQ SWITCH WITH_OTS)
# scenarios directory is part of repository but omitted for Docker build context
if(WITH_SCENARIOS)
add_subdirectory(scenarios)
endif()
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)
string(TOLOWER "${config}" config_lower)
generate_run_config(TARGET artery CONFIG ${config} FILE "${PROJECT_BINARY_DIR}/run-artery.${config}.ini")
generate_run_config(TARGET artery CONFIG ${config} FILE "${PROJECT_BINARY_DIR}/run-artery.${config}.ini.install" INSTALL)
endforeach()
else()
generate_run_config(TARGET artery CONFIG ${CMAKE_BUILD_TYPE} FILE "${PROJECT_BINARY_DIR}/run-artery.ini")
generate_run_config(TARGET artery CONFIG ${CMAKE_BUILD_TYPE} FILE "${PROJECT_BINARY_DIR}/run-artery.ini.install" INSTALL)
endif()
if(VSCODE_LAUNCH_INTEGRATION)
if(is_multi_config AND "Debug" IN_LIST CMAKE_CONFIGURATION_TYPES)
message(STATUS "VS Code integration is enabled, but Debug is not included in build types")
elseif(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "VS Code integration is enabled, but build type is not Debug")
else()
generate_vscode(TARGET artery FILE ${PROJECT_SOURCE_DIR}/.vscode/launch.json)
endif()
endif()