ctkBlockCheckDependencies.cmake 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # Independently of the value of CTK_SUPERBUILD, each external project definition will
  3. # provides either the include and library directories or a variable name
  4. # used by the corresponding Find<package>.cmake files.
  5. #
  6. # Within top-level CMakeLists.txt file, the variable names will be expanded if not in
  7. # superbuild mode. The include and library dirs are then used in
  8. # ctkMacroBuildApp, ctkMacroBuildLib, and ctkMacroBuildPlugin
  9. #
  10. #-----------------------------------------------------------------------------
  11. # Collect CTK library target dependencies
  12. #
  13. ctkMacroCollectAllTargetLibraries("${CTK_LIBS}" "Libs" ALL_TARGET_LIBRARIES)
  14. ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS}" "Plugins" ALL_TARGET_LIBRARIES)
  15. ctkMacroCollectAllTargetLibraries("${CTK_APPS}" "Applications" ALL_TARGET_LIBRARIES)
  16. #message(STATUS ALL_TARGET_LIBRARIES:${ALL_TARGET_LIBRARIES})
  17. #-----------------------------------------------------------------------------
  18. # Initialize NON_CTK_DEPENDENCIES variable
  19. #
  20. # Using the variable ALL_TARGET_LIBRARIES initialized above with the help
  21. # of the macro ctkMacroCollectAllTargetLibraries, let's get the list of all Non-CTK dependencies.
  22. # NON_CTK_DEPENDENCIES is expected by the macro ctkMacroShouldAddExternalProject
  23. ctkMacroGetAllNonProjectTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCIES)
  24. #message(NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})
  25. #-----------------------------------------------------------------------------
  26. # Enable and setup External project global properties
  27. #
  28. if(CTK_SUPERBUILD)
  29. include(ExternalProject)
  30. include(ctkMacroEmptyExternalProject)
  31. #set(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals")
  32. #set_property(DIRECTORY PROPERTY EP_BASE ${ep_base})
  33. set(ep_install_dir ${CMAKE_BINARY_DIR}/CMakeExternals/Install)
  34. set(ep_suffix "-cmake")
  35. set(ep_common_c_flags "${CMAKE_C_FLAGS_INIT} ${ADDITIONAL_C_FLAGS}")
  36. set(ep_common_cxx_flags "${CMAKE_CXX_FLAGS_INIT} ${ADDITIONAL_CXX_FLAGS}")
  37. set(ep_common_cache_args
  38. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  39. -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
  40. -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
  41. -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
  42. -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
  43. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  44. -DBUILD_TESTING:BOOL=OFF
  45. )
  46. # Set CMake OSX variable to pass down the external projects
  47. set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS)
  48. if(APPLE)
  49. list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS
  50. -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  51. -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}
  52. -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
  53. )
  54. list(APPEND ep_common_cache_args ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS})
  55. endif()
  56. # Compute -G arg for configuring external projects with the same CMake generator:
  57. if(CMAKE_EXTRA_GENERATOR)
  58. set(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
  59. else()
  60. set(gen "${CMAKE_GENERATOR}")
  61. endif()
  62. # Use this value where semi-colons are needed in ep_add args:
  63. set(sep "^^")
  64. # This variable will contain the list of CMake variable specific to each external project
  65. # that should passed to CTK.
  66. # The item of this list should have the following form: <EP_VAR>:<TYPE>
  67. # where '<EP_VAR>' is an external project variable and TYPE is either BOOL, PATH or FILEPATH.
  68. # Variable appended to this list will be automatically exported in CTKConfig.cmake, prefix 'CTK_'
  69. # will be prepended if it applied.
  70. set(CTK_SUPERBUILD_EP_VARS)
  71. endif()
  72. if(NOT DEFINED CTK_POSSIBLE_DEPENDENCIES)
  73. message(FATAL_ERROR "error: CTK_POSSIBLE_DEPENDENCIES variable is not defined !")
  74. endif()
  75. foreach(p ${CTK_POSSIBLE_DEPENDENCIES})
  76. include(CMakeExternals/${p}.cmake)
  77. endforeach()
  78. #message("CTK_POSSIBLE_DEPENDENCIES:")
  79. #foreach(dep ${CTK_POSSIBLE_DEPENDENCIES})
  80. # message(" ${dep}")
  81. #endforeach()