Moved genborn.h to mdlib
[gromacs.git] / docs / CMakeLists.txt
blobb4ac8d8d5e0dcdf5588b8fd30232455dc7f6ae37
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 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 # This directory provides a unified place for building all kinds of
36 # GROMACS documentation. This includes some "static" content (Doxygen
37 # code documentation, reference manual, install guide, old online HTML
38 # images), and content generated from the gmx program for the various
39 # tools (man and HTML pages). It also provides the "webpage" target,
40 # that combines all of the above (except man pages in man format) into
41 # a form suitable for automated deployment to the GROMACS website. It
42 # also provides the INSTALL file for the tarball.
44 # The webpage is mostly built by Sphinx.  Variable values for Sphinx
45 # substitutions are configured by CMake (for things like version numbers),
46 # using gmx_configure_version_file().  This happens during build time instead
47 # of configure time, because 1) some of the version variables are only
48 # available during build time, and 2) we don't want to do all the Sphinx setup
49 # during configuration to save some time when not building the content.
50 # All the generated values get put into conf-vars.py (generated from
51 # conf-vars.py.cmakein), which in turn is included by the Sphinx configuration
52 # file conf.py.
54 set(SOURCE_MD5SUM "unknown" CACHE STRING
55     "MD5 sum of the source tarball, normally used only for the pre-release webpage build")
56 # REGRESSIONTEST_MD5SUM is set in cmake/gmxVersionInfo.cmake because it is used also in tests/CMakeLists.txt
57 mark_as_advanced(SOURCE_MD5SUM)
59 set(EXPECTED_DOXYGEN_VERSION 1.8.5)
61 find_package(PythonInterp 2.7)
62 find_package(Sphinx 1.2.3 QUIET COMPONENTS pygments)
64 # Even if we aren't going to make the full webpage, set up to put all
65 # the documentation output in the same place, for convenience
66 set(HTML_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
67 file(MAKE_DIRECTORY ${HTML_OUTPUT_DIR})
69 # The directory from which man pages will be installed; if it remains
70 # empty, they will be silently skipped.
71 set(MAN_PAGE_DIR)
72 if (SOURCE_IS_SOURCE_DISTRIBUTION)
73     # When building from the tarball, install the bundled man pages
74     # (unless overridden).
75     set(MAN_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
76 endif()
78 add_subdirectory(doxygen)
79 add_subdirectory(manual)
81 if (SPHINX_FOUND)
82     # We need to have all the Sphinx input files in a single directory, and
83     # since some of them are generated, we copy everything into the build tree,
84     # to this directory.
85     set(SPHINX_INPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx-input)
86     set(SPHINX_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/conf.py)
87     set(SPHINX_CONFIG_VARS_FILE ${SPHINX_INPUT_DIR}/conf-vars.py)
88     set(SPHINX_EXTENSION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
89     if (SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_TARBALL)
90         # The real build of the webpage happens from the tarball, and
91         # this should be set to the matching MD5 sum.
92         set(REGRESSIONTEST_MD5SUM_STRING "${REGRESSIONTEST_MD5SUM}")
93     else()
94         # But for testing the webpage build (e.g. from the repo) we
95         # need a default value.
96         set(REGRESSIONTEST_MD5SUM_STRING "unknown")
97     endif()
98     set(SPHINX_SOURCE_FILES
99         index.rst
100         download.rst
101         dev-manual/index.rst
102         dev-manual/build-system.rst
103         dev-manual/doxygen.rst
104         dev-manual/formatting.rst
105         dev-manual/gmxtree.rst
106         dev-manual/includestyle.rst
107         dev-manual/jenkins.rst
108         dev-manual/language-features.rst
109         dev-manual/naming.rst
110         dev-manual/overview.rst
111         dev-manual/relocatable-binaries.rst
112         dev-manual/style.rst
113         dev-manual/testutils.rst
114         dev-manual/tools.rst
115         dev-manual/uncrustify.rst
116         fragments/doxygen-links.rst
117         install-guide/index.rst
118         user-guide/index.rst
119         user-guide/getting-started.rst
120         user-guide/flow.rst
121         user-guide/cutoff-schemes.rst
122         user-guide/mdrun-features.rst
123         user-guide/mdrun-performance.rst
124         user-guide/mdp-options.rst
125         user-guide/file-formats.rst
126         user-guide/cmdline.rst
127         user-guide/environment-variables.rst
128         user-guide/plotje.gif
129         user-guide/xvgr.gif
130         conf.py
131         links.dat
132         )
134     # Remove other rst files from the build tree, since they confuse Sphinx.
135     file(GLOB_RECURSE _obsolete_sources RELATIVE ${SPHINX_INPUT_DIR}
136          ${SPHINX_INPUT_DIR}/*.rst)
137     list(REMOVE_ITEM _obsolete_sources ${SPHINX_SOURCE_FILES})
138     foreach(_file ${_obsolete_sources})
139         # Skip generated files in onlinehelp/, and fragments.
140         # The latter do not cause issues with obsolete files, as they
141         # are not considered as Sphinx input files, but will only be
142         # included using an explicit .. include::.
143         if (NOT _file MATCHES "^(onlinehelp|fragments)/.*\\.rst$")
144             message(STATUS "Removing obsolete Sphinx input ${_file}")
145             file(REMOVE ${SPHINX_INPUT_DIR}/${_file})
146         endif()
147     endforeach()
149     gmx_configure_version_file(conf-vars.py.cmakein ${SPHINX_CONFIG_VARS_FILE}
150         EXTRA_VARS
151             SPHINX_EXTENSION_PATH
152             EXPECTED_DOXYGEN_VERSION
153             GMX_CMAKE_MINIMUM_REQUIRED_VERSION REQUIRED_CUDA_VERSION
154             REQUIRED_OPENCL_MIN_VERSION
155             REQUIRED_CUDA_COMPUTE_CAPABILITY REGRESSIONTEST_VERSION
156             SOURCE_MD5SUM REGRESSIONTEST_MD5SUM_STRING
157         COMMENT "Configuring Sphinx configuration file")
158     set(SPHINX_INPUT_FILES ${SPHINX_CONFIG_VARS_FILE})
159     foreach(_file ${SPHINX_SOURCE_FILES})
160         add_custom_command(
161             OUTPUT ${SPHINX_INPUT_DIR}/${_file}
162             COMMAND ${CMAKE_COMMAND} -E copy
163                 ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
164                 ${SPHINX_INPUT_DIR}/${_file}
165             DEPENDS
166                 ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
167             COMMENT "Copying Sphinx input file ${_file}"
168             VERBATIM)
169         list(APPEND SPHINX_INPUT_FILES ${SPHINX_INPUT_DIR}/${_file})
170     endforeach()
171     gmx_add_custom_output_target(sphinx-input OUTPUT STAMP
172         DEPENDS ${SPHINX_INPUT_FILES})
173     # TODO: Make this remove obsolete .rst files.
174     # TODO: This does not work in cross-compilation scenarios; disable up to
175     # the necessary level.
176     gmx_add_custom_output_target(sphinx-programs OUTPUT STAMP
177         COMMAND ${CMAKE_COMMAND} -E make_directory onlinehelp
178         COMMAND gmx -quiet help -export rst
179         DEPENDS gmx
180         WORKING_DIRECTORY ${SPHINX_INPUT_DIR}
181         COMMENT "Generating reStructuredText help")
182     # This dependency ensures that the directories exist before the
183     # executable tries to write things there.
184     add_dependencies(sphinx-programs sphinx-input)
186     # Make the INSTALL file for CPack for the tarball. This gets put
187     # into the tarball via the CPack rules below, which requires that
188     # the INSTALL file is in a separate directory by itself.
189     set(TEXT_INSTALL_GUIDE_OUTPUT_DIR "install-guide/text")
190     add_custom_target(install-guide
191         COMMAND
192             ${SPHINX_EXECUTABLE}
193             -q -b text
194             -w sphinx-install.log
195             -d ${CMAKE_CURRENT_BINARY_DIR}/install-guide/_doctrees
196             -c ${SPHINX_INPUT_DIR}
197             "${SPHINX_INPUT_DIR}/install-guide"
198             "${TEXT_INSTALL_GUIDE_OUTPUT_DIR}"
199         COMMAND
200             ${CMAKE_COMMAND} -E rename
201             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/index.txt
202             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/INSTALL
203         WORKING_DIRECTORY
204             ${CMAKE_CURRENT_BINARY_DIR}
205         COMMENT "Building INSTALL with Sphinx"
206         VERBATIM
207         )
208     add_dependencies(install-guide sphinx-input)
209     gmx_cpack_add_generated_source_directory(install-guide/text DESTINATION /)
211     # Sphinx cache with pickled ReST documents
212     set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
214     add_custom_target(webpage-sphinx
215         COMMAND
216             ${CMAKE_COMMAND} -E make_directory ${SPHINX_INPUT_DIR}/_static
217         COMMAND
218             ${SPHINX_EXECUTABLE}
219             -q -b html
220             -w sphinx-html.log
221             -d "${SPHINX_CACHE_DIR}"
222             "${SPHINX_INPUT_DIR}"
223             "${HTML_OUTPUT_DIR}"
224         WORKING_DIRECTORY
225             ${CMAKE_CURRENT_BINARY_DIR}
226         COMMENT "Building HTML documentation with Sphinx"
227         VERBATIM
228         )
229     add_dependencies(webpage-sphinx sphinx-input sphinx-programs)
231     add_custom_target(man
232         COMMAND
233             ${SPHINX_EXECUTABLE}
234             -q -b man
235             -w sphinx-man.log
236             -d ${SPHINX_CACHE_DIR}
237             -t do_man
238             ${SPHINX_INPUT_DIR}
239             ${CMAKE_CURRENT_BINARY_DIR}/man
240         COMMENT "Building man pages with Sphinx"
241         VERBATIM)
242     add_dependencies(man sphinx-input sphinx-programs)
243     if (GMX_BUILD_HELP)
244         # If requested, install the man pages built by the 'man' target
245         # created above.  Nothing will be installed if the user did not
246         # manually build the target.
247         set(MAN_PAGE_DIR ${CMAKE_CURRENT_BINARY_DIR})
248     endif()
249 else()
250     add_custom_target(webpage-sphinx
251         COMMAND ${CMAKE_COMMAND} -E echo
252             "HTML pages cannot be built because Sphinx is not available"
253         VERBATIM)
254     add_custom_target(install-guide
255         COMMAND ${CMAKE_COMMAND} -E echo
256             "INSTALL cannot be built because Sphinx is not available"
257         VERBATIM)
258     add_custom_target(man
259         COMMAND ${CMAKE_COMMAND} -E echo
260             "man pages cannot be built because Sphinx is not available"
261         VERBATIM)
262 endif()
264 if (MAN_PAGE_DIR)
265     set(MAN_PAGE_DIR ${MAN_PAGE_DIR}/man)
266     # Trailing slash on directory is significant for
267     # install(DIRECTORY). See CMake docs.
268     install(DIRECTORY ${MAN_PAGE_DIR}/
269         DESTINATION ${MAN_INSTALL_DIR}/man1
270         COMPONENT man OPTIONAL
271         FILES_MATCHING PATTERN "*.1")
272     install(DIRECTORY ${MAN_PAGE_DIR}/
273         DESTINATION ${MAN_INSTALL_DIR}/man7
274         COMPONENT man OPTIONAL
275         FILES_MATCHING PATTERN "*.7")
276 endif()
277 gmx_cpack_add_generated_source_directory(man)
279 # Determine whether we can build all the HTML pages and content linked from
280 # there.  If not, construct an informative message if the user tries to
281 # build the target; most people never need to know, unless they've asked for
282 # the webpage build.
283 set(HTML_BUILD_IS_POSSIBLE ON)
284 set(HTML_BUILD_NOT_POSSIBLE_REASON)
285 set(HTML_BUILD_WARNINGS)
287 # Next, turn it off if any of the preconditions are unsatisified
288 if (NOT PYTHON_EXECUTABLE)
289     set(HTML_BUILD_IS_POSSIBLE OFF)
290     set(HTML_BUILD_NOT_POSSIBLE_REASON "Python is required")
291 elseif (NOT SPHINX_FOUND)
292     # Hardly anything gets built if Sphinx is not available, so don't bother.
293     set(HTML_BUILD_IS_POSSIBLE OFF)
294     set(HTML_BUILD_NOT_POSSIBLE_REASON "Sphinx is required")
295 endif()
296 if (NOT MANUAL_BUILD_IS_POSSIBLE)
297     list(APPEND HTML_BUILD_WARNINGS
298          "Reference PDF manual was not built, so links to it do not work")
299 endif()
300 if (NOT DOXYGEN_EXECUTABLE)
301     list(APPEND HTML_BUILD_WARNINGS
302         "Doxygen was not available, so links to Doxygen do not work")
303 endif()
304 if (NOT DOXYGEN_DOT_EXECUTABLE)
305     list(APPEND HTML_BUILD_WARNINGS
306         "dot/graphviz was not found, so some graphs are missing")
307 endif()
309 if (HTML_BUILD_IS_POSSIBLE)
310     set(_webpage_target_properties)
311     if (HTML_BUILD_WARNINGS)
312         list(APPEND _webpage_target_properties
313              COMMAND ${CMAKE_COMMAND} -E echo
314                  "webpage was built, but with the following limitations:")
315         foreach(_warning ${HTML_BUILD_WARNINGS})
316         list(APPEND _webpage_target_properties
317              COMMAND ${CMAKE_COMMAND} -E echo " - ${_warning}")
318         endforeach()
319     endif()
321     if (MANUAL_BUILD_IS_POSSIBLE)
322         # Make the PDF reference guide
323         # TODO Try to make the PDF arrive directly in ${HTML_OUTPUT_DIR}
324         # TODO Make this depend on the output of the manual build, so that the
325         # file actually gets copied multiple times.
326         set(_manual_target_location ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf)
327         add_custom_command(
328             OUTPUT ${_manual_target_location}
329             COMMAND ${CMAKE_COMMAND}
330                 -E remove -f ${_manual_target_location}
331             COMMAND ${CMAKE_COMMAND}
332                 -E copy ${CMAKE_CURRENT_BINARY_DIR}/manual/gromacs.pdf ${_manual_target_location}
333             DEPENDS manual
334             VERBATIM)
335         list(APPEND _webpage_target_properties
336              DEPENDS ${_manual_target_location})
337     endif()
339     # The Doxygen configuration in doxygen/Doxyfile-common.cmakein
340     # makes all the Doxygen output directly in
341     # ${HTML_OUTPUT_DIR}/doxygen (and makes the directory if it needs
342     # to).
344     # Add a top-level target that builds everything related to the webpage,
345     # for Jenkins (and possibly others) to use
346     add_custom_target(webpage ${_webpage_target_properties}
347         COMMENT "Building webpage"
348         VERBATIM)
349     add_dependencies(webpage webpage-sphinx doxygen-all)
350 else()
351     add_custom_target(webpage
352         COMMAND ${CMAKE_COMMAND} -E echo
353             "Cannot build webpage because ${HTML_BUILD_NOT_POSSIBLE_REASON}"
354         COMMENT "Webpage build not possible"
355         VERBATIM)
356 endif()