ctkFunctionGetIncludeDirs.cmake 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. ctkMacroGetAllProjectTargetLibraries("${${_target}_DEPENDENCIES}" ctk_deps)
  33. ctkMacroGetAllNonProjectTargetLibraries("${${_target}_DEPENDENCIES}" ext_deps)
  34. FOREACH(dep ${ctk_deps})
  35. IF(${dep}_INCLUDE_SUFFIXES)
  36. FOREACH(_suffix ${${dep}_INCLUDE_SUFFIXES})
  37. LIST(APPEND _include_dirs ${${dep}_SOURCE_DIR}/${_suffix})
  38. ENDFOREACH()
  39. LIST(APPEND _include_dirs ${${dep}_BINARY_DIR})
  40. ELSE()
  41. LIST(APPEND _include_dirs
  42. ${${dep}_SOURCE_DIR}
  43. ${${dep}_BINARY_DIR}
  44. )
  45. ENDIF()
  46. # For external projects, CTKConfig.cmake contains variables
  47. # listening the include dirs for CTK libraries and plugins
  48. IF(${dep}_INCLUDE_DIRS)
  49. LIST(APPEND _include_dirs ${${dep}_INCLUDE_DIRS})
  50. ENDIF()
  51. ENDFOREACH()
  52. FOREACH(dep ${ext_deps})
  53. IF(${dep}_INCLUDE_DIRS)
  54. STRING(REPLACE "^" ";" _ext_include_dirs "${${dep}_INCLUDE_DIRS}")
  55. LIST(APPEND _include_dirs ${_ext_include_dirs})
  56. ENDIF()
  57. # This is for resolving include dependencies between
  58. # libraries / plugins from external projects using CTK
  59. IF(${dep}_SOURCE_DIR AND ${dep}_INCLUDE_SUFFIXES)
  60. FOREACH(_suffix ${${dep}_INCLUDE_SUFFIXES})
  61. LIST(APPEND _include_dirs ${${dep}_SOURCE_DIR}/${_suffix})
  62. ENDFOREACH()
  63. LIST(APPEND _include_dirs ${${dep}_BINARY_DIR})
  64. ELSEIF(${dep}_SOURCE_DIR)
  65. LIST(APPEND _include_dirs ${${dep}_SOURCE_DIR})
  66. ENDIF()
  67. IF(${dep}_BINARY_DIR)
  68. LIST(APPEND _include_dirs ${${dep}_BINARY_DIR})
  69. ENDIF()
  70. ENDFOREACH()
  71. ENDFOREACH()
  72. IF(_include_dirs)
  73. LIST(REMOVE_DUPLICATES _include_dirs)
  74. ENDIF()
  75. SET(${var_include_dirs} ${_include_dirs} PARENT_SCOPE)
  76. ENDFUNCTION()