I would like to create a shared c++ library with Bazel using a soname.
With cmake
I could set properties like:
set_target_properties(my-library
PROPERTIES
SOVERSION 3
VERSION 3.2.0
)
which would then generate
libmy-library.so -> libmy-library.so.3
libmy-library.so.3 -> libmy-library.so.3.2.0
libmy-library.so.3.2.0
However in bazel
documentation I cannot find anything that would allow me to do so easily. I know that I could define the soname and version directly and pass some linkopts
in the build file:
cc_binary(
name = "libmy-library.so.3.2.0",
srcs = ["my-library.cpp", "my-library.h"],
linkshared = 1,
linkopts = ["-Wl,-soname,libmy-library.so.3"],
)
which does produce libmy-library.so.3.2.0 with the correct soname, but not the .so file so it would require a whole lot of hacks around to:
- create libmy-library.so.3 symlink
- create libmy-library.so symlink
- create some import rules such that I can build binaries that link with this library.
This does not feel like the right way. What would be the right way to solve such problem?