79417640

Date: 2025-02-06 11:07:31
Score: 0.5
Natty:
Report link

I'm leaving this here as it may be helpful: as specified by asker @ScalewingedAcidicorn , this question uses a different approach: set the library as

add_library(<mylib> SHARED IMPORTED)
set_target_properties(<mylib> PROPERTIES
    IMPORTED_LOCATION <mylib.so in source tree>
    INTERFACE_INCLUDE_DIRECTORIES <mylib.h in source tree>
    IMPORTED_NO_SONAME TRUE # <------ NOTE HERE!
)

# [...]

target_link_libraries(<my_executable> <mylib>)

from the documentation (emphasis added):

this property to true for an imported shared library file that has no soname field. CMake may adjust generated link commands for some platforms to prevent the linker from using the path to the library in place of its missing soname.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ScalewingedAcidicorn
  • Low reputation (0.5):
Posted by: Alessandro Bertulli