riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
203 stars 129 forks source link

NED files are not being picked up from new folder #239

Closed raash1d closed 2 years ago

raash1d commented 2 years ago

Hi @riebl,

I am building a project under the src/artery folder. I am unable to get the NED files getting added to the list of search paths.

Following is my folder structure

.
src
├── artery
│   ├── application
│   │   └── den
│   ├── envmod
│   │   ├── sensor
│   │   └── service
│   ├── inet
│   │   └── gemv2
                .
                .
                .
├── newapp <--------------- This is my folder
│   ├── application
├── ots
└── traci
    └── sumo
        ├── foreign
        │   └── tcpip
        ├── libsumo
        └── utils
            └── traci

Following is my src/newapp/CMakeLists.txt file which I created by looking at the one in src/artery/CMakeLists.txt:

set(SOURCES
    application/CarApp.cc
)

add_library(newapp SHARED ${SOURCES})

set_target_properties(newapp PROPERTIES
    OUTPUT_NAME artery_newapp
    OMNETPP_LIBRARY ON
    NED_FOLDERS ${CMAKE_CURRENT_SOURCE_DIR})

target_include_directories(newapp PUBLIC ${PROJECT_SOURCE_DIR}/src)

target_link_libraries(newapp PUBLIC OmnetPP::envir)
target_link_libraries(newapp PUBLIC traci)
target_link_libraries(newapp PUBLIC Vanetza::vanetza)

install(TARGETS newapp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
set_property(TARGET newapp APPEND PROPERTY INSTALL_NED_FOLDERS ${CMAKE_INSTALL_DATADIR}/ned/mps)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION share/ned/newapp FILES_MATCHING PATTERN "*.ned")

When I run simulations it looks for NED folders as follows:

Loading NED files from /usr2/ransari/src/artery/src/artery:  113
Loading NED files from /usr2/ransari/src/artery/src/traci:  21
Loading NED files from /usr2/ransari/src/artery/extern/veins/examples/veins:  1
Loading NED files from /usr2/ransari/src/artery/extern/veins/src/veins:  43
Loading NED files from /usr2/ransari/src/artery/extern/inet/src:  670
Loading NED files from /usr2/ransari/src/artery/extern/inet/examples:  175
Loading NED files from /usr2/ransari/src/artery/extern/inet/tutorials:  19
Loading NED files from /usr2/ransari/src/artery/extern/inet/showcases:  33

It compiles without errors but just does not pick up the NED files in the newapp folder. Can you please help me find what I am missing?

riebl commented 2 years ago

Artery's core library is probably not depending on your newapp yet. Thus, your simulation run does not pick up newapp's NED folder.

You can add target_link_libraries(core PUBLIC newapp) to add newapp as integral dependency. See also src/artery/CMakeLists.txt where other libraries such as traci or ots are added this way. Alternatively, you can make Artery a dependency of your newapp and modify add_opp_run(... DEPENDENCY newapp ...). See scenarios/lte-blackice/CMakeLists.txt for an example.

raash1d commented 2 years ago

It works, thank you for that guidance @riebl.

However I am getting a syntax error for my newappWorld.ned file now.

The file is as follows (it is located in ~/src/artery/src/mps/network):

package newapp.network;

import artery.veins.World;

network newappWorld extends World {
}

The newappWorld does not have anything right now. Following is the error:

Loading NED files from <home>/src/artery/src/artery:  113
Loading NED files from <home>/src/artery/src/traci:  21
Loading NED files from <home>/src/artery/src/newapp: 
<!> Error: Could not load NED sources from '<home>/src/artery/src/newapp': Syntax error, at <home>/src/artery/src/newapp/network/newappWorld.ned:1

Have you faced anything like this after including your project?

raash1d commented 2 years ago

@riebl I moved the whole folder inside the artery folder and treat newapp as a submodule now. I got the same error at this point but I found out that the network file can only be one level down from the artery package. So now it is at ~/src/artery/src/artery/newapp/newappWorld.ned. It's first line is package artery.newapp;. This works now.