Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
provide a backtrace implementation that uses boost.stacktrace
[simgrid.git] / tools / cmake / Documentation.cmake
1 ###
2 ### Generate all parts of the documentation on non-Windows systems
3 ###
4 ###   - HTML with doxygen (reference and manual)
5 ###   - Javadoc (reference)
6 ###   - manpages (reference of tools)
7 ###
8 ###  This file is not loaded on windows
9
10 #### Generate the html documentation
11 if (enable_documentation)
12   find_package(Doxygen REQUIRED)
13 else()
14   find_package(Doxygen)
15 endif()
16
17 find_path(FIG2DEV_PATH  NAMES fig2dev  PATHS NO_DEFAULT_PATHS)
18
19 if(enable_documentation)
20   ADD_CUSTOM_TARGET(documentation
21     COMMENT "Generating the SimGrid documentation..."
22     DEPENDS ${DOC_SOURCES} ${DOC_FIGS} ${source_doxygen}
23     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_BINARY_DIR}/doc/doxygen
24     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_BINARY_DIR}/doc/example_lists
25     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/doc/html
26     COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_BINARY_DIR}/doc/html
27     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/doc/xml
28     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/docs/source/api
29     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
30     )
31
32   message(STATUS "Doxygen version: ${DOXYGEN_VERSION}")
33
34   # This is a workaround for older cmake versions (such as 2.8.7 on Ubuntu 12.04). These cmake versions do not provide
35   # the DOXYGEN_VERSION variable and hence, building the documentation will always  fail. This code is the same as used
36   # in the cmake library, version 3.
37   if(DOXYGEN_EXECUTABLE)
38     execute_process(COMMAND ${DOXYGEN_EXECUTABLE} "--version" OUTPUT_VARIABLE DOXYGEN_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
39   endif()
40
41   if(DOXYGEN_VERSION VERSION_LESS "1.8")
42     ADD_CUSTOM_TARGET(error_doxygen
43         COMMAND ${CMAKE_COMMAND} -E echo "Doxygen must be at least version 1.8 to generate documentation. Version found: ${DOXYGEN_VERSION}"
44       COMMAND false
45     )
46     add_dependencies(documentation error_doxygen)
47   endif()
48
49   configure_file(${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in ${CMAKE_BINARY_DIR}/doc/Doxyfile @ONLY)
50
51   foreach(file ${DOC_FIGS})
52     string(REPLACE ".fig" ".png" tmp_file ${file})
53     string(REPLACE "${CMAKE_HOME_DIRECTORY}/doc/shared/fig/" "${CMAKE_BINARY_DIR}/doc/html/" tmp_file ${tmp_file})
54     ADD_CUSTOM_COMMAND(TARGET documentation  COMMAND ${FIG2DEV_PATH}/fig2dev -Lpng -S 4 ${file} ${tmp_file})
55   endforeach()
56
57   foreach(file ${DOC_IMG})
58     ADD_CUSTOM_COMMAND(TARGET documentation COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_BINARY_DIR}/doc/html/)
59   endforeach()
60
61   ADD_CUSTOM_COMMAND(TARGET documentation
62     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_BINARY_DIR}/doc/simgrid_modules.map
63     COMMAND pwd
64     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate the index files"
65     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/doc/doxygen/logcategories.doc
66     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl ${CMAKE_HOME_DIRECTORY} > ${CMAKE_BINARY_DIR}/doc/doxygen/logcategories.doc
67     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate list of files in examples/ for routing models"
68     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc/example_lists/
69     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh Floyd > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_floyd
70     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh Dijkstra > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_dijkstra
71     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh DijkstraCache > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_dijkstra_cache
72     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh 'routing="None"' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_none
73     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh 'routing="Cluster"' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_cluster
74     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh 'routing="Vivaldi"' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_vivaldi
75     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh 'routing="Full"' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_routing_full
76     COMMAND ${CMAKE_COMMAND} -E echo "XX Generate list of files in examples/ for XML tags"
77     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh '<mount ' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_xmltag_mount
78     COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/list_routing_models_examples.sh '<link_ctn ' > ${CMAKE_BINARY_DIR}/doc/example_lists/example_filelist_xmltag_linkctn
79     COMMAND ${CMAKE_COMMAND} -E echo "XX Run doxygen"
80     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
81     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/doc/simgrid_modules.map
82     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
83     )
84
85 ### Fill in the "make gforge-sync" target ###
86
87 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)
88
89 add_custom_target(gforge-sync
90   COMMAND ssh scm.gforge.inria.fr mkdir -p -m 2775 /home/groups/simgrid/htdocs/simgrid/${release_version}/ || true
91
92   COMMAND ${RSYNC_CMD} doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/doc/ || true
93
94   COMMAND ${RSYNC_CMD} doc/html/simgrid_modules2.png doc/html/simgrid_modules.png /${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011.png
95   /${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/
96
97   COMMAND ${RSYNC_CMD} ${CMAKE_HOME_DIRECTORY}/src/surf/xml/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/
98   COMMAND ${RSYNC_CMD} ${CMAKE_HOME_DIRECTORY}/src/surf/xml/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid/${release_version}/simgrid.dtd
99
100   WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
101   )
102 add_dependencies(gforge-sync documentation)
103
104 else(enable_documentation)
105   ADD_CUSTOM_TARGET(documentation
106     COMMENT "The generation of the SimGrid documentation was disabled in cmake"
107     )
108 endif(enable_documentation)
109
110 if (Java_FOUND)
111   find_path(JAVADOC_PATH  NAMES javadoc   PATHS NO_DEFAULT_PATHS)
112   mark_as_advanced(JAVADOC_PATH)
113
114   ADD_CUSTOM_COMMAND(TARGET documentation
115     COMMAND ${CMAKE_COMMAND} -E echo "XX Javadoc pass"
116     COMMAND ${JAVADOC_PATH}/javadoc -quiet -d ${CMAKE_BINARY_DIR}/doc/html/javadoc/ ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*.java ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*/*.java
117     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
118   )
119 endif()
120
121 #### Generate the manpages
122 if( NOT MANPAGE_DIR)
123   set( MANPAGE_DIR ${CMAKE_BINARY_DIR}/manpages )
124 endif()
125
126 add_custom_target(manpages ALL
127   COMMAND ${CMAKE_COMMAND} -E make_directory ${MANPAGE_DIR}
128   COMMAND pod2man ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl > ${MANPAGE_DIR}/simgrid_update_xml.1
129   COMMAND pod2man ${CMAKE_HOME_DIRECTORY}/docs/manpages/tesh.pod > ${MANPAGE_DIR}/tesh.1
130   COMMENT "Generating manpages"
131   )
132 install(FILES
133   ${MANPAGE_DIR}/simgrid_update_xml.1
134   ${MANPAGE_DIR}/tesh.1
135   ${CMAKE_HOME_DIRECTORY}/docs/manpages/smpicc.1
136   ${CMAKE_HOME_DIRECTORY}/docs/manpages/smpicxx.1
137   ${CMAKE_HOME_DIRECTORY}/docs/manpages/smpif90.1
138   ${CMAKE_HOME_DIRECTORY}/docs/manpages/smpiff.1
139   ${CMAKE_HOME_DIRECTORY}/docs/manpages/smpirun.1
140   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/man/man1)