ctkFunctionGetTargetDependencies.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!
  2. #! \brief Stores all target dependencies (potentially also from external projects)
  3. #! in the variable specified by the first argument.
  4. #!
  5. #! \param var_deps (required) A variable name containing the output.
  6. #! \param TARGETS (required) A list of targets (library targets or plug-in targets/symbolic names)
  7. #! for which the set of dependencies should be obtained.
  8. #! \param ALL (option) Include external dependencies.
  9. #! \ingroup CMakeUtilities
  10. function(ctkFunctionGetTargetDependencies var_deps)
  11. ctkMacroParseArguments(MY "TARGETS" "ALL" ${ARGN})
  12. # Sanity checks
  13. if(NOT var_deps)
  14. message(FATAL_ERROR "Missing variable name as the first argument for storing the result")
  15. endif()
  16. if(NOT MY_TARGETS)
  17. message(FATAL_ERROR "Missing target names")
  18. endif()
  19. set(_targets )
  20. foreach(_target ${MY_TARGETS})
  21. # convenience conversion for plug-in targets
  22. string(REPLACE "." "_" _target ${_target})
  23. # assume the variable ${_target}_DEPENDENCIES was set during
  24. # a previous invocation of the ctkMacroValidateBuildOptions macro.
  25. list(APPEND _targets ${${_target}_DEPENDENCIES})
  26. endforeach()
  27. if (_targets)
  28. list(REMOVE_DUPLICATES _targets)
  29. if(NOT MY_ALL)
  30. # remove external targets not belonging to the current project
  31. ctkMacroGetAllProjectTargetLibraries("${_targets}" _targets)
  32. endif()
  33. endif()
  34. set(${var_deps} ${_targets} PARENT_SCOPE)
  35. endfunction()