Logo AND Algorithmique Numérique Distribuée

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