Fix zlib usage with TNG
[alexxy/gromacs.git] / docs / doxygen / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2012,2013,2014, 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.
8 #
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.
13 #
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.
18 #
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.
23 #
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.
31 #
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.
34
35 include(gmxOptionUtilities)
36
37 find_package(Doxygen QUIET)
38 if (DOXYGEN_FOUND)
39     # This logic closely follows that found in FindDoxygen.cmake for dot,
40     # except that the PATH variable is not cached.
41     FIND_PROGRAM(DOXYGEN_MSCGEN_EXECUTABLE
42         NAMES mscgen
43         DOC "Message sequence chart renderer tool (http://www.mcternan.me.uk/mscgen/)")
44     if (DOXYGEN_MSCGEN_EXECUTABLE)
45         set(DOXYGEN_MSCGEN_FOUND TRUE)
46         get_filename_component(DOXYGEN_MSCGEN_PATH "${DOXYGEN_MSCGEN_EXECUTABLE}" PATH)
47     endif()
48     mark_as_advanced(DOXYGEN_MSCGEN_EXECUTABLE)
49 endif()
50
51 gmx_dependent_option(
52     GMX_COMPACT_DOXYGEN
53     "Skip parts of Doxygen documentation (in particular, many graphs) to save disk space and time"
54     OFF
55     DOXYGEN_FOUND)
56 mark_as_advanced(GMX_COMPACT_DOXYGEN)
57
58 find_package(PythonInterp)
59 set(USE_PYTHON_SCRIPTS OFF)
60 if (PYTHONINTERP_FOUND AND NOT PYTHON_VERSION_STRING VERSION_LESS "2.6")
61     set(USE_PYTHON_SCRIPTS ON)
62 endif()
63
64 add_custom_target(find-installed-headers
65     COMMAND ${CMAKE_COMMAND}
66         -D SRCDIR=${CMAKE_SOURCE_DIR}
67         -D BUILDDIR=${CMAKE_BINARY_DIR}
68         -D OUTFILE=${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt
69         -P ${CMAKE_CURRENT_SOURCE_DIR}/getInstalledHeaders.cmake
70     COMMENT "Generating installed headers list" VERBATIM)
71
72 ########################################################################
73 # Doxygen configuration
74 ########################################################################
75 if (DOXYGEN_FOUND)
76     FILE(GLOB NB_KERNEL_DIRS
77          ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_*/)
78     LIST(REMOVE_ITEM NB_KERNEL_DIRS
79          ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_c)
80     FOREACH(NB_KERNEL_DIR ${NB_KERNEL_DIRS})
81         SET(NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN
82             "${NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN} \\\n                         ${NB_KERNEL_DIR}")
83     ENDFOREACH(NB_KERNEL_DIR)
84     set(DOXYGEN_SECTIONS "")
85     CONFIGURE_FILE(Doxyfile-common.cmakein Doxyfile-common)
86     CONFIGURE_FILE(Doxyfile-full.cmakein Doxyfile-full)
87     CONFIGURE_FILE(Doxyfile-lib.cmakein Doxyfile-lib)
88     CONFIGURE_FILE(Doxyfile-user.cmakein Doxyfile-user)
89     CONFIGURE_FILE(Doxyfile-xml.cmakein Doxyfile-xml)
90
91     if (GMX_COMPACT_DOXYGEN)
92         FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-common
93              "@INCLUDE   = ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-compact\n")
94     endif()
95
96     configure_file(RunDoxygen.cmake.cmakein RunDoxygen.cmake @ONLY)
97     add_custom_target(doc-full
98         ${CMAKE_COMMAND} -DDOCTYPE=full -P RunDoxygen.cmake
99         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
100         COMMENT "Generating full documentation with Doxygen" VERBATIM)
101     add_custom_target(doc-lib
102         ${CMAKE_COMMAND} -DDOCTYPE=lib -P RunDoxygen.cmake
103         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
104         COMMENT "Generating library documentation with Doxygen" VERBATIM)
105     add_custom_target(doc-user
106         ${CMAKE_COMMAND} -DDOCTYPE=user -P RunDoxygen.cmake
107         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
108         COMMENT "Generating public API documentation with Doxygen" VERBATIM)
109     add_custom_target(doc-xml
110         ${CMAKE_COMMAND} -DDOCTYPE=xml -P RunDoxygen.cmake
111         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
112         COMMENT "Extracting Doxygen documentation to XML" VERBATIM)
113     add_custom_target(doc-all)
114     add_dependencies(doc-all doc-full doc-lib doc-user)
115
116     if (GMX_GIT_VERSION_INFO)
117         add_custom_target(doxygen-version
118                 COMMAND ${CMAKE_COMMAND}
119                     -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
120                     -D PROJECT_VERSION="${PROJECT_VERSION}"
121                     -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
122                     -D VERSION_CMAKEIN="${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-version.cmakein"
123                     -D VERSION_OUT="${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-version"
124                     -D VERSION_NO_REMOTE_HASH=
125                     -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
126                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
127                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-version.cmakein
128                 COMMENT "Generating version information for Doxygen")
129         add_dependencies(doc-full doxygen-version)
130         add_dependencies(doc-lib doxygen-version)
131         add_dependencies(doc-user doxygen-version)
132         add_dependencies(doc-xml doxygen-version)
133     else()
134         set(GMX_PROJECT_VERSION_STR ${PROJECT_VERSION})
135         configure_file(Doxyfile-version.cmakein Doxyfile-version)
136     endif()
137
138     if (USE_PYTHON_SCRIPTS)
139         # TODO: Consider whether this is the best name and location for this
140         # code, since not all of it is Doxygen-specific (but nearly all of it
141         # relies on the Doxygen XML documentation).
142         set(doc_check_command
143             ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen-check.py
144             -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
145             --installed ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt
146             -l ${CMAKE_CURRENT_BINARY_DIR}/doxygen-check.log
147             --ignore ${CMAKE_CURRENT_SOURCE_DIR}/suppressions.txt)
148         add_custom_target(doc-check COMMAND ${doc_check_command}
149             COMMENT "Checking Doxygen documentation" VERBATIM)
150         add_dependencies(doc-check doc-xml find-installed-headers)
151
152         set(graphdir ${CMAKE_CURRENT_BINARY_DIR}/depgraphs)
153         set(dep_graphs_command_python
154             ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/graphbuilder.py
155             -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
156             --installed ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt
157             -o ${CMAKE_CURRENT_BINARY_DIR}/depgraphs)
158         set(dep_graphs_command_dot
159             ${CMAKE_COMMAND} -DGRAPHDIR=${graphdir}
160             -DDOT_EXECUTABLE=${DOXYGEN_DOT_EXECUTABLE}
161             -P ${CMAKE_CURRENT_SOURCE_DIR}/generateGraphs.cmake)
162         add_custom_target(dep-graphs
163             COMMAND ${dep_graphs_command_python}
164             COMMAND ${dep_graphs_command_dot}
165             COMMENT "Generating include dependency graphs" VERBATIM)
166         add_dependencies(dep-graphs doc-xml find-installed-headers)
167
168         # These targets are the same as above, but they don't rerun the
169         # dependencies each time, making it faster and more convenient for
170         # testing.
171         add_custom_target(doc-check-fast COMMAND ${doc_check_command}
172             COMMENT "Checking Doxygen documentation" VERBATIM)
173         add_custom_target(dep-graphs-fast
174             COMMAND ${dep_graphs_command_python}
175             COMMAND ${dep_graphs_command_dot}
176             COMMENT "Generating include dependency graphs" VERBATIM)
177     endif()
178 endif()