2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 include(gmxCustomCommandUtilities)
36 include(gmxOptionUtilities)
38 find_package(Doxygen QUIET)
40 # This logic closely follows that found in FindDoxygen.cmake for dot,
41 # except that the PATH variable is not cached.
42 find_program(DOXYGEN_MSCGEN_EXECUTABLE
44 DOC "Message sequence chart renderer tool (http://www.mcternan.me.uk/mscgen/)")
45 if (DOXYGEN_MSCGEN_EXECUTABLE)
46 set(DOXYGEN_MSCGEN_FOUND TRUE)
47 get_filename_component(DOXYGEN_MSCGEN_PATH "${DOXYGEN_MSCGEN_EXECUTABLE}" PATH)
49 mark_as_advanced(DOXYGEN_MSCGEN_EXECUTABLE)
54 "Skip parts of Doxygen documentation (in particular, many graphs) to save disk space and time"
57 mark_as_advanced(GMX_COMPACT_DOXYGEN)
59 find_package(PythonInterp)
60 set(USE_PYTHON_SCRIPTS OFF)
61 if (PYTHONINTERP_FOUND AND NOT PYTHON_VERSION_STRING VERSION_LESS "2.6")
62 set(USE_PYTHON_SCRIPTS ON)
65 # Note that if you relocate this file, you also need to change gmxtree.py.
66 # TODO: Try to find a solution where this would be hard-coded here, completely
67 # separate from the logic that generates it.
68 set(INSTALLED_HEADERS_FILE ${PROJECT_BINARY_DIR}/src/gromacs/installed-headers.txt)
70 ########################################################################
71 # Doxygen configuration
74 # Generate Doxygen input configuration files
75 file(GLOB NB_KERNEL_DIRS
76 ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_*/)
77 list(REMOVE_ITEM NB_KERNEL_DIRS
78 ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_c)
79 foreach (dir ${NB_KERNEL_DIRS})
80 SET(NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN
81 "${NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN} \\\n ${dir}")
83 set(DEPGRAPH_DIR ${CMAKE_CURRENT_BINARY_DIR}/depgraphs)
84 set(DOXYGEN_SECTIONS "")
85 set(DOXYGEN_EXTRA_SETTINGS "")
86 if (GMX_COMPACT_DOXYGEN)
87 set(DOXYGEN_EXTRA_SETTINGS "@INCLUDE = ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-compact")
89 configure_file(Doxyfile-common.cmakein Doxyfile-common)
90 configure_file(Doxyfile-full.cmakein Doxyfile-full)
91 configure_file(Doxyfile-lib.cmakein Doxyfile-lib)
92 configure_file(Doxyfile-user.cmakein Doxyfile-user)
93 configure_file(Doxyfile-xml.cmakein Doxyfile-xml)
95 configure_file(RunDoxygen.cmake.cmakein RunDoxygen.cmake @ONLY)
96 gmx_configure_version_file(Doxyfile-version.cmakein Doxyfile-version
97 TARGET doxygen-version)
99 # Add a stamp that gets updated whenever a source file that contributes to
100 # Doxygen is updated. All Doxygen targets can then depend on this stamp,
101 # instead of each specifying this massive set of dependencies.
102 # TODO: The set of files that affects Doxygen is not exactly the same as
103 # that which affects the dependency graphs, and neither is captured
104 # perfectly with this set, but this can be improved if it becomes a real
105 # issue (the differences are mainly in the generated group kernel files,
106 # but there are some minor other differences as well).
107 if (SOURCE_IS_GIT_REPOSITORY AND GIT_FOUND)
108 gmx_get_files_with_gitattribute(doxygen_sources gmx-doxygen)
109 # Add also common configuration files that influence the generation.
111 ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-common
112 ${CMAKE_CURRENT_BINARY_DIR}/RunDoxygen.cmake)
113 if (GMX_COMPACT_DOXYGEN)
114 list(APPEND doxygen_deps ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-compact)
116 gmx_add_custom_output_target(doxygen-source-timestamp
118 DEPENDS_FILE_LIST doxygen_sources
119 DEPENDS ${doxygen_deps}
120 COMMENT "Updating Doxygen source timestamp")
122 # If there is no git, we just update the stamp every time, and the
123 # builds are triggered every time. This should be rare enough, but
124 # this case still needs to be supported for the Jenkins job that builds
125 # the documentation for a release from the release tarball.
126 gmx_add_custom_output_target(doxygen-source-timestamp
127 RUN_ALWAYS OUTPUT STAMP
128 COMMENT "Updating Doxygen source timestamp")
131 # Helper function to create a Doxygen build target
132 function (add_doxygen_target TARGET TYPE COMMENT)
133 set(_deps doxygen-source-timestamp doxygen-version
134 ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-${TYPE})
136 if ("${ARGN}" STREQUAL "DEPGRAPHS")
137 set(_fast_arg "ADD_FAST_TARGET")
138 if (TARGET dep-graphs-dot)
139 list(APPEND _deps dep-graphs-dot)
142 gmx_add_custom_output_target(${TARGET} OUTPUT STAMP ${_fast_arg}
143 # Ensure the directory exists to avoid spurious warnings
144 COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPGRAPH_DIR}
145 COMMAND ${CMAKE_COMMAND} -DDOCTYPE=${TYPE} -P RunDoxygen.cmake
147 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
148 COMMENT "${COMMENT}")
150 add_dependencies(${TARGET}-fast doxygen-version)
154 # The XML target is necessary for the dependency graphs
155 add_doxygen_target(doxygen-xml xml "Extracting Doxygen documentation to XML")
157 # Add targets for generating the dependency graphs; they are necessary for
158 # the full and lib variants of the documentation.
159 if (USE_PYTHON_SCRIPTS)
160 # Add target that generates .dot files for the dependency graphs.
161 # The output also depends on the Doxygen source files, but the
162 # dependency on doxygen-xml takes care of that transitively.
163 gmx_add_custom_output_target(dep-graphs-dot ADD_FAST_TARGET
165 COMMAND ${PYTHON_EXECUTABLE}
166 ${CMAKE_CURRENT_SOURCE_DIR}/graphbuilder.py
167 -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
168 --ignore-cycles ${CMAKE_CURRENT_SOURCE_DIR}/cycle-suppressions.txt
170 DEPENDS doxygen-xml ${INSTALLED_HEADER_FILE}
171 ${CMAKE_CURRENT_SOURCE_DIR}/doxygenxml.py
172 ${CMAKE_CURRENT_SOURCE_DIR}/gmxtree.py
173 ${CMAKE_CURRENT_SOURCE_DIR}/graphbuilder.py
174 ${CMAKE_CURRENT_SOURCE_DIR}/cycle-suppressions.txt
175 COMMENT "Generating include dependency graphs for dot")
177 # Add separate targets for converting the .dot files to .png.
178 # These are not needed by the Doxygen targets, but are useful for
179 # investigating just the graphs.
180 set(dep_graphs_command_dot
181 ${CMAKE_COMMAND} -DGRAPHDIR=${DEPGRAPH_DIR}
182 -DDOT_EXECUTABLE=${DOXYGEN_DOT_EXECUTABLE}
183 -P ${CMAKE_CURRENT_SOURCE_DIR}/generateGraphs.cmake)
184 add_custom_target(dep-graphs COMMAND ${dep_graphs_command_dot}
185 COMMENT "Generating PNG include dependency graphs" VERBATIM)
186 add_custom_target(dep-graphs-fast COMMAND ${dep_graphs_command_dot}
187 COMMENT "Generating PNG include dependency graphs" VERBATIM)
188 add_dependencies(dep-graphs dep-graphs-dot)
189 add_dependencies(dep-graphs-fast dep-graphs-dot-fast)
192 # Create the actual targets to build the documentation.
193 add_doxygen_target(doxygen-full full "Generating full documentation with Doxygen" DEPGRAPHS)
194 add_doxygen_target(doxygen-lib lib "Generating library documentation with Doxygen" DEPGRAPHS)
195 add_doxygen_target(doxygen-user user "Generating public API documentation with Doxygen")
196 # Convenience targets to build all the documentation flavors.
197 add_custom_target(doxygen-all)
198 add_custom_target(doxygen-all-fast)
199 add_dependencies(doxygen-all doxygen-full doxygen-lib doxygen-user)
200 add_dependencies(doxygen-all-fast doxygen-full-fast doxygen-lib-fast doxygen-user)
202 # Finally, create the check-source target.
203 if (USE_PYTHON_SCRIPTS)
204 # TODO: Consider whether this is the best location for this code,
205 # since not all of it is Doxygen-specific (but nearly all of it
206 # relies on the Doxygen XML documentation).
207 # The output .log file currently needs to be here, since Jenkins
209 set(check_source_command
210 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check-source.py
211 -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
212 -l ${CMAKE_CURRENT_BINARY_DIR}/check-source.log
213 --ignore ${CMAKE_CURRENT_SOURCE_DIR}/suppressions.txt
214 --ignore-cycles ${CMAKE_CURRENT_SOURCE_DIR}/cycle-suppressions.txt)
215 add_custom_target(check-source COMMAND ${check_source_command}
216 COMMENT "Checking source code for various issues" VERBATIM)
217 add_custom_target(check-source-fast COMMAND ${check_source_command}
218 COMMENT "Checking source code for various issues" VERBATIM)
219 add_dependencies(check-source doxygen-xml)
222 function (add_disabled_doxygen_target TARGET)
223 add_custom_target(${TARGET}
224 COMMAND ${CMAKE_COMMAND} -E echo
225 "Cannot build/run target ${TARGET} because Doxygen is not available"
226 COMMENT "Doxygen not available" VERBATIM)
228 add_disabled_doxygen_target(doxygen-all)
229 add_disabled_doxygen_target(doxygen-all-fast)
230 add_disabled_doxygen_target(doxygen-xml)
231 add_disabled_doxygen_target(doxygen-user)
232 add_disabled_doxygen_target(doxygen-lib)
233 add_disabled_doxygen_target(doxygen-lib-fast)
234 add_disabled_doxygen_target(doxygen-full)
235 add_disabled_doxygen_target(doxygen-full-fast)
236 add_disabled_doxygen_target(check-source)
237 add_disabled_doxygen_target(check-source-fast)
238 add_disabled_doxygen_target(dep-graphs)
239 add_disabled_doxygen_target(dep-graphs-fast)