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.