Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixed cmake/doxygen errors on old systems.
[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   # This is a workaround for older cmake versions
27   # (such as 2.8.7 on Ubuntu 12.04). These cmake versions do not provide the
28   # DOXYGEN_VERSION variable and hence, building the documentation will always
29   # fail. This code is the same as used in the cmake library, version 3.
30   if(DOXYGEN_EXECUTABLE)
31     execute_process(COMMAND ${DOXYGEN_EXECUTABLE} "--version" OUTPUT_VARIABLE DOXYGEN_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
32   endif()
33
34   if(DOXYGEN_VERSION VERSION_LESS "1.8")
35     ADD_CUSTOM_TARGET(error_doxygen
36         COMMAND ${CMAKE_COMMAND} -E echo "Doxygen must be at least version 1.8 to generate documentation. Version found: ${DOXYGEN_VERSION}"
37       COMMAND false
38     )
39
40     add_dependencies(doc error_doxygen)
41   endif()
42
43   configure_file(${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in ${CMAKE_HOME_DIRECTORY}/doc/Doxyfile @ONLY)
44
45   foreach(file ${DOC_FIGS})
46     string(REPLACE ".fig" ".png" tmp_file ${file})
47     string(REPLACE "${CMAKE_HOME_DIRECTORY}/doc/shared/fig/" "${CMAKE_HOME_DIRECTORY}/doc/html/" tmp_file ${tmp_file})
48     ADD_CUSTOM_COMMAND(TARGET doc
49       COMMAND ${FIG2DEV_PATH}/fig2dev -Lpng -S 4 ${file} ${tmp_file}
50       )
51   endforeach()
52
53   foreach(file ${DOC_IMG})
54     ADD_CUSTOM_COMMAND(
55       TARGET doc
56       COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_HOME_DIRECTORY}/doc/html/
57     )
58   endforeach()
59
60   ADD_CUSTOM_COMMAND(TARGET doc
61     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
62     COMMAND pwd
63     COMMAND ${CMAKE_COMMAND} -E tar czf html/msg-tuto-src.tgz msg-tuto-src/
64     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen"
65     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
66     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate the index files"
67     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/index_create.pl simgrid.tag index-API.doc
68     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
69     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl > ${CMAKE_HOME_DIRECTORY}/doc/doxygen/logcategories.doc
70     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen again"
71     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
72     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
73     COMMAND ${CMAKE_COMMAND} -E echo "XX Javadoc pass"
74     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
75     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
76     )
77
78   ADD_CUSTOM_TARGET(pdf
79     COMMAND ${CMAKE_COMMAND} -E echo "XX First pass simgrid_documentation.pdf"
80     COMMAND make clean
81     COMMAND make pdf || true
82     COMMAND ${CMAKE_COMMAND} -E echo "XX Second pass simgrid_documentation.pdf"
83     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf
84     COMMAND make pdf || true
85     COMMAND ${CMAKE_COMMAND} -E echo "XX Write Simgrid_documentation.pdf"
86     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf ${CMAKE_HOME_DIRECTORY}/doc/latex/simgrid_documentation.pdf
87     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/latex/
88     )
89   add_dependencies(pdf doc)
90
91
92
93
94 #############################################
95 ### Fill in the "make sync-gforge" target ###
96 #############################################
97
98 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)
99
100 add_custom_target(sync-gforge-doc
101   COMMAND ssh scm.gforge.inria.fr mkdir -p -m 2775 /home/groups/simgrid/htdocs/simgrid/${release_version}/ || true
102
103   COMMAND ${RSYNC_CMD} doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/doc/ || true
104
105   COMMAND ${RSYNC_CMD} doc/html/simgrid_modules2.png doc/html/simgrid_modules.png doc/webcruft/simgrid_logo_2011.png
106   doc/webcruft/simgrid_logo_2011_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/
107
108   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
109   )
110 add_dependencies(sync-gforge-doc doc)
111
112 add_custom_target(sync-gforge-dtd
113   COMMAND ${RSYNC_CMD} src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/simgrid.dtd
114   COMMAND ${RSYNC_CMD} src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid.dtd
115   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
116   )
117
118 endif()
119