Ninja generator does not create symlinks with transitive dependency through OBJECT library
When using the Ninja
generator and building a target the transitively depends on a shared library with SOVERSION
and VERSION
information the required symlinks to *.so.<major>.<minor>.<patch>
are not created under some circumstances.
Reproduction example:
$ cat a.cpp
extern "C" int ext_a() { return 23; }
$ cat b.cpp
extern "C" int ext_a();
int main() {return ext_a();}
$ cat c.cpp
//empty
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.15.0)
project(sonamerepro C CXX)
add_library(A SHARED a.cpp)
set_target_properties(A PROPERTIES SOVERSION 0 VERSION 0.0.0)
add_library(B OBJECT b.cpp)
target_link_libraries(B PUBLIC A)
add_executable(C c.cpp)
target_link_libraries(C PRIVATE B)
$ cmake --version
cmake version 3.15.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
The resulting executable C
has a NEEDED
entry which refers to libA.so.0
(see readelf -a C | grep NEEDED
).
- When target
B
is anOBJECT
library the buildninja C
will not create the necessary symlinks. - When building
ninja A
, the symlinks are created. - When changing the target type of
B
toSHARED
, the symlinks are created as expected duringninja C
.
When using the Unix Makefiles
generator, the symlinks are created in either case.