ctkFunctionGetIncludeDirs.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. FUNCTION(ctkFunctionGetIncludeDirs var_include_dirs)
  22. IF(NOT ARGN)
  23. MESSAGE(FATAL_ERROR "No targets given")
  24. ENDIF()
  25. SET(_include_dirs ${${var_include_dirs}})
  26. FOREACH(_target ${ARGN})
  27. # Add the include directories from the plugin dependencies
  28. # The variable ${_target}_DEPENDENCIES is set in the
  29. # macro ctkMacroValidateBuildOptions
  30. SET(ctk_deps )
  31. SET(ext_deps )
  32. ctkMacroGetAllCTKTargetLibraries("${${_target}_DEPENDENCIES}" ctk_deps)
  33. ctkMacroGetAllNonCTKTargetLibraries("${${_target}_DEPENDENCIES}" ext_deps)
  34. FOREACH(dep ${ctk_deps})
  35. LIST(APPEND _include_dirs
  36. ${${dep}_SOURCE_DIR}
  37. ${${dep}_BINARY_DIR}
  38. )
  39. # For external projects, CTKConfig.cmake contains variables
  40. # listening the include dirs for CTK libraries and plugins
  41. IF(${dep}_INCLUDE_DIRS)
  42. LIST(APPEND _include_dirs ${${dep}_INCLUDE_DIRS})
  43. ENDIF()
  44. ENDFOREACH()
  45. FOREACH(dep ${ext_deps})
  46. IF(${dep}_INCLUDE_DIRS)
  47. STRING(REPLACE "^" ";" _ext_include_dirs "${${dep}_INCLUDE_DIRS}")
  48. LIST(APPEND _include_dirs ${_ext_include_dirs})
  49. ENDIF()
  50. # This is for resolving include dependencies between
  51. # libraries / plugins from external projects using CTK
  52. IF(${dep}_SOURCE_DIR)
  53. LIST(APPEND _include_dirs ${${dep}_SOURCE_DIR})
  54. ENDIF()
  55. IF(${dep}_BINARY_DIR)
  56. LIST(APPEND _include_dirs ${${dep}_BINARY_DIR})
  57. ENDIF()
  58. ENDFOREACH()
  59. ENDFOREACH()
  60. IF(_include_dirs)
  61. LIST(REMOVE_DUPLICATES _include_dirs)
  62. ENDIF()
  63. SET(${var_include_dirs} ${_include_dirs} PARENT_SCOPE)
  64. ENDFUNCTION()