| 1 | project (Overview) |
| 2 | |
| 3 | # directory that contains all raw OCCT overview articles (markdown format) |
| 4 | set (OCCT_OVERVIEW_DIR "${CMAKE_SOURCE_DIR}/dox") |
| 5 | |
| 6 | # directory that contains resources for the generation of OCCT documentation |
| 7 | set (OCCT_OVERVIEW_RESOURCE_DIR "${OCCT_OVERVIEW_DIR}/resources") |
| 8 | |
| 9 | # directory that contains all generated OCCT articles |
| 10 | set (OCCT_GENERATED_DOC_DIR "${CMAKE_BINARY_DIR}/doc") |
| 11 | if (NOT EXISTS "${OCCT_GENERATED_DOC_DIR}") |
| 12 | file (MAKE_DIRECTORY "${OCCT_GENERATED_DOC_DIR}") |
| 13 | endif() |
| 14 | |
| 15 | # directory that contains generated OCCT overview articles |
| 16 | set (OCCT_GENERATED_OVERVIEW_DIR "${OCCT_GENERATED_DOC_DIR}/overview") |
| 17 | if (NOT EXISTS "${OCCT_GENERATED_OVERVIEW_DIR}") |
| 18 | file (MAKE_DIRECTORY "${OCCT_GENERATED_OVERVIEW_DIR}") |
| 19 | endif() |
| 20 | |
| 21 | # directory that contains generated OCCT overview articles in html format |
| 22 | set (OCCT_GENERATED_HTML_OVERVIEW_DIR "${OCCT_GENERATED_OVERVIEW_DIR}/html") |
| 23 | if (NOT EXISTS "${OCCT_GENERATED_HTML_OVERVIEW_DIR}") |
| 24 | file (MAKE_DIRECTORY "${OCCT_GENERATED_HTML_OVERVIEW_DIR}") |
| 25 | endif() |
| 26 | |
| 27 | # read OCCT articles that should be generated |
| 28 | set (OCCT_ARTICLES "") |
| 29 | if (EXISTS "${OCCT_OVERVIEW_DIR}/FILES_HTML.txt" ) |
| 30 | file (STRINGS "${OCCT_OVERVIEW_DIR}/FILES_HTML.txt" OCCT_ARTICLES REGEX "^[^#]+") |
| 31 | else() |
| 32 | message (FATAL_ERROR "FILES_HTML.txt is not found in ${OCCT_OVERVIEW_DIR}") |
| 33 | endif() |
| 34 | |
| 35 | # configuration file for doxygen |
| 36 | set (OCCT_CONFIG_FOR_DOXYGEN "${OCCT_GENERATED_DOC_DIR}/occt.cfg") |
| 37 | |
| 38 | set (3RDPARTY_MATHJAX_RELATIVE_PATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1") |
| 39 | |
| 40 | configure_file ("${OCCT_OVERVIEW_RESOURCE_DIR}/occt_ug_html.doxyfile" "${OCCT_CONFIG_FOR_DOXYGEN}" COPYONLY) |
| 41 | |
| 42 | # Add common options for generation of Overview and User Guides |
| 43 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nPROJECT_NUMBER = ${OCC_VERSION_STRING_EXT}") |
| 44 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nOUTPUT_DIRECTORY = ${OCCT_GENERATED_OVERVIEW_DIR}/.") |
| 45 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nPROJECT_LOGO = ${OCCT_OVERVIEW_DIR}/resources/occ_logo.png") |
| 46 | |
| 47 | set (OCCT_ARTICLE_PARAM_INPUT "INPUT =") |
| 48 | set (OCCT_ARTICLE_PARAM_IMAGEPATH "IMAGE_PATH = ${OCCT_OVERVIEW_DIR}/resources/ ") |
| 49 | |
| 50 | set (OCCT_ARTICLES_ABSPATH "") |
| 51 | foreach (OCCT_ARTICLE ${OCCT_ARTICLES}) |
| 52 | get_filename_component (OCCT_ARTICLE_ABSOLUTE_PATH "${OCCT_OVERVIEW_DIR}/${OCCT_ARTICLE}" ABSOLUTE) |
| 53 | get_filename_component (OCCT_ARTICLE_PARENT_DIR "${OCCT_ARTICLE_ABSOLUTE_PATH}" PATH) |
| 54 | |
| 55 | if (EXISTS "${OCCT_ARTICLE_PARENT_DIR}/images") |
| 56 | set (OCCT_ARTICLE_PARAM_IMAGEPATH "${OCCT_ARTICLE_PARAM_IMAGEPATH} ${OCCT_ARTICLE_PARENT_DIR}/images") |
| 57 | endif() |
| 58 | |
| 59 | set (OCCT_ARTICLE_PARAM_INPUT "${OCCT_ARTICLE_PARAM_INPUT} ${OCCT_ARTICLE_ABSOLUTE_PATH}") |
| 60 | |
| 61 | set (SOURCE_GROUP_NAME "") |
| 62 | |
| 63 | # add the file to appropriate source group |
| 64 | get_filename_component (CURRENT_TAIL_PATH "${OCCT_ARTICLE}" PATH) |
| 65 | while (CURRENT_TAIL_PATH AND NOT "${CURRENT_TAIL_PATH}" STREQUAL "..") |
| 66 | get_filename_component (CURRENT_DIR_NAME "${CURRENT_TAIL_PATH}" NAME) |
| 67 | set (SOURCE_GROUP_NAME "${CURRENT_DIR_NAME}\\${SOURCE_GROUP_NAME}") |
| 68 | |
| 69 | # one step out (get parent directory) |
| 70 | get_filename_component (CURRENT_TAIL_PATH "${CURRENT_TAIL_PATH}" PATH) |
| 71 | endwhile() |
| 72 | SOURCE_GROUP ("${SOURCE_GROUP_NAME}" FILES ${OCCT_ARTICLE_ABSOLUTE_PATH}) |
| 73 | |
| 74 | list (APPEND OCCT_ARTICLES_ABSPATH ${OCCT_ARTICLE_ABSOLUTE_PATH}) |
| 75 | endforeach() |
| 76 | |
| 77 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\n${OCCT_ARTICLE_PARAM_INPUT}") |
| 78 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\n${OCCT_ARTICLE_PARAM_IMAGEPATH}") |
| 79 | |
| 80 | # Add document type-specific options |
| 81 | # generate tree view |
| 82 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nGENERATE_TREEVIEW = YES") |
| 83 | |
| 84 | # HTML Search engine options |
| 85 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nSEARCHENGINE = YES") |
| 86 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nSERVER_BASED_SEARCH = YES") |
| 87 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nEXTERNAL_SEARCH = NO") |
| 88 | |
| 89 | # Formula options |
| 90 | file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nMATHJAX_RELPATH = ${3RDPARTY_MATHJAX_RELATIVE_PATH}") |
| 91 | |
| 92 | # Copy index file to provide fast access to HTML documentation |
| 93 | file(COPY "${OCCT_OVERVIEW_RESOURCE_DIR}/index.html" DESTINATION "${OCCT_GENERATED_OVERVIEW_DIR}") |
| 94 | |
| 95 | # get relative paths to documentation source files |
| 96 | file (GLOB_RECURSE OCCT_OVERVIEW_FILES "${OCCT_OVERVIEW_DIR}/*") |
| 97 | |
| 98 | add_custom_command(OUTPUT "${OCCT_GENERATED_DOC_DIR}/overview/html/occt_logo.png" |
| 99 | COMMAND ${3RDPARTY_DOXYGEN_EXECUTABLE} ${OCCT_CONFIG_FOR_DOXYGEN} |
| 100 | DEPENDS ${OCCT_OVERVIEW_FILES} |
| 101 | WORKING_DIRECTORY ${OCCT_GENERATED_DOC_DIR} |
| 102 | COMMENT "Generating OCCT overview documentation with Doxygen" |
| 103 | VERBATIM |
| 104 | ) |
| 105 | |
| 106 | add_custom_target(${PROJECT_NAME} ALL |
| 107 | DEPENDS "${OCCT_GENERATED_DOC_DIR}/overview/html/occt_logo.png" ${OCCT_OVERVIEW_FILES} |
| 108 | SOURCES ${OCCT_ARTICLES_ABSPATH} |
| 109 | VERBATIM |
| 110 | ) |
| 111 | |
| 112 | # Create Documentation folder in solution view |
| 113 | set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "Documentation") |