Logo AND Algorithmique Numérique Distribuée

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