Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3d01654d0fc8f13d2fbe26aeb57522a90b74474c
[simgrid.git] / buildtools / Cmake / GenerateDoc.cmake
1 #### Generate the whole html documentation
2
3 if (enable_documentation)
4   find_package(Doxygen REQUIRED)
5   set(DocAll "ALL")
6 else()
7   find_package(Doxygen)
8 endif()
9
10 find_path(JAVADOC_PATH  NAMES javadoc   PATHS NO_DEFAULT_PATHS)
11 find_path(FIG2DEV_PATH  NAMES fig2dev  PATHS NO_DEFAULT_PATHS)
12 mark_as_advanced(JAVADOC_PATH)
13
14 if(DOXYGEN_FOUND)
15
16   ADD_CUSTOM_TARGET(doc ${DocAll}
17     COMMENT "Generating the SimGrid documentation..."
18     DEPENDS ${DOC_SOURCES} ${DOC_FIGS} ${source_doxygen}
19     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_HOME_DIRECTORY}/doc/html
20     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_HOME_DIRECTORY}/doc/html
21     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
22     )
23
24   message(STATUS "Doxygen version: ${DOXYGEN_VERSION}")
25
26   if(DOXYGEN_VERSION VERSION_LESS "1.8")
27     ADD_CUSTOM_TARGET(error_doxygen
28       COMMAND ${CMAKE_COMMAND} -E echo "Doxygen must be at least version 1.8 to generate documentation"
29       COMMAND false
30     )
31
32     add_dependencies(doc error_doxygen)
33   endif()
34
35   configure_file(${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in ${CMAKE_HOME_DIRECTORY}/doc/Doxyfile @ONLY)
36
37   foreach(file ${DOC_FIGS})
38     string(REPLACE ".fig" ".png" tmp_file ${file})
39     string(REPLACE "${CMAKE_HOME_DIRECTORY}/doc/shared/fig/" "${CMAKE_HOME_DIRECTORY}/doc/html/" tmp_file ${tmp_file})
40     ADD_CUSTOM_COMMAND(TARGET doc
41       COMMAND ${FIG2DEV_PATH}/fig2dev -Lpng -S 4 ${file} ${tmp_file}
42       )
43   endforeach()
44
45   foreach(file ${DOC_IMG})
46     ADD_CUSTOM_COMMAND(
47       TARGET doc
48       COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_HOME_DIRECTORY}/doc/html/
49     )
50   endforeach()
51
52   ADD_CUSTOM_COMMAND(TARGET doc
53     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
54     COMMAND pwd
55     COMMAND ${CMAKE_COMMAND} -E tar czf html/msg-tuto-src.tgz msg-tuto-src/
56     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen"
57     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
58     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate the index files"
59     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/index_create.pl simgrid.tag index-API.doc
60     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
61     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl > ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
62     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen again"
63     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
64     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
65     COMMAND ${CMAKE_COMMAND} -E echo "XX Javadoc pass"
66     COMMAND ${JAVADOC_PATH}/javadoc -quiet -d ${CMAKE_HOME_DIRECTORY}/doc/html/javadoc/ ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*.java ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*/*.java
67     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
68     )
69
70   ADD_CUSTOM_TARGET(pdf
71     COMMAND ${CMAKE_COMMAND} -E echo "XX First pass simgrid_documentation.pdf"
72     COMMAND make clean
73     COMMAND make pdf || true
74     COMMAND ${CMAKE_COMMAND} -E echo "XX Second pass simgrid_documentation.pdf"
75     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf
76     COMMAND make pdf || true
77     COMMAND ${CMAKE_COMMAND} -E echo "XX Write Simgrid_documentation.pdf"
78     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf ${CMAKE_HOME_DIRECTORY}/doc/latex/simgrid_documentation.pdf
79     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/latex/
80     )
81   add_dependencies(pdf doc)
82
83
84
85
86 #############################################
87 ### Fill in the "make sync-gforge" target ###
88 #############################################
89
90 set(RSYNC_CMD rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --times --omit-dir-times --perms --chmod=a+rX,ug+w,o-w,Dg+s)
91
92 add_custom_target(sync-gforge-doc
93   COMMAND ssh scm.gforge.inria.fr mkdir -p -m 2775 /home/groups/simgrid/htdocs/simgrid/${release_version}/ || true
94
95   COMMAND ${RSYNC_CMD} doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/doc/ || true
96
97   COMMAND ${RSYNC_CMD} doc/html/simgrid_modules2.png doc/html/simgrid_modules.png doc/webcruft/simgrid_logo_2011.png
98   doc/webcruft/simgrid_logo_2011_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/
99
100   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
101   )
102 add_dependencies(sync-gforge-doc doc)
103
104 add_custom_target(sync-gforge-dtd
105   COMMAND ${RSYNC_CMD} src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/simgrid.dtd
106   COMMAND ${RSYNC_CMD} src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid.dtd
107   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
108   )
109   
110 endif()
111