Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0c46d038534f2a2ac45215b4cd6cf3472887aa11
[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   execute_process(COMMAND ${DOXYGEN_PATH}/doxygen --version OUTPUT_VARIABLE DOXYGEN_VERSION )
9   string(REGEX MATCH "^[0-9]" DOXYGEN_MAJOR_VERSION "${DOXYGEN_VERSION}")
10   string(REGEX MATCH "^[0-9].[0-9]" DOXYGEN_MINOR_VERSION "${DOXYGEN_VERSION}")
11   string(REGEX MATCH "^[0-9].[0-9].[0-9]" DOXYGEN_PATCH_VERSION "${DOXYGEN_VERSION}")
12   string(REGEX REPLACE "^${DOXYGEN_MINOR_VERSION}." "" DOXYGEN_PATCH_VERSION "${DOXYGEN_PATCH_VERSION}")
13   string(REGEX REPLACE "^${DOXYGEN_MAJOR_VERSION}." "" DOXYGEN_MINOR_VERSION "${DOXYGEN_MINOR_VERSION}")
14   message(STATUS "Doxygen version : ${DOXYGEN_MAJOR_VERSION}.${DOXYGEN_MINOR_VERSION}.${DOXYGEN_PATCH_VERSION}")
15
16   set(DOC_PNGS
17     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_modules.png
18     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011.png
19     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011_small.png
20     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/poster_thumbnail.png
21     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_01.png
22     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_02.png
23     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_03.png
24     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_04.png
25     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_05.png
26     ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_06.png
27     )
28
29   configure_file(${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in ${CMAKE_HOME_DIRECTORY}/doc/Doxyfile @ONLY)
30
31   ADD_CUSTOM_TARGET(simgrid_documentation
32     COMMENT "Generating the SimGrid documentation..."
33     DEPENDS ${DOC_SOURCES} ${DOC_FIGS} ${source_doxygen}
34     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_HOME_DIRECTORY}/doc/html
35     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_HOME_DIRECTORY}/doc/html
36     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
37     )
38
39   foreach(file ${DOC_PNGS})
40     ADD_CUSTOM_COMMAND(
41       TARGET simgrid_documentation
42       COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_HOME_DIRECTORY}/doc/html/
43       )
44   endforeach(file ${DOC_PNGS})
45
46   ADD_CUSTOM_COMMAND(TARGET simgrid_documentation
47     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/simgrid.css ${CMAKE_HOME_DIRECTORY}/doc/html/
48     )
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 file"
55     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/index_create.pl simgrid.tag index-API.doc     
56     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen again"
57     COMMAND ${DOXYGEN_PATH}/doxygen Doxyfile
58     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
59     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
60     )
61
62   ADD_CUSTOM_TARGET(pdf
63     COMMAND ${CMAKE_COMMAND} -E echo "XX First pass simgrid_documentation.pdf"
64     COMMAND make clean
65     COMMAND make pdf || true
66     COMMAND ${CMAKE_COMMAND} -E echo "XX Second pass simgrid_documentation.pdf"
67     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf
68     COMMAND make pdf || true
69     COMMAND ${CMAKE_COMMAND} -E echo "XX Write Simgrid_documentation.pdf"
70     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf ${CMAKE_HOME_DIRECTORY}/doc/latex/simgrid_documentation.pdf
71     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/latex/
72     )
73   add_dependencies(pdf simgrid_documentation)
74
75   ADD_CUSTOM_TARGET(error_doxygen
76     COMMAND ${CMAKE_COMMAND} -E echo "Doxygen must be at least version 1.8 to generate documentation"
77     COMMAND false
78     )
79
80   if(DOXYGEN_MAJOR_VERSION STRLESS "2" AND DOXYGEN_MINOR_VERSION STRLESS "8")
81     add_dependencies(simgrid_documentation error_doxygen)
82   endif()
83
84 endif()
85
86 #############################################
87 ### Fill in the "make sync-gforge" target ###
88 #############################################
89
90 add_custom_target(sync-gforge-doc
91   COMMAND chmod g+rw -R doc/
92   COMMAND chmod a+rX -R doc/
93   COMMAND ssh scm.gforge.inria.fr mkdir -p /home/groups/simgrid/htdocs/simgrid/${release_version}/html/ || true
94   COMMAND ssh scm.gforge.inria.fr mkdir -p /home/groups/simgrid/htdocs/simgrid/${release_version}/ref_guide/html/ || true
95
96   COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times
97   doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/doc/ || true
98
99   COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times
100   doc/ref_guide/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/ref_guide/html || true
101
102   COMMAND scp doc/user_guide/html/simgrid_modules2.png doc/user_guide/html/simgrid_modules.png doc/webcruft/simgrid_logo_2011.png
103   doc/webcruft/simgrid_logo_2011_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/
104   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
105   )
106 add_dependencies(sync-gforge-doc simgrid_documentation)
107
108 add_custom_target(sync-gforge-dtd
109   COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/simgrid.dtd
110   COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid.dtd
111   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
112   )
113