1
1
cmake_minimum_required (VERSION 3.16 )
2
+
2
3
cmake_policy (VERSION 3.16...3.31 )
3
- project (Artery )
4
4
5
- set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake )
5
+ project (Artery LANGUAGES CXX C )
6
+
7
+ enable_testing ()
8
+
6
9
set (CMAKE_CXX_STANDARD 17 )
7
10
set (CMAKE_CXX_STANDARD_REQUIRED ON )
8
- enable_testing ( )
11
+ set ( CMAKE_CXX_EXTENSIONS OFF )
9
12
10
- find_package (OmnetPP 5.5.1 MODULE REQUIRED )
11
- include (AddOppRun )
12
- include (AddOppTarget )
13
- include (AddVSCode )
14
- include (CheckGitSubmodule )
15
- include (GenerateOppMessage )
16
- include (GNUInstallDirs )
13
+ list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake )
17
14
18
- find_package (Boost 1.59 REQUIRED COMPONENTS date_time system CONFIG )
15
+ ##################
16
+ # Artery Options #
17
+ ##################
18
+
19
+ # These are essential componets that are better to be turned on.
20
+ option (WITH_INET "Build Artery with INET framework integration" ON )
21
+ option (WITH_VEINS "Build Artery with Veins framework integration" ON )
22
+
23
+ # Various extensions, adjust them as needed.
24
+ option (WITH_SIMULTE "Build Artery with SimuLTE integration" OFF )
25
+ option (WITH_OTS "Build Artery with support for OpenTrafficSim" OFF )
26
+ option (WITH_TESTBED "Build Artery with testbed feature" OFF )
27
+ option (WITH_ENVMOD "Build Artery with environment model feature" ON )
28
+ option (WITH_STORYBOARD "Build Artery with storyboard feature" ON )
29
+ option (WITH_TRANSFUSION "Build Artery with transfusion feature" OFF )
30
+
31
+ # Miscellaneous stuff, does not affect functionality directly.
32
+ option (WITH_SCENARIOS "Build Artery with scenarios" ON )
33
+ option (VSCODE_LAUNCH_INTEGRATION "Generate VS Code configuration for debugging Artery (requires debug build)" OFF )
34
+
35
+ ##############################
36
+ # Artery build configuration #
37
+ ##############################
19
38
20
39
# use "RelWithDebInfo" as default build type
21
40
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
@@ -26,83 +45,76 @@ endif()
26
45
# running simulations with opp_run requires shared libraries
27
46
set (BUILD_SHARED_LIBS ON CACHE INTERNAL "Cached for propagation to sub-projects with older CMake versions" )
28
47
29
- check_git_submodule (PATH extern/vanetza REQUIRED_FILES CMakeLists.txt )
30
- set (VANETZA_INSTALL ON )
31
- add_subdirectory (${PROJECT_SOURCE_DIR} /extern/vanetza )
32
- mark_as_advanced (BUILD_BENCHMARK BUILD_CERTIFY BUILD_SOCKTAP BUILD_TESTS BUILD_USING_CONAN )
33
- mark_as_advanced (VANETZA_ASN1_WITH_ASN1C VANETZA_EXPORT_PACKAGE VANETZA_NET_WITH_POSIX )
34
-
35
- check_git_submodule (PATH extern/veins REQUIRED_FILES src/veins/package.ned )
36
- find_path (Veins_DIR NAMES src/veins/package.ned PATHS extern/veins DOC "Veins root directory" )
37
- mark_as_advanced (Veins_DIR )
38
- add_opp_target (TARGET veins ROOT_DIR ${Veins_DIR} )
39
-
40
-
41
- check_git_submodule (PATH extern/inet REQUIRED_FILES src/inet/package.ned )
42
- find_path (INET_DIR NAMES src/inet/package.ned PATHS extern/inet DOC "INET root directory" )
43
- mark_as_advanced (INET_DIR )
44
- set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${INET_DIR} /.oppfeaturestate ${INET_DIR} /.nedexclusions )
45
-
46
- # collect INET's opp_makemake options
47
- execute_process (COMMAND ./inet_featuretool options -l -f
48
- WORKING_DIRECTORY ${INET_DIR}
49
- OUTPUT_VARIABLE INET_OPP_MAKEMAKE )
50
- separate_arguments (INET_OPP_MAKEMAKE UNIX_COMMAND ${INET_OPP_MAKEMAKE} )
51
-
52
- # generate INET's features and opp_defines header
53
- set (INET_GEN_DIR ${PROJECT_BINARY_DIR} /INET_gen )
54
- file (MAKE_DIRECTORY ${INET_GEN_DIR} /inet )
55
- add_custom_command (OUTPUT ${INET_DIR} /.oppfeaturestate
56
- COMMAND ./inet_featuretool repair
57
- DEPENDS ${INET_DIR} /.oppfeatures ${INET_DIR} /inet_featuretool
58
- WORKING_DIRECTORY ${INET_DIR} )
59
- add_custom_command (OUTPUT ${INET_GEN_DIR} /inet/features.h
60
- COMMAND ./inet_featuretool defines >${INET_GEN_DIR}/inet/features.h
61
- DEPENDS ${INET_DIR} /.oppfeaturestate
62
- WORKING_DIRECTORY ${INET_DIR}
63
- COMMENT "Generate INET features.h" )
64
- add_custom_command (OUTPUT ${INET_GEN_DIR} /inet/opp_defines.h
65
- COMMAND ${CMAKE_COMMAND} -E touch ${INET_GEN_DIR} /inet/opp_defines.h
66
- COMMENT "Generate INET opp_defines.h" )
67
-
68
- add_opp_target (TARGET INET ROOT_DIR ${INET_DIR}
69
- DEPENDS ${INET_GEN_DIR} /inet/features.h ${INET_GEN_DIR} /inet/opp_defines.h
70
- OPP_MAKEMAKE ${INET_OPP_MAKEMAKE} )
71
-
72
-
73
- check_git_submodule (PATH extern/simulte REQUIRED_FILES src/package.ned )
74
- find_path (SimuLTE_DIR NAMES src/package.ned PATHS extern/simulte DOC "SimuLTE root directory" )
75
- mark_as_advanced (SimuLTE_DIR )
76
- option (WITH_SIMULTE "Build Artery with SimuLTE integration" OFF )
77
- if (WITH_SIMULTE )
78
- add_opp_target (TARGET lte ROOT_DIR ${SimuLTE_DIR} )
79
- target_link_libraries (lte PUBLIC INET )
80
- else ()
81
- message (STATUS "SimuLTE integration disabled" )
82
- endif ()
48
+ ###############################
49
+ # Required packages & scripts #
50
+ ###############################
83
51
52
+ find_package (OmnetPP 5.5.1 MODULE REQUIRED )
53
+ find_package (Boost 1.59 REQUIRED COMPONENTS date_time system CONFIG )
84
54
85
- option (WITH_ENVMOD "Build Artery with environment model feature" ON )
86
- option (WITH_STORYBOARD "Build Artery with storyboard feature" ON )
87
- option (WITH_TRANSFUSION "Build Artery with transfusion feature" OFF )
88
- option (WITH_TESTBED "Build Artery with testbed feature" OFF )
55
+ include (AddOppRun )
56
+ include (AddOppTarget )
57
+ include (AddVSCode )
58
+ include (CheckGitSubmodule )
59
+ include (GenerateOppMessage )
60
+ include (AddArterySubdirectory )
61
+ include (GNUInstallDirs )
89
62
90
- option (WITH_OTS "Build Artery with support for OpenTrafficSim" OFF )
91
- if (WITH_OTS )
92
- add_subdirectory (src/ots )
63
+ # Packages below are needed by various
64
+ # optional components. They should be used
65
+ # with add_artery_subdirectory() to trigger
66
+ # checks on them only if variables (WITH*)
67
+ # are set.
68
+
69
+ find_package (Protobuf QUIET )
70
+ find_package (PkgConfig MODULE QUIET )
71
+ find_package (SEA_V2X CONFIG QUIET )
72
+
73
+ if (PkgConfig_FOUND )
74
+ pkg_check_modules (ZEROMQ QUIET IMPORTED_TARGET libzmq )
93
75
endif ()
94
- add_subdirectory (src/traci )
95
76
77
+ if (SEA_V2X_FOUND )
78
+ mark_as_advanced (SEA_V2X_DIR )
79
+ endif ()
80
+
81
+ add_subdirectory (extern )
82
+
83
+ ##########################
84
+ # Primary Artery targets #
85
+ ##########################
86
+
87
+ # TODO: temporarily targets are moved into src/artery
88
+
89
+ macro (add_artery_feature name )
90
+ add_library (${name} SHARED ${ARGN} )
91
+ add_library (Artery::${name} ALIAS ${name} )
92
+ get_target_property (ned_folder ${name} SOURCE_DIR )
93
+ set_target_properties (${name} PROPERTIES
94
+ OUTPUT_NAME artery_${name}
95
+ OMNETPP_LIBRARY ON
96
+ NED_FOLDERS ${ned_folder} )
97
+ target_link_libraries (${name} PRIVATE core )
98
+ target_link_libraries (artery INTERFACE Artery::${name} )
99
+ install (TARGETS ${name} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
100
+ endmacro ()
101
+
102
+ ##########
103
+ # Artery #
104
+ ##########
105
+
106
+ add_subdirectory (src/traci )
96
107
add_subdirectory (src/artery )
97
108
98
- option ( VSCODE_LAUNCH_INTEGRATION "Generate VS Code configuration for debugging Artery (requires debug build)" OFF )
109
+ add_artery_subdirectory ( src/ots REQUIRES INET PkgConfig::ZEROMQ SWITCH WITH_OTS )
99
110
100
111
# scenarios directory is part of repository but omitted for Docker build context
101
- if (EXISTS ${PROJECT_SOURCE_DIR} /scenarios )
112
+ if (WITH_SCENARIOS )
102
113
add_subdirectory (scenarios )
103
114
endif ()
104
115
105
116
get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
117
+
106
118
if (is_multi_config )
107
119
foreach (config IN LISTS CMAKE_CONFIGURATION_TYPES )
108
120
string (TOLOWER "${config} " config_lower )
@@ -113,3 +125,13 @@ else()
113
125
generate_run_config (TARGET artery CONFIG ${CMAKE_BUILD_TYPE} FILE "${PROJECT_BINARY_DIR} /run-artery.ini" )
114
126
generate_run_config (TARGET artery CONFIG ${CMAKE_BUILD_TYPE} FILE "${PROJECT_BINARY_DIR} /run-artery.ini.install" INSTALL )
115
127
endif ()
128
+
129
+ if (VSCODE_LAUNCH_INTEGRATION )
130
+ if (is_multi_config AND "Debug" NOT IN CMAKE_CONFIGURATION_TYPES )
131
+ message (STATUS "VS Code integration is enabled, but Debug is not included in build types" )
132
+ elseif (NOT "${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
133
+ message (STATUS "VS Code integration is enabled, but build type is not Debug" )
134
+ else ()
135
+ generate_vscode (TARGET artery FILE ${PROJECT_SOURCE_DIR} /.vscode/launch.json )
136
+ endif ()
137
+ endif ()
0 commit comments