ctkMacroSetupExternalPlugins.cmake 2.7 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. MACRO(ctkMacroSetupExternalPlugins )
  22. ctkMacroParseArguments(MY "BUILD_OPTION_PREFIX;BUILD_ALL" "COMPACT_OPTIONS" ${ARGN})
  23. IF(NOT MY_DEFAULT_ARGS)
  24. MESSAGE(FATAL_ERROR "Empty plugin list")
  25. ENDIF()
  26. SET(plugin_list ${MY_DEFAULT_ARGS})
  27. IF(NOT MY_BUILD_OPTION_PREFIX)
  28. SET(MY_BUILD_OPTION_PREFIX "BUILD_")
  29. ENDIF()
  30. IF(NOT MY_BUILD_ALL)
  31. SET(MY_BUILD_ALL 0)
  32. ENDIF()
  33. # Set up Qt, if not already done
  34. IF(NOT QT4_FOUND)
  35. SET(minimum_required_qt_version "4.6")
  36. FIND_PACKAGE(Qt4 REQUIRED)
  37. IF("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
  38. MESSAGE(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
  39. ENDIF()
  40. ENDIF()
  41. SET(plugin_dirswithoption )
  42. SET(plugin_subdirs )
  43. FOREACH(plugin ${plugin_list})
  44. ctkFunctionExtractOptionNameAndValue(${plugin} plugin_name plugin_value)
  45. IF(MY_COMPACT_OPTIONS)
  46. STRING(REPLACE "/" ";" _tokens ${plugin_name})
  47. LIST(GET _tokens -1 option_name)
  48. SET(option_name ${MY_BUILD_OPTION_PREFIX}${option_name})
  49. ELSE()
  50. SET(option_name ${MY_BUILD_OPTION_PREFIX}${plugin_name})
  51. ENDIF()
  52. SET(${plugin_name}_option_name ${option_name})
  53. OPTION(${option_name} "Build ${plugin_name} Plugin." ${plugin_value})
  54. IF(MY_BUILD_ALL)
  55. SET(${option_name} 1)
  56. ENDIF()
  57. LIST(APPEND plugin_subdirs "${plugin_name}")
  58. LIST(APPEND plugin_dirswithoption "${CMAKE_CURRENT_SOURCE_DIR}/${plugin_name}^^${option_name}")
  59. ENDFOREACH()
  60. ctkFunctionGenerateDGraphInput(${CMAKE_CURRENT_BINARY_DIR} "${plugin_dirswithoption}" WITH_EXTERNALS)
  61. ctkMacroValidateBuildOptions("${CMAKE_CURRENT_BINARY_DIR}" "${CTK_DGRAPH_EXECUTABLE}" "${plugin_dirswithoption}")
  62. FOREACH(plugin ${plugin_subdirs})
  63. IF(${${plugin}_option_name})
  64. ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/${plugin})
  65. ENDIF()
  66. ENDFOREACH()
  67. ENDMACRO()