ctkMacroSetupExternalPlugins.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 CMakeAPI
  22. MACRO(ctkMacroSetupExternalPlugins )
  23. ctkMacroParseArguments(MY "BUILD_OPTION_PREFIX" "" ${ARGN})
  24. IF(NOT MY_DEFAULT_ARGS)
  25. MESSAGE(FATAL_ERROR "Empty plugin list")
  26. ENDIF()
  27. SET(plugin_list ${MY_DEFAULT_ARGS})
  28. IF(NOT MY_BUILD_OPTION_PREFIX)
  29. SET(MY_BUILD_OPTION_PREFIX "BUILD_")
  30. ENDIF()
  31. SET(plugin_dirswithoption )
  32. SET(plugin_subdirs )
  33. FOREACH(plugin ${plugin_list})
  34. ctkFunctionExtractOptionNameAndValue(${plugin} plugin_name plugin_value)
  35. SET(option_name ${MY_BUILD_OPTION_PREFIX}${plugin_name})
  36. OPTION(${option_name} "Build ${plugin_name} Plugin." ${plugin_value})
  37. LIST(APPEND plugin_subdirs "${plugin_name}")
  38. LIST(APPEND plugin_dirswithoption "${CMAKE_CURRENT_SOURCE_DIR}/${plugin_name}^^${option_name}")
  39. ENDFOREACH()
  40. ctkFunctionGenerateDGraphInput(${CMAKE_CURRENT_BINARY_DIR} "${plugin_dirswithoption}" WITH_EXTERNALS)
  41. ctkMacroValidateBuildOptions("${CMAKE_CURRENT_BINARY_DIR}" "${CTK_DGRAPH_EXECUTABLE}" "${plugin_dirswithoption}")
  42. FOREACH(plugin ${plugin_subdirs})
  43. IF(${MY_BUILD_OPTION_PREFIX}${plugin})
  44. ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/${plugin})
  45. ENDIF()
  46. ENDFOREACH()
  47. ENDMACRO()