Skip to content

Instantly share code, notes, and snippets.

@felix-kolbe
Forked from mikedld/CMakeLists.txt
Last active September 1, 2025 06:22
Show Gist options
  • Select an option

  • Save felix-kolbe/794810d036f40ddf7f96fa0d3a5c1f93 to your computer and use it in GitHub Desktop.

Select an option

Save felix-kolbe/794810d036f40ddf7f96fa0d3a5c1f93 to your computer and use it in GitHub Desktop.
Find all library dependencies of a CMake targets, recursively
function(print_all_libs TGT INDENT)
get_target_property(LIBS ${TGT} LINK_LIBRARIES)
if (LIBS)
foreach(LIB IN LISTS LIBS)
message(STATUS "${INDENT}> ${LIB}")
print_all_libs(${LIB} "${INDENT} ")
endforeach()
endif()
endfunction()
message(STATUS "All lib dependencies of app:")
print_all_libs(app "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment