Skip to content

Commit 291bf6f

Browse files
committed
traci: adding cmake configs for traci
1 parent 0ceb50e commit 291bf6f

File tree

4 files changed

+66
-75
lines changed

4 files changed

+66
-75
lines changed

src/traci/CMakeLists.txt

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
1-
add_library(traci SHARED
2-
Defs.cc
3-
API.cc
4-
BasicModuleMapper.cc
5-
BasicNodeManager.cc
6-
BasicSubscriptionManager.cc
7-
CheckTimeSync.cc
8-
Core.cc
9-
launchers/ConnectLauncher.cc
10-
launchers/PosixLauncher.cc
11-
ExtensibleNodeManager.cc
12-
InsertionDelayVehiclePolicy.cc
13-
Listener.cc
14-
MultiTypeModuleMapper.cc
15-
RegionsOfInterest.cc
16-
RegionOfInterestVehiclePolicy.cc
17-
TestbedModuleMapper.cc
18-
TestbedNodeManager.cc
19-
ValueUtils.cc
20-
VariableCache.cc
21-
)
1+
###########
2+
# Helpers #
3+
###########
4+
5+
# Add a static library to traci component. This macro
6+
# adds static library to scope, sets include directory
7+
# and adds LIBTRACI compile definition.
8+
macro(add_traci_component name)
9+
add_library(${name} STATIC ${ARGN})
10+
target_include_directories(${name} PUBLIC ${CMAKE_SOURCE_DIR}/src)
11+
12+
if(WITH_LIBTRACI)
13+
target_compile_definitions(${name} PUBLIC LIBTRACI)
14+
endif()
15+
target_link_libraries(traci PRIVATE ${name})
16+
endmacro()
2217

23-
target_link_libraries(traci PUBLIC OmnetPP::envir)
24-
target_include_directories(traci PUBLIC ${CMAKE_SOURCE_DIR}/src)
18+
#########
19+
# TraCI #
20+
#########
2521

26-
if(WITH_LIBTRACI)
27-
target_compile_definitions(traci PUBLIC LIBTRACI)
28-
endif()
22+
add_library(traci SHARED)
23+
24+
# Common code for other components goes here.
25+
add_traci_component(traci_common
26+
Defs.cc
27+
)
2928

3029
set_target_properties(traci PROPERTIES
3130
NED_FOLDERS ${CMAKE_CURRENT_SOURCE_DIR}
3231
OMNETPP_LIBRARY ON
3332
)
3433

3534
install(TARGETS traci LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
36-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_DATADIR}/ned/traci FILES_MATCHING PATTERN "*.ned")
35+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_DATADIR}/ned/traci FILES_MATCHING PATTERN "*.ned")
3736

3837
set_property(TARGET traci APPEND PROPERTY INSTALL_NED_FOLDERS ${CMAKE_INSTALL_DATADIR}/ned/traci)
3938

40-
# traci library uses inet/common/ModuleAccess.h
41-
add_dependencies(traci INET)
39+
add_subdirectory(launchers)

src/traci/Core.h

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
1-
#ifndef CORE_H_HPQGM1MF
2-
#define CORE_H_HPQGM1MF
1+
#pragma once
2+
3+
#include <memory>
34

45
#include <omnetpp/cmessage.h>
56
#include <omnetpp/csimplemodule.h>
67
#include <omnetpp/simtime.h>
7-
#include <memory>
88

9-
namespace traci
10-
{
9+
#include <traci/API.h>
10+
#include <traci/launchers/Launcher.h>
11+
12+
namespace artery {
13+
14+
namespace traci {
1115

12-
class API;
13-
class Launcher;
14-
class LiteAPI;
15-
class SubscriptionManager;
16+
class SubscriptionManager;
1617

17-
class Core : public omnetpp::cSimpleModule
18-
{
19-
public:
20-
Core();
21-
virtual ~Core();
18+
class Core : public omnetpp::cSimpleModule
19+
{
20+
public:
21+
Core();
22+
virtual ~Core();
2223

23-
void initialize() override;
24-
void finish() override;
25-
void handleMessage(omnetpp::cMessage*) override;
26-
std::shared_ptr<API> getAPI();
24+
void initialize() override;
25+
void finish() override;
26+
void handleMessage(omnetpp::cMessage*) override;
27+
std::shared_ptr<API> getAPI();
2728

28-
protected:
29-
virtual void checkVersion();
30-
virtual void syncTime();
29+
protected:
30+
virtual void checkVersion();
31+
virtual void syncTime();
3132

32-
private:
33-
omnetpp::cMessage* m_connectEvent;
34-
omnetpp::cMessage* m_updateEvent;
35-
omnetpp::SimTime m_updateInterval;
33+
private:
34+
omnetpp::cMessage* m_connectEvent;
35+
omnetpp::cMessage* m_updateEvent;
36+
omnetpp::SimTime m_updateInterval;
3637

37-
Launcher* m_launcher;
38-
std::shared_ptr<API> m_traci;
39-
bool m_stopping;
40-
SubscriptionManager* m_subscriptions;
41-
};
38+
ILauncher* m_launcher;
39+
std::shared_ptr<API> m_traci;
40+
bool m_stopping;
41+
SubscriptionManager* m_subscriptions;
42+
};
4243

43-
} // namespace traci
44+
} // namespace traci
4445

45-
#endif /* CORE_H_HPQGM1MF */
46+
}
4647

src/traci/Position.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/traci/launchers/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_traci_component(traci_launchers
2+
ConnectLauncher.cc
3+
PosixLauncher.cc
4+
)
5+
6+

0 commit comments

Comments
 (0)