riebl / artery

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

Add IMPORTED_NO_SONAME in Omnet++ setup #342

Closed AshFungor closed 1 month ago

AshFungor commented 1 month ago

Hey,

According to cmake documentation on imported targets, setting this property may help compiler (linker specifically) to avoid using relative paths when generating linking command. Ref: https://cmake.org/cmake/help/latest/command/add_library.html#imported-libraries

If the referenced library file has a SONAME (or on macOS, has a LC_ID_DYLIB starting in @rpath/), the value of that field should be set in the IMPORTED_SONAME target property. If the referenced library file does not have a SONAME, but the platform supports it, then the IMPORTED_NO_SONAME target property should be set.

I had a problem with linker when cmake used relative path for shared library OmnetPP::envir, linked here https://github.com/riebl/artery/blob/master/cmake/AddOppTarget.cmake#L69

It used to adjust path to .so lib just as it does with static targets, like ../.../path/to/omnetpp/libs/liboppenvir.so. With IMPORTED_NO_SONAME set compiler command on my platform looks like this: /usr/bin/c++ -fPIC -m64 -g -m64 -shared ... ../../extern/libINET.so -loppenvir_dbg ... With path to Omnet++ libs included in rpath of compiled .so.

riebl commented 1 month ago

Thanks for the in-depth background information related to your PR. Your change looks reasonable. :-)