You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.8 KiB

  1. #
  2. # This program source code file is part of KICAD, a free EDA CAD application.
  3. #
  4. # Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, you may find one here:
  18. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. # or you may search the http://www.gnu.org website for the version 2 license,
  20. # or you may write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. # Build file for docset generation.
  23. #
  24. # Docsets are generated from the Doxygen docs by this process:
  25. # * Modify the existing doxygen file for a docset-friendly output
  26. # * Run doxygen to generate normal docygen output
  27. # * Run a makefile made by doxygen to start the docset
  28. # * Run doxytag2zealdb to generate the docset index
  29. # * Make a couple of changes to the Plist file and add icons
  30. find_program(DOXYTAG2ZEALDB doxytag2zealdb)
  31. find_program(SED sed)
  32. if(DOXYGEN_FOUND AND DOXYTAG2ZEALDB AND SED)
  33. function(get_kicad_doc_version RESULT_NAME)
  34. include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
  35. create_git_version_header(${CMAKE_SOURCE_DIR})
  36. # Now we have KICAD_VERSION, but it's got () around it
  37. string(REPLACE "(" "" KICAD_VERSION ${KICAD_VERSION})
  38. string(REPLACE ")" "" KICAD_VERSION ${KICAD_VERSION})
  39. set (${RESULT_NAME} ${KICAD_VERSION} PARENT_SCOPE)
  40. endfunction()
  41. # The DocSet's bundle ID, which is used for most of the ID's
  42. set(BUNDLE_ID KiCad)
  43. # The source for the doxygen config
  44. set(SRC_DOXYFILE ${CMAKE_SOURCE_DIR}/Doxyfile)
  45. # A new doxyfile with the original, plus some extra config
  46. set(DOCSET_DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
  47. # Various pieces of the docset
  48. set(DOCSET_LOC ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html/${BUNDLE_ID}.docset)
  49. set(DOXY_MAKEFILE ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html/Makefile)
  50. set(DOXY_TAG_FILE ${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_ID}.tag)
  51. set(DOCSET_PLIST ${DOCSET_LOC}/Contents/Info.plist)
  52. set(DOCSET_DSIDX ${DOCSET_LOC}/Contents/Resources/docSet.dsidx)
  53. #icon files
  54. set(DOCSET_SRC_ICON16 ${CMAKE_CURRENT_SOURCE_DIR}/icon-16.png)
  55. set(DOCSET_ICON16 ${DOCSET_LOC}/icon.png)
  56. get_kicad_doc_version(KICAD_DOC_VERSION)
  57. # copy and modify the "normal" Doxyfile
  58. file(COPY ${SRC_DOXYFILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
  59. file(APPEND ${DOCSET_DOXYFILE} "
  60. # Added for DocSet generation
  61. OUTPUT_DIRECTORY = ${CMAKE_CURRENT_BINARY_DIR}/doxygen
  62. PROJECT_NAME = ${BUNDLE_ID}
  63. PROJECT_NUMBER = ${KICAD_DOC_VERSION}
  64. GENERATE_DOCSET = YES
  65. DOCSET_FEEDNAME = ${BUNDLE_ID}
  66. DOCSET_BUNDLE_ID = ${BUNDLE_ID}
  67. DISABLE_INDEX = YES
  68. GENERATE_TREEVIEW = NO
  69. SEARCHENGINE = NO
  70. GENERATE_TAGFILE = ${DOXY_TAG_FILE}"
  71. )
  72. add_custom_command(
  73. COMMAND ${DOXYGEN_EXECUTABLE} ${DOCSET_DOXYFILE}
  74. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  75. OUTPUT ${DOXY_TAG_FILE} ${DOXY_MAKEFILE}
  76. DEPENDS ${DOCSET_DOXYFILE}
  77. COMMENT "Generating Doxygen for DocSet"
  78. )
  79. # Generate the skeleton of the docset
  80. # And modify the plist: DocSetPlatformFamily is used for the prefix in Zeal,
  81. add_custom_command(
  82. COMMAND make || true
  83. COMMAND ${SED} -i "/<key>DocSetPlatformFamily<\\/key>/!b;n;s/doxygen/${BUNDLE_ID}/" ${DOCSET_PLIST}
  84. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
  85. DEPENDS ${DOXY_MAKEFILE}
  86. OUTPUT ${DOCSET_PLIST}
  87. COMMENT "Running doxygen-generated makefile"
  88. VERBATIM
  89. )
  90. add_custom_command(
  91. COMMAND ${DOXYTAG2ZEALDB} --tag ${DOXY_TAG_FILE}
  92. --db ${DOCSET_DSIDX}
  93. --include-parent-scopes
  94. --include-function-signatures
  95. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
  96. DEPENDS ${DOCSET_PLIST} ${DOXY_TAG_FILE}
  97. OUTPUT ${DOCSET_DSIDX}
  98. COMMENT "Generating docset index"
  99. )
  100. add_custom_command(
  101. COMMAND ${CMAKE_COMMAND} -E copy ${DOCSET_SRC_ICON16} ${DOCSET_ICON16}
  102. DEPENDS ${DOCSET_DSIDX} ${DOCSET_SRC_ICON16}
  103. OUTPUT ${DOCSET_ICON16}
  104. COMMENT "Copying docset icons"
  105. )
  106. add_custom_target(docset
  107. DEPENDS ${DOCSET_ICON16}
  108. )
  109. endif()