Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
72a2e456dbb16311c834137d333af6f1b7832f0d
[simgrid.git] / buildtools / Cmake / GenerateDoc.cmake
1 #### Generate the whole html documentation
2
3 find_path(DOXYGEN_PATH  NAMES doxygen  PATHS NO_DEFAULT_PATHS)
4 find_path(FIG2DEV_PATH  NAMES fig2dev  PATHS NO_DEFAULT_PATHS)
5
6 if(DOXYGEN_PATH)
7
8   ADD_CUSTOM_TARGET(simgrid_documentation
9     COMMENT "Generating the SimGrid documentation..."
10     DEPENDS ${DOC_SOURCES} ${DOC_FIGS} ${source_doxygen}
11     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_HOME_DIRECTORY}/doc/html
12     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_HOME_DIRECTORY}/doc/html
13     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
14     )
15
16   execute_process(COMMAND ${DOXYGEN_PATH}/doxygen --version OUTPUT_VARIABLE DOXYGEN_VERSION )
17   string(REGEX MATCH "^[0-9]" DOXYGEN_MAJOR_VERSION "${DOXYGEN_VERSION}")
18   string(REGEX MATCH "^[0-9].[0-9]" DOXYGEN_MINOR_VERSION "${DOXYGEN_VERSION}")
19   string(REGEX MATCH "^[0-9].[0-9].[0-9]" DOXYGEN_PATCH_VERSION "${DOXYGEN_VERSION}")
20   string(REGEX REPLACE "^${DOXYGEN_MINOR_VERSION}." "" DOXYGEN_PATCH_VERSION "${DOXYGEN_PATCH_VERSION}")
21   string(REGEX REPLACE "^${DOXYGEN_MAJOR_VERSION}." "" DOXYGEN_MINOR_VERSION "${DOXYGEN_MINOR_VERSION}")
22   message(STATUS "Doxygen version : ${DOXYGEN_MAJOR_VERSION}.${DOXYGEN_MINOR_VERSION}.${DOXYGEN_PATCH_VERSION}")
23
24   if(DOXYGEN_MAJOR_VERSION STRLESS "2" AND DOXYGEN_MINOR_VERSION STRLESS "8")
25     ADD_CUSTOM_TARGET(error_doxygen
26       COMMAND ${CMAKE_COMMAND} -E echo "Doxygen must be at least version 1.8 to generate documentation"
27       COMMAND false
28     )
29
30     add_dependencies(simgrid_documentation error_doxygen)
31   endif()
32
33   configure_file(${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in ${CMAKE_HOME_DIRECTORY}/doc/Doxyfile @ONLY)
34
35   foreach(file ${DOC_FIGS})
36     string(REPLACE ".fig" ".png" tmp_file ${file})
37     string(REPLACE "${CMAKE_HOME_DIRECTORY}/doc/shared/fig/" "${CMAKE_HOME_DIRECTORY}/doc/html/" tmp_file ${tmp_file})
38     ADD_CUSTOM_COMMAND(TARGET simgrid_documentation
39       COMMAND ${FIG2DEV_PATH}/fig2dev -Lpng -S 4 ${file} ${tmp_file}
40       )
41   endforeach()
42
43   foreach(file ${DOC_IMG})
44     ADD_CUSTOM_COMMAND(
45       TARGET simgrid_documentation
46       COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_HOME_DIRECTORY}/doc/html/
47     )
48   endforeach()
49
50   ADD_CUSTOM_COMMAND(TARGET simgrid_documentation
51     COMMAND ${FIG2DEV_PATH}/fig2dev -Lmap ${CMAKE_HOME_DIRECTORY}/doc/shared/fig/simgrid_modules.fig | perl -pe 's/imagemap/simgrid_modules/g'| perl -pe 's/<IMG/<IMG style=border:0px/g' | ${CMAKE_HOME_DIRECTORY}/tools/doxygen/fig2dev_postprocessor.pl > ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
52     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen"
53     COMMAND ${DOXYGEN_PATH}/doxygen Doxyfile
54     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate the index files"
55     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/index_create.pl simgrid.tag index-API.doc     
56     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
57     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl > ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
58     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen again"
59     COMMAND ${DOXYGEN_PATH}/doxygen Doxyfile
60     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
61     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
62     )
63
64   ADD_CUSTOM_TARGET(pdf
65     COMMAND ${CMAKE_COMMAND} -E echo "XX First pass simgrid_documentation.pdf"
66     COMMAND make clean
67     COMMAND make pdf || true
68     COMMAND ${CMAKE_COMMAND} -E echo "XX Second pass simgrid_documentation.pdf"
69     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf
70     COMMAND make pdf || true
71     COMMAND ${CMAKE_COMMAND} -E echo "XX Write Simgrid_documentation.pdf"
72     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf ${CMAKE_HOME_DIRECTORY}/doc/latex/simgrid_documentation.pdf
73     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/latex/
74     )
75   add_dependencies(pdf simgrid_documentation)
76
77
78 endif()
79
80 #############################################
81 ### Fill in the "make sync-gforge" target ###
82 #############################################
83
84 add_custom_target(sync-gforge-doc
85   COMMAND chmod g+rw -R doc/
86   COMMAND chmod a+rX -R doc/
87   COMMAND ssh scm.gforge.inria.fr mkdir -p /home/groups/simgrid/htdocs/simgrid/${release_version}/html/ || true
88
89   COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times
90   doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/doc/ || true
91
92   COMMAND scp doc/html/simgrid_modules2.png doc/html/simgrid_modules.png doc/webcruft/simgrid_logo_2011.png
93   doc/webcruft/simgrid_logo_2011_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/
94   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
95   )
96 add_dependencies(sync-gforge-doc simgrid_documentation)
97
98 add_custom_target(sync-gforge-dtd
99   COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/simgrid.dtd
100   COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid.dtd
101   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
102   )
103