SparkWithGit.cmake 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # Spark WithGit
  2. set(SPARK_FRAMEWORK_TO "${CMAKE_SOURCE_DIR}/cmake/_spark")
  3. function(spark_framework_from_git)
  4. # 1. 解析参数,使用原生 cmake 提供的参数解析器
  5. # set(OPTIONS)
  6. set(ONEVARG PREFIX)
  7. set(MULVARG COMPONENTS)
  8. cmake_parse_arguments(SPARK "" "${ONEVARG}" "${MULVARG}" ${ARGN})
  9. # 2. 如果包含 PREFIX 则开始进行解析
  10. if(SPARK_PREFIX)
  11. if(NOT EXISTS "${SPARK_FRAMEWORK_TO}")
  12. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${SPARK_FRAMEWORK_TO}")
  13. endif(NOT EXISTS "${SPARK_FRAMEWORK_TO}")
  14. foreach(SPARK_COMPONENT IN LISTS SPARK_COMPONENTS)
  15. # execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${SPARK_PREFIX}.${SPARK_COMPONENT}'"
  16. # WORKING_DIRECTORY ${SPARK_FRAMEWORK_TO})
  17. if(NOT EXISTS "${SPARK_FRAMEWORK_TO}/${SPARK_COMPONENT}")
  18. execute_process(COMMAND git clone "${SPARK_PREFIX}/${SPARK_COMPONENT}"
  19. WORKING_DIRECTORY ${SPARK_FRAMEWORK_TO})
  20. else()
  21. message("[SparkWithGit] Exits: ${SPARK_COMPONENT}")
  22. endif(NOT EXISTS "${SPARK_FRAMEWORK_TO}/${SPARK_COMPONENT}")
  23. endforeach(SPARK_COMPONENT IN LISTS SPARK_COMPONENTS)
  24. endif(SPARK_PREFIX)
  25. # 方案一:.gitignoe
  26. if(NOT EXISTS "${SPARK_FRAMEWORK_TO}/.gitignore")
  27. file(WRITE "${SPARK_FRAMEWORK_TO}/.gitignore" "spark.*/\n.gitignore")
  28. endif(NOT EXISTS "${SPARK_FRAMEWORK_TO}/.gitignore")
  29. # 方案二: ../.gitignore
  30. # if(NOT EXISTS "${SPARK_FRAMEWORK_TO}/../.gitignore")
  31. # file(WRITE "${SPARK_FRAMEWORK_TO}/../.gitignore" "_spark/\n.gitignore")
  32. # endif(NOT EXISTS "${SPARK_FRAMEWORK_TO}/../.gitignore")
  33. endfunction(spark_framework_from_git)
  34. macro(spark_include)
  35. set(_spark_files ${ARGN})
  36. foreach(_spark_file IN LISTS _spark_files)
  37. if(EXISTS "${_spark_file}")
  38. include(${_spark_file})
  39. continue()
  40. endif(EXISTS "${_spark_file}")
  41. file(GLOB_RECURSE _file RELATIVE "${SPARK_FRAMEWORK_TO}" ${_spark_file})
  42. list(FILTER _file EXCLUDE REGEX "\\.\\.")
  43. if(EXISTS "${SPARK_FRAMEWORK_TO}/${_file}")
  44. message("FOUND: ${SPARK_FRAMEWORK_TO}/${_file}")
  45. include("${SPARK_FRAMEWORK_TO}/${_file}")
  46. else()
  47. message(WARNING "NOT FOUND: ${SPARK_FRAMEWORK_TO}/${_file}")
  48. endif(EXISTS "${SPARK_FRAMEWORK_TO}/${_file}")
  49. endforeach(_spark_file IN LISTS _spark_files)
  50. endmacro(spark_include)
  51. # 引入的所有 Spark 构建模块
  52. spark_framework_from_git(
  53. PREFIX
  54. http://gitee.com/zinface/
  55. COMPONENTS
  56. spark.assets-icon
  57. spark.env
  58. spark.macros
  59. spark.find-qt5
  60. spark.find-qt6
  61. spark.find-dtk
  62. spark.find-library
  63. spark.macros-extend
  64. spark.build-graphviz
  65. spark.framework
  66. spark.cmake-info
  67. spark.external-project
  68. spark.translator-macro
  69. spark.install-macros
  70. spark.desktop-macro
  71. spark.deb-package
  72. spark.appimage-macros-online
  73. )
  74. # include(cmake/SparkWithGit.cmake)
  75. # 用于 spark_include 引入相关的列表项,每一项都是可引用的构建模块
  76. # spark_include(
  77. # SparkEnvConfig.cmake
  78. # SparkMacrosConfig.cmake
  79. # SparkFindQt5Config.cmake
  80. # SparkFindQt6Config.cmake
  81. # SparkFindDtkConfig.cmake
  82. # SparkFindLibraries.cmake
  83. # SparkMacrosExtendConfig.cmake
  84. # SparkFramework.cmake
  85. # SparkCMakeInfoAfterConfig.cmake
  86. # SparkCMakeInfoBeforeConfig.cmake
  87. # SparkExternalProject.cmake
  88. # SparkTranslatorConfig.cmake
  89. # SparkInstallMacrosConfig.cmake
  90. # SparkBuildGraphviz.cmake
  91. # SparkDesktopMacros.cmake
  92. # SparkDebPackageConfig.cmake
  93. # SparkAppimageConfig.cmake
  94. # )