[CMake] Getting a list of build link targets?

Doug douglas.linder at gmail.com
Wed Mar 5 02:58:37 EST 2014


Is there a less annoying way of doing this?

function(get_dependent_targets TARGET RETURN)
  get_property(LOC TARGET ${TARGET} PROPERTY LOCATION)
  set(RTN ${LOC})
  get_property(LIBS TARGET ${TARGET} PROPERTY LINK_LIBRARIES)
  foreach(LIB ${LIBS})
    get_dependent_targets(${LIB} LIB_LIST)
    foreach(LIBI ${LIB_LIST})
      list(APPEND RTN ${LIBI})
    endforeach()
  endforeach()
  set(${RETURN} ${RTN} PARENT_SCOPE)
endfunction()

Specifically I'm trying to generate a list of static link targets for a
library to output ot a file using the template system so that a rust build
can statically link correctly to all the dependent static targets for a
given library...

~
Doug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140305/0a057a6f/attachment.html>


More information about the CMake mailing list