I am building a static library (say, libsdk), and I am using gRPC as a submodule that is built (using add_subdirectory).
I am able to build gRPC and my libsdk into a single static library (libsdk.a), which I am trying to use in another project.
The problem is that, while I am able to build the gRPC objects into my static library, abseil is not handled in the same way and I’m not sure how to incorporate this. The user of this library has undefined references to the abseil functions.
Currently, I have the following:
add_library(${CMAKE_PROJECT_NAME} STATIC
${__src_files}
$<TARGET_OBJECTS:gpr>
$<TARGET_OBJECTS:grpc>
$<TARGET_OBJECTS:grpc++>
$<TARGET_OBJECTS:grpc++_reflection>
$<TARGET_OBJECTS:protobuf::libprotobuf>
$<TARGET_OBJECTS:protobuf::libprotoc>
)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
absl::check
absl::flags
absl::flags_parse
absl::log
protobuf::libprotobuf
protobuf::libprotoc
grpc++
grpc
grpc++_reflection
)
I thought I would be able to add abseil to my library, as I do with gRPC and protobuf, but it seems the targets I need are not exposed in the same way as the gRPC targets are.
My question is: if my goal is to have one final libsdk.a file, which includes everything it needs (without dynamic linking), is this possible? If so, is it possible without modifying the gRPC build system (including its dependency on abseil)?
Finally, regardless of the answer above, is this considered bad practice? What would be the best way to distribute my library, such that a user of my library will have minimal work to get up and running with it?