"Unix Makefiles" and "Ninja" generators produce different shared library paths in elf NEEDED sections
I'm using CMake to cross-compile on a Windows machine for VxWorks using a custom toolchain file (edited starting form the toolchain files generated form Workbench, not written from scratch).
I can indifferently use "Unix Makefiles" and "Ninja" generators, the project is always building fine.
The problem is that the executables built with ninja do not run because they cannot find the shared libraries. And indeed, this is the output of readelf in the two cases:
Makefiles
readelf -d hrtf-node.vxe
Dynamic section at offset 0x6c478 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libhrtf-system.so]
0x0000000000000001 (NEEDED) Shared library: [libhrtf-logger.so]
0x0000000000000001 (NEEDED) Shared library: [libhrtf-platform.so]
0x0000000000000001 (NEEDED) Shared library: [libxerces-c.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.1]
0x0000000000000001 (NEEDED) Shared library: [libllvm.so.1]
0x0000000000000001 (NEEDED) Shared library: [libcplusplus.so.1]
0x0000000000000001 (NEEDED) Shared library: [libllvmcplus.so.1]
Ninja
readelf -d hrtf-node.vxe
Dynamic section at offset 0x110048 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [source\hrtf\system\libhrtf-system.so]
0x0000000000000001 (NEEDED) Shared library: [source\hrtf\logging\diagnostics\libhrtf-logger.so]
0x0000000000000001 (NEEDED) Shared library: [source\hrtf\platform\libhrtf-platform.so]
0x0000000000000001 (NEEDED) Shared library: [libxerces-c.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.1]
0x0000000000000001 (NEEDED) Shared library: [libllvm.so.1]
0x0000000000000001 (NEEDED) Shared library: [libcplusplus.so.1]
0x0000000000000001 (NEEDED) Shared library: [libllvmcplus.so.1]
As you can see, with ninja some library names are pre-pended with the relative path from the root of the project (where the main CMakeLists.txt is). Those libraries are part of the same project. The other ones, not prepended with any path, are either system libraries or external dependencies added using find_package and target_link_libraries (xerces)
Why this difference? Is there a workaround to have "Ninja" producing the same as "Unix Makefiles"?