ctkFunctionGetIncludeDirs.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) German Cancer Research Center,
  6. # Division of Medical and Biological Informatics
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. #
  20. ###########################################################################
  21. #! \ingroup CMakeUtilities
  22. FUNCTION(ctkFunctionGetIncludeDirs var_include_dirs)
  23. IF(NOT ARGN)
  24. MESSAGE(FATAL_ERROR "No targets given")
  25. ENDIF()
  26. SET(_include_dirs ${${var_include_dirs}})
  27. FOREACH(_target ${ARGN})
  28. # Add the include directories from the plugin dependencies
  29. # The variable ${_target}_DEPENDENCIES is set in the
  30. # macro ctkMacroValidateBuildOptions
  31. SET(ctk_deps )
  32. SET(ext_deps )
  33. ctkMacroGetAllCTKTargetLibraries("${${_target}_DEPENDENCIES}" ctk_deps)
  34. ctkMacroGetAllNonCTKTargetLibraries("${${_target}_DEPENDENCIES}" ext_deps)
  35. FOREACH(dep ${ctk_deps})
  36. LIST(APPEND _include_dirs
  37. ${${dep}_SOURCE_DIR}
  38. ${${dep}_BINARY_DIR}
  39. )
  40. # For external projects, CTKConfig.cmake contains variables
  41. # listening the include dirs for CTK libraries and plugins
  42. IF(${dep}_INCLUDE_DIRS)
  43. LIST(APPEND _include_dirs ${${dep}_INCLUDE_DIRS})
  44. ENDIF()
  45. ENDFOREACH()
  46. FOREACH(dep ${ext_deps})
  47. IF(${dep}_INCLUDE_DIRS)
  48. STRING(REPLACE "^" ";" _ext_include_dirs "${${dep}_INCLUDE_DIRS}")
  49. LIST(APPEND _include_dirs ${_ext_include_dirs})
  50. ENDIF()
  51. # This is for resolving include dependencies between
  52. # libraries / plugins from external projects using CTK
  53. IF(${dep}_SOURCE_DIR)
  54. LIST(APPEND _include_dirs ${${dep}_SOURCE_DIR})
  55. ENDIF()
  56. IF(${dep}_BINARY_DIR)
  57. LIST(APPEND _include_dirs ${${dep}_BINARY_DIR})
  58. ENDIF()
  59. ENDFOREACH()
  60. ENDFOREACH()
  61. IF(_include_dirs)
  62. LIST(REMOVE_DUPLICATES _include_dirs)
  63. ENDIF()
  64. SET(${var_include_dirs} ${_include_dirs} PARENT_SCOPE)
  65. ENDFUNCTION()