Add missing mass term to deltaH
[alexxy/gromacs.git] / docs / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2014,2015,2016,2017,2018, 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 # 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.
43 #
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.
53
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)
58
59 set(EXPECTED_DOXYGEN_VERSION 1.8.5)
60
61 set(EXPECTED_SPHINX_VERSION 1.4.1)
62
63 if (DEFINED PYTHON_EXECUTABLE)
64     # Keep quiet on subsequent runs of cmake
65     set(PythonInterp_FIND_QUIETLY ON)
66 endif()
67 find_package(PythonInterp 2.7)
68 find_package(Sphinx ${EXPECTED_SPHINX_VERSION} QUIET COMPONENTS pygments)
69
70 # Even if we aren't going to make the full webpage, set up to put all
71 # the documentation output in the same place, for convenience
72 set(HTML_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
73 file(MAKE_DIRECTORY ${HTML_OUTPUT_DIR})
74
75 # The directory from which man pages will be installed; if it remains
76 # empty, they will be silently skipped.
77 set(MAN_PAGE_DIR)
78 if (SOURCE_IS_SOURCE_DISTRIBUTION)
79     # When building from the tarball, install the bundled man pages
80     # (unless overridden).
81     set(MAN_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
82 endif()
83
84 add_subdirectory(doxygen)
85 add_subdirectory(manual)
86
87 if (SPHINX_FOUND)
88     # We need to have all the Sphinx input files in a single directory, and
89     # since some of them are generated, we copy everything into the build tree,
90     # to this directory.
91     set(SPHINX_INPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx-input)
92     set(SPHINX_EXTENSION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
93     if (SOURCE_MD5SUM STREQUAL "unknown")
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     else()
98         # The real build of the webpage happens from the tarball, and
99         # this should be set to the matching MD5 sum.
100         set(REGRESSIONTEST_MD5SUM_STRING "${REGRESSIONTEST_MD5SUM}")
101     endif()
102     set(SPHINX_SOURCE_FILES
103         index.rst
104         download.rst
105         dev-manual/index.rst
106         dev-manual/build-system.rst
107         dev-manual/commitstyle.rst
108         dev-manual/documentation-generation.rst
109         dev-manual/doxygen.rst
110         dev-manual/error-handling.rst
111         dev-manual/formatting.rst
112         dev-manual/gmxtree.rst
113         dev-manual/includestyle.rst
114         dev-manual/jenkins.rst
115         dev-manual/language-features.rst
116         dev-manual/naming.rst
117         dev-manual/overview.rst
118         dev-manual/redmine-states.png
119         dev-manual/relocatable-binaries.rst
120         dev-manual/reportstyle.rst
121         dev-manual/style.rst
122         dev-manual/testutils.rst
123         dev-manual/tools.rst
124         dev-manual/uncrustify.rst
125         fragments/doxygen-links.rst
126         install-guide/index.rst
127         release-notes/index.rst
128         release-notes/2018/2018.4.rst
129         release-notes/2018/2018.3.rst
130         release-notes/2018/2018.2.rst
131         release-notes/2018/2018.1.rst
132         release-notes/2018/major/highlights.rst
133         release-notes/2018/major/features.rst
134         release-notes/2018/major/performance.rst
135         release-notes/2018/major/tools.rst
136         release-notes/2018/major/bugs-fixed.rst
137         release-notes/2018/major/removed-features.rst
138         release-notes/2018/major/portability.rst
139         release-notes/2018/major/miscellaneous.rst
140         release-notes/2016/2016.5.rst
141         release-notes/2016/2016.4.rst
142         release-notes/2016/2016.3.rst
143         release-notes/2016/2016.2.rst
144         release-notes/2016/2016.1.rst
145         release-notes/2016/major/highlights.rst
146         release-notes/2016/major/new-features.rst
147         release-notes/2016/major/performance.rst
148         release-notes/2016/major/tools.rst
149         release-notes/2016/major/bugs-fixed.rst
150         release-notes/2016/major/removed-features.rst
151         release-notes/2016/major/miscellaneous.rst
152         release-notes/older/index.rst
153         user-guide/index.rst
154         user-guide/cutoff-schemes.rst
155         user-guide/getting-started.rst
156         user-guide/force-fields.rst
157         user-guide/faq.rst
158         user-guide/flow.rst
159         user-guide/floating-point.rst
160         user-guide/system-preparation.rst
161         user-guide/managing-simulations.rst
162         user-guide/mdrun-features.rst
163         user-guide/mdrun-performance.rst
164         user-guide/mdp-options.rst
165         user-guide/run-time-errors.rst
166         user-guide/file-formats.rst
167         user-guide/cmdline.rst
168         user-guide/environment-variables.rst
169         user-guide/security.rst
170         user-guide/terminology.rst
171         user-guide/plotje.gif
172         user-guide/xvgr.gif
173         conf.py
174         links.dat
175         )
176
177     include(SphinxMacros.cmake)
178     gmx_init_sphinx_setup(${SPHINX_INPUT_DIR})
179
180     set(SPHINX_CONFIG_VARS_FILE ${SPHINX_INPUT_DIR}/conf-vars.py)
181     gmx_configure_version_file(conf-vars.py.cmakein ${SPHINX_CONFIG_VARS_FILE}
182         EXTRA_VARS
183             SPHINX_EXTENSION_PATH RELENG_PATH
184             EXPECTED_DOXYGEN_VERSION
185             EXPECTED_SPHINX_VERSION
186             CMAKE_MINIMUM_REQUIRED_VERSION REQUIRED_CUDA_VERSION
187             REQUIRED_OPENCL_MIN_VERSION
188             REQUIRED_CUDA_COMPUTE_CAPABILITY REGRESSIONTEST_VERSION
189             SOURCE_MD5SUM REGRESSIONTEST_MD5SUM_STRING
190             GMX_TNG_MINIMUM_REQUIRED_VERSION
191             GMX_LMFIT_MINIMUM_REQUIRED_VERSION
192         COMMENT "Configuring Sphinx configuration file")
193     gmx_add_sphinx_input_file(${SPHINX_CONFIG_VARS_FILE})
194     gmx_add_sphinx_source_files(FILES ${SPHINX_SOURCE_FILES})
195     if (EXISTS ${RELENG_PATH}/docs/FileList.cmake)
196         include(${RELENG_PATH}/docs/FileList.cmake)
197         gmx_add_sphinx_source_files(
198             FROM ${RELENG_PATH}/docs TO dev-manual/releng PREFIX releng/docs/
199             FILES ${RELENG_SPHINX_FILES})
200     else()
201         gmx_add_sphinx_source_files(FILES
202             dev-manual/releng/index.rst
203             dev-manual/releng/jenkins-howto.rst
204             dev-manual/releng/jenkins-ui.rst
205             )
206     endif()
207     gmx_add_sphinx_input_target(sphinx-input)
208     # Remove other rst files from the build tree, since they confuse Sphinx.
209     # Skip generated files in onlinehelp/, and fragments.
210     # The latter do not cause issues with obsolete files, as they
211     # are not considered as Sphinx input files, but will only be
212     # included using an explicit .. include::.
213     gmx_remove_obsolete_sphinx_input_files("^(onlinehelp|fragments)/.*\\\\.rst$")
214
215     # TODO: Make this remove obsolete .rst files.
216     # TODO: This does not work in cross-compilation scenarios; disable up to
217     # the necessary level.
218     gmx_add_custom_output_target(sphinx-programs OUTPUT STAMP
219         COMMAND ${CMAKE_COMMAND} -E make_directory onlinehelp
220         COMMAND gmx -quiet help -export rst
221         DEPENDS gmx
222         WORKING_DIRECTORY ${SPHINX_INPUT_DIR}
223         COMMENT "Generating reStructuredText help")
224     # This dependency ensures that the directories exist before the
225     # executable tries to write things there.
226     add_dependencies(sphinx-programs sphinx-input)
227
228     # Make the INSTALL file for CPack for the tarball. This gets put
229     # into the tarball via the CPack rules below, which requires that
230     # the INSTALL file is in a separate directory by itself.
231     set(TEXT_INSTALL_GUIDE_OUTPUT_DIR "install-guide/text")
232     add_custom_target(install-guide
233         COMMAND
234             ${SPHINX_EXECUTABLE}
235             -q -b text
236             -w sphinx-install.log
237             -d ${CMAKE_CURRENT_BINARY_DIR}/install-guide/_doctrees
238             -c ${SPHINX_INPUT_DIR}
239             "${SPHINX_INPUT_DIR}/install-guide"
240             "${TEXT_INSTALL_GUIDE_OUTPUT_DIR}"
241         COMMAND
242             ${CMAKE_COMMAND} -E rename
243             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/index.txt
244             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/INSTALL
245         WORKING_DIRECTORY
246             ${CMAKE_CURRENT_BINARY_DIR}
247         COMMENT "Building INSTALL with Sphinx"
248         VERBATIM
249         )
250     add_dependencies(install-guide sphinx-input)
251     gmx_cpack_add_generated_source_directory(install-guide/text DESTINATION /)
252
253     # Sphinx cache with pickled ReST documents
254     set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
255
256     add_custom_target(webpage-sphinx
257         COMMAND
258             ${CMAKE_COMMAND} -E make_directory ${SPHINX_INPUT_DIR}/_static
259         COMMAND
260             ${SPHINX_EXECUTABLE}
261             -q -b html
262             -w sphinx-html.log
263             -d "${SPHINX_CACHE_DIR}"
264             "${SPHINX_INPUT_DIR}"
265             "${HTML_OUTPUT_DIR}"
266         WORKING_DIRECTORY
267             ${CMAKE_CURRENT_BINARY_DIR}
268         COMMENT "Building HTML documentation with Sphinx"
269         VERBATIM
270         )
271     add_dependencies(webpage-sphinx sphinx-input sphinx-programs)
272
273     add_custom_target(man
274         COMMAND
275             ${SPHINX_EXECUTABLE}
276             -q -b man
277             -w sphinx-man.log
278             -d ${SPHINX_CACHE_DIR}
279             -t do_man
280             ${SPHINX_INPUT_DIR}
281             ${CMAKE_CURRENT_BINARY_DIR}/man
282         COMMENT "Building man pages with Sphinx"
283         VERBATIM)
284     add_dependencies(man sphinx-input sphinx-programs)
285     if (GMX_BUILD_HELP)
286         # If requested, install the man pages built by the 'man' target
287         # created above.  Nothing will be installed if the user did not
288         # manually build the target.
289         set(MAN_PAGE_DIR ${CMAKE_CURRENT_BINARY_DIR})
290     endif()
291 else()
292     add_custom_target(webpage-sphinx
293         COMMAND ${CMAKE_COMMAND} -E echo
294             "HTML pages cannot be built because Sphinx version ${EXPECTED_SPHINX_VERSION} is not available"
295         VERBATIM)
296     add_custom_target(install-guide
297         COMMAND ${CMAKE_COMMAND} -E echo
298             "INSTALL cannot be built because Sphinx version ${EXPECTED_SPHINX_VERSION} is not available"
299         VERBATIM)
300     add_custom_target(man
301         COMMAND ${CMAKE_COMMAND} -E echo
302             "man pages cannot be built because Sphinx version ${EXPECTED_SPHINX_VERSION} is not available"
303         VERBATIM)
304 endif()
305
306 if (MAN_PAGE_DIR)
307     set(MAN_PAGE_DIR ${MAN_PAGE_DIR}/man)
308     # Trailing slash on directory is significant for
309     # install(DIRECTORY). See CMake docs.
310     install(DIRECTORY ${MAN_PAGE_DIR}/
311         DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
312         COMPONENT man OPTIONAL
313         FILES_MATCHING PATTERN "*.1")
314 endif()
315 gmx_cpack_add_generated_source_directory(man)
316
317 # Determine whether we can build all the HTML pages and content linked from
318 # there.  If not, construct an informative message if the user tries to
319 # build the target; most people never need to know, unless they've asked for
320 # the webpage build.
321 set(HTML_BUILD_IS_POSSIBLE ON)
322 set(HTML_BUILD_NOT_POSSIBLE_REASON)
323 set(HTML_BUILD_WARNINGS)
324
325 # Next, turn it off if any of the preconditions are unsatisified
326 if (NOT PYTHON_EXECUTABLE)
327     set(HTML_BUILD_IS_POSSIBLE OFF)
328     set(HTML_BUILD_NOT_POSSIBLE_REASON "Python is required")
329 elseif (NOT SPHINX_FOUND)
330     # Hardly anything gets built if Sphinx is not available, so don't bother.
331     set(HTML_BUILD_IS_POSSIBLE OFF)
332     set(HTML_BUILD_NOT_POSSIBLE_REASON "Sphinx version ${EXPECTED_SPHINX_VERSION} is required")
333 endif()
334 if (NOT MANUAL_BUILD_IS_POSSIBLE)
335     list(APPEND HTML_BUILD_WARNINGS
336          "Reference PDF manual was not built, so links to it do not work")
337 endif()
338 if (NOT DOXYGEN_EXECUTABLE)
339     list(APPEND HTML_BUILD_WARNINGS
340         "Doxygen was not available, so links to Doxygen do not work")
341 endif()
342 if (NOT DOXYGEN_DOT_EXECUTABLE)
343     list(APPEND HTML_BUILD_WARNINGS
344         "dot/graphviz was not found, so some graphs are missing")
345 endif()
346
347 if (HTML_BUILD_IS_POSSIBLE)
348     set(_webpage_target_properties)
349     if (HTML_BUILD_WARNINGS)
350         list(APPEND _webpage_target_properties
351              COMMAND ${CMAKE_COMMAND} -E echo
352                  "webpage was built, but with the following limitations:")
353         foreach(_warning ${HTML_BUILD_WARNINGS})
354         list(APPEND _webpage_target_properties
355              COMMAND ${CMAKE_COMMAND} -E echo " - ${_warning}")
356         endforeach()
357     endif()
358
359     if (MANUAL_BUILD_IS_POSSIBLE)
360         # Make the PDF reference guide
361         # TODO Try to make the PDF arrive directly in ${HTML_OUTPUT_DIR}
362         # TODO Make this depend on the output of the manual build, so that the
363         # file actually gets copied multiple times.
364         set(_manual_target_location ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf)
365         add_custom_command(
366             OUTPUT ${_manual_target_location}
367             COMMAND ${CMAKE_COMMAND}
368                 -E remove -f ${_manual_target_location}
369             COMMAND ${CMAKE_COMMAND}
370                 -E copy ${CMAKE_CURRENT_BINARY_DIR}/manual/gromacs.pdf ${_manual_target_location}
371             DEPENDS manual
372             VERBATIM)
373         list(APPEND _webpage_target_properties
374              DEPENDS ${_manual_target_location})
375     endif()
376
377     # The Doxygen configuration in doxygen/Doxyfile-common.cmakein
378     # makes all the Doxygen output directly in
379     # ${HTML_OUTPUT_DIR}/doxygen (and makes the directory if it needs
380     # to).
381
382     # Add a top-level target that builds everything related to the webpage,
383     # for Jenkins (and possibly others) to use
384     add_custom_target(webpage ${_webpage_target_properties}
385         COMMENT "Building webpage"
386         VERBATIM)
387     add_dependencies(webpage webpage-sphinx doxygen-all)
388 else()
389     add_custom_target(webpage
390         COMMAND ${CMAKE_COMMAND} -E echo
391             "Cannot build webpage because ${HTML_BUILD_NOT_POSSIBLE_REASON}"
392         COMMENT "Webpage build not possible"
393         VERBATIM)
394 endif()