|
| 1 | +# Add the cmake folder so the FindSphinx module is found |
| 2 | +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) |
| 3 | + |
| 4 | +find_package(Python REQUIRED) |
| 5 | +find_package(Doxygen REQUIRED) |
| 6 | +find_package(Sphinx REQUIRED COMPONENTS sphinx_rtd_theme breathe sphinx_copybutton rst2pdf) |
| 7 | + |
| 8 | +# Find all the public headers |
| 9 | +get_target_property(MGX_PUBLIC_HEADER_DIR Core INTERFACE_INCLUDE_DIRECTORIES) |
| 10 | +file(GLOB_RECURSE MGX_PUBLIC_HEADERS ${MGX_PUBLIC_HEADER_DIR}/*.h) |
| 11 | + |
| 12 | +set(DOXYGEN_DIRS |
| 13 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Internal/ContextIfc.h |
| 14 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Internal/Context.h |
| 15 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Internal/M3DCommandManager.h |
| 16 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Internal/M3DCommandResultIfc.h |
| 17 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Point.h |
| 18 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Spherical.h |
| 19 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Cylindrical.h |
| 20 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Vector.h |
| 21 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Plane.h |
| 22 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Rotation.h |
| 23 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/RotX.h |
| 24 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/RotY.h |
| 25 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Point.h |
| 26 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/RotZ.h |
| 27 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Constants.h |
| 28 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Landmark.h |
| 29 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/Unit.h |
| 30 | + ${PROJECT_SOURCE_DIR}/src/Utils/protected/Utils/SwigCompletion.h |
| 31 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Geom/GeomManagerIfc.h |
| 32 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Geom/GeomInfo.h |
| 33 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/TopoInfo.h |
| 34 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/TopoManagerIfc.h |
| 35 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyUniform.h |
| 36 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyUniformSmoothFix.h |
| 37 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyGeometric.h |
| 38 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyBigeometric.h |
| 39 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyHyperbolic.h |
| 40 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertySpecificSize.h |
| 41 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyInterpolate.h |
| 42 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyGlobalInterpolate.h |
| 43 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyTabulated.h |
| 44 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/EdgeMeshingPropertyBeta.h |
| 45 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyDirectional.h |
| 46 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyOrthogonal.h |
| 47 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyRotational.h |
| 48 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyTransfinite.h |
| 49 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyDelaunayGMSH.h |
| 50 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyQuadPairing.h |
| 51 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/FaceMeshingPropertyMeshGems.h |
| 52 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyDirectional.h |
| 53 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyOrthogonal.h |
| 54 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyRotational.h |
| 55 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyTransfinite.h |
| 56 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyDelaunayMeshGems.h |
| 57 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyDelaunayTetgen.h |
| 58 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Topo/BlockMeshingPropertyInsertion.h |
| 59 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Mesh/MeshManagerIfc.h |
| 60 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Mesh/MeshModificationBySepa.h |
| 61 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Smoothing/SurfacicSmoothing.h |
| 62 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Smoothing/VolumicSmoothing.h |
| 63 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Group/GroupManagerIfc.h |
| 64 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/SysCoord/SysCoordManagerIfc.h |
| 65 | + ${PROJECT_SOURCE_DIR}/src/Core/protected/Structured/StructuredMeshManagerIfc.h |
| 66 | +) |
| 67 | + |
| 68 | +string(REPLACE ";" " " DOXYGEN_DIRS_STR "${DOXYGEN_DIRS}") |
| 69 | +set(DOXYGEN_INPUT_DIR ${DOXYGEN_DIRS_STR}) |
| 70 | +set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen) |
| 71 | +set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml) |
| 72 | +set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) |
| 73 | +set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 74 | + |
| 75 | +#Replace variables inside @@ with the current values |
| 76 | +configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) |
| 77 | + |
| 78 | +set(VARMMODULE_IN ${CMAKE_CURRENT_SOURCE_DIR}/variables.py.in) |
| 79 | +set(VARMMODULE_OUT ${CMAKE_CURRENT_BINARY_DIR}/variables.py) |
| 80 | + |
| 81 | +configure_file(${VARMMODULE_IN} ${VARMMODULE_OUT} @ONLY) |
| 82 | + |
| 83 | +# Doxygen won't create this for us |
| 84 | +file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}) |
| 85 | +# fix bug https://github.com/doxygen/doxygen/issues/6293 |
| 86 | +file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html) |
| 87 | +file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}/xml) |
| 88 | + |
| 89 | +# Only regenerate Doxygen when the Doxyfile or public headers change |
| 90 | +add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} |
| 91 | + DEPENDS ${MGX_PUBLIC_HEADERS} |
| 92 | + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} |
| 93 | + MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN} |
| 94 | + COMMENT "Generating docs" |
| 95 | + VERBATIM) |
| 96 | + |
| 97 | +# Nice named target so we can run the job easily |
| 98 | +add_custom_target(doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) |
| 99 | + |
| 100 | +set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}) |
| 101 | +set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx) |
| 102 | +set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html) |
| 103 | + |
| 104 | +# we call sphinx from camke command to set PYTHONPATH (to use built VARMMODULE_OUT file) |
| 105 | +set(HTML_SPHINX_COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_BINARY_DIR} |
| 106 | + ${SPHINX_EXECUTABLE} -q -b html |
| 107 | + # Tell Breathe where to find the Doxygen output |
| 108 | + -Dbreathe_projects.MGX=${DOXYGEN_OUTPUT_DIR}/xml |
| 109 | + ${SPHINX_SOURCE} ${SPHINX_BUILD}) |
| 110 | + |
| 111 | +# we call sphinx from camke command to set PYTHONPATH (to use built VARMMODULE_OUT file) |
| 112 | +set(PDF_SPHINX_COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_BINARY_DIR} |
| 113 | + ${SPHINX_EXECUTABLE} -b pdf |
| 114 | +${SPHINX_SOURCE} ${SPHINX_BUILD}/pdf) |
| 115 | + |
| 116 | +# Only regenerate Sphinx when: |
| 117 | +# - Doxygen has rerun |
| 118 | +# - Our doc files have been updated |
| 119 | +# - The Sphinx config has been updated |
| 120 | +add_custom_command( |
| 121 | + OUTPUT ${SPHINX_INDEX_FILE} |
| 122 | + COMMAND ${HTML_SPHINX_COMMAND} |
| 123 | + COMMAND ${PDF_SPHINX_COMMAND} |
| 124 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 125 | + DEPENDS |
| 126 | + # Other docs files you want to track should go here (or in some variable) |
| 127 | + ${CMAKE_CURRENT_SOURCE_DIR}/index.rst |
| 128 | + ${CMAKE_CURRENT_SOURCE_DIR}/pages/*.rst |
| 129 | + ${CMAKE_CURRENT_SOURCE_DIR}/resources/* |
| 130 | + ${CMAKE_CURRENT_SOURCE_DIR}/images/* |
| 131 | + ${CMAKE_CURRENT_SOURCE_DIR}/_ext/*.py |
| 132 | + ${CMAKE_CURRENT_SOURCE_DIR}/_static/*.css |
| 133 | + ${CMAKE_CURRENT_SOURCE_DIR}/*.yaml |
| 134 | + ${DOXYGEN_INDEX_FILE} |
| 135 | + MAIN_DEPENDENCY conf.py |
| 136 | + COMMENT "Generating html and pdf documentation with Sphinx") |
| 137 | + |
| 138 | +# Doc target so we can run the job easily |
| 139 | +add_custom_target(documentation ALL DEPENDS ${SPHINX_INDEX_FILE}) |
| 140 | + |
| 141 | +# Recopie de la doc générée dans le répertoire d'installation |
| 142 | +include(GNUInstallDirs) |
| 143 | +install (DIRECTORY ${SPHINX_BUILD} |
| 144 | + DESTINATION ${CMAKE_INSTALL_DOCDIR} |
| 145 | + FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_READ |
| 146 | + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETGID |
| 147 | + ) |
| 148 | + |
| 149 | +install (DIRECTORY ${DOXYGEN_OUTPUT_DIR} |
| 150 | + DESTINATION ${CMAKE_INSTALL_DOCDIR} |
| 151 | + FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_READ |
| 152 | + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETGID |
| 153 | + ) |
0 commit comments