abseil-cpp
abseil-cpp copied to clipboard
How to link abseil as a static library to another static library in Cmake
I wrote a library myself, he can compile as a static library or a dynamic library, if I compile as a dynamic library, I rely on the following libraries from absl below:
target_link_libraries(${TARGET_NAME}
PUBLIC
${CMAKE_DL_LIBS}
absl::base
absl::strings
absl::status
absl::statusor
absl::flat_hash_map
${TCE_ZLIB_LIBS})
But when I want to compile it as a static library, the problem comes, after I do the static packaging as below, it will be missing the dependencies of these targets that I depend on, how can I get all the target dependencies?
set(EXTERN_OBJECTS
$<TARGET_FILE:yaml-cpp>
$<TARGET_LINKER_FILE:absl::base>
$<TARGET_LINKER_FILE:absl::strings>
$<TARGET_LINKER_FILE:absl::status>
$<TARGET_LINKER_FILE:absl::statusor>
$<TARGET_LINKER_FILE:absl::strings_internal>
)
add_custom_target(combined ALL
COMMAND ${CMAKE_AR} rcsT
${LIBRARY_NAME}
${EXTERN_OBJECTS} )