Merge origin/release-2019 into release-2020
[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,2019, 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.6.1)
62
63 # By default, suppress output after first configuration.
64 if(SPHINX_ALREADY_SEARCHED)
65     set(Sphinx_FIND_QUIETLY ON)
66 endif()
67 find_package(Sphinx ${EXPECTED_SPHINX_VERSION} COMPONENTS pygments)
68 set(SPHINX_ALREADY_SEARCHED TRUE CACHE BOOL "True if a search for Sphinx has already been done")
69 mark_as_advanced(SPHINX_ALREADY_SEARCHED)
70
71 # Even if we aren't going to make the full webpage, set up to put all
72 # the documentation output in the same place, for convenience
73 set(HTML_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
74 file(MAKE_DIRECTORY ${HTML_OUTPUT_DIR})
75
76 # Prepare directories for pdf/tex output
77 set(TEX_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual")
78 set(SPHINX_LATEX_FILE "${TEX_OUTPUT_DIR}/gromacs.tex")
79 file(MAKE_DIRECTORY ${TEX_OUTPUT_DIR})
80
81 # The directory from which man pages will be installed; if it remains
82 # empty, they will be silently skipped.
83 set(MAN_PAGE_DIR)
84 if (SOURCE_IS_SOURCE_DISTRIBUTION)
85     # When building from the tarball, install the bundled man pages
86     # (unless overridden).
87     set(MAN_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
88 endif()
89
90 add_subdirectory(doxygen)
91
92 # TODO: Consider whether this could just be replaced by using
93 # GMX_DEVELOPER_BUILD to control this as well.
94 option(GMX_BUILD_MANUAL "Whether to try to configure to build the PDF manual" OFF)
95 mark_as_advanced(GMX_BUILD_MANUAL)
96
97 set(MANUAL_BUILD_IS_POSSIBLE ON)
98 set(MANUAL_BUILD_NOT_POSSIBLE_REASON)
99 set(NO_IMAGE_CONVERT_REASON)
100 if (NOT GMX_BUILD_MANUAL)
101     # Make sure we only do detection of manual-building dependencies
102     # when the user opted in for that.
103     set(MANUAL_BUILD_IS_POSSIBLE OFF)
104     set(MANUAL_BUILD_NOT_POSSIBLE_REASON "GMX_BUILD_MANUAL is not ON")
105 elseif (BUILD_IS_INSOURCE)
106     # UseLATEX.cmake does not work with an in-source build
107     set(MANUAL_BUILD_IS_POSSIBLE OFF)
108     set(MANUAL_BUILD_NOT_POSSIBLE_REASON "the build is in-source")
109 else()
110     include(manual/UseLATEX.cmake)
111     if(NOT SPHINX_FOUND)
112         set(MANUAL_BUILD_IS_POSSIBLE OFF)
113         set(MANUAL_BUILD_NOT_POSSIBLE_REASON "Sphinx has not been found and is needed to create the LaTex input files")
114     elseif(NOT PDFLATEX_COMPILER)
115         set(MANUAL_BUILD_IS_POSSIBLE OFF)
116         set(MANUAL_BUILD_NOT_POSSIBLE_REASON "pdflatex is not available")
117     elseif(NOT IMAGE_CONVERT_POSSIBLE)
118         set(MANUAL_BUILD_IS_POSSIBLE OFF)
119         set(MANUAL_BUILD_NOT_POSSIBLE_REASON "a working form of ImageMagick convert is not available")
120         set(NO_IMAGE_CONVERT_REASON "Can not convert files for online or pdf manual")
121         # TODO Later, identify other dependencies like bibtex,
122         # make_index, date, some graphics conversion program,
123         # etc. Perhaps patch UseLATEX.cmake and contribute upstream.
124     endif()
125
126 endif()
127
128 if (SPHINX_FOUND)
129     # We need to have all the Sphinx input files in a single directory, and
130     # since some of them are generated, we copy everything into the build tree,
131     # to this directory.
132     set(SPHINX_INPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx-input)
133     set(SPHINX_EXTENSION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
134     # As the manual build now depends also on Sphinx, the inclusion path needs
135     # to be set after we know the basic information for Sphinx.
136     add_subdirectory(manual)
137     if (SOURCE_MD5SUM STREQUAL "unknown")
138         # But for testing the webpage build (e.g. from the repo) we
139         # need a default value.
140         set(REGRESSIONTEST_MD5SUM_STRING "unknown")
141     else()
142         # The real build of the webpage happens from the tarball, and
143         # this should be set to the matching MD5 sum.
144         set(REGRESSIONTEST_MD5SUM_STRING "${REGRESSIONTEST_MD5SUM}")
145     endif()
146     # The reference manual still contains the individual sections from the
147     # LaTeX document, with the files below grouped and annotated by chapter.
148     set(REFERENCEMANUAL_SPHINX_FILES_GENERAL
149         # Main index file, preface and introduction.
150         reference-manual/index.rst
151         reference-manual/preface.rst
152         reference-manual/introduction.rst
153         # Definitions and Units chapter
154         reference-manual/definitions.rst
155         # Topologies chapter
156         reference-manual/topologies.rst
157         reference-manual/topologies/particle-type.rst
158         reference-manual/topologies/parameter-files.rst
159         reference-manual/topologies/molecule-definition.rst
160         reference-manual/topologies/constraint-algorithm-section.rst
161         reference-manual/topologies/pdb2gmx-input-files.rst
162         reference-manual/topologies/topology-file-formats.rst
163         reference-manual/topologies/force-field-organization.rst
164         # File formats chapter
165         reference-manual/file-formats.rst
166         # Run parameters and programs chapter
167         reference-manual/run-parameters.rst
168         # Implementation details chapter
169         reference-manual/details.rst
170         # Averages and fluctations chapter
171         reference-manual/averages.rst
172         # References
173         reference-manual/references.rst
174         # PNG formated plot files that don't need to be converted into PNG
175         # for the web page.
176         reference-manual/plots/peregrine.png
177         reference-manual/plots/adress.png
178         reference-manual/plots/plotje.png
179         reference-manual/plots/xvgr.png
180         )
181     set(REFERENCEMANUAL_SPHINX_FILES_WITH_IMAGES
182         # Algorithms chapter
183         reference-manual/algorithms.rst
184         reference-manual/algorithms/periodic-boundary-conditions.rst
185         reference-manual/algorithms/group-concept.rst
186         reference-manual/algorithms/molecular-dynamics.rst
187         reference-manual/algorithms/shell-molecular-dynamics.rst
188         reference-manual/algorithms/constraint-algorithms.rst
189         reference-manual/algorithms/simulated-annealing.rst
190         reference-manual/algorithms/stochastic-dynamics.rst
191         reference-manual/algorithms/brownian-dynamics.rst
192         reference-manual/algorithms/energy-minimization.rst
193         reference-manual/algorithms/normal-mode-analysis.rst
194         reference-manual/algorithms/free-energy-calculations.rst
195         reference-manual/algorithms/replica-exchange.rst
196         reference-manual/algorithms/essential-dynamics.rst
197         reference-manual/algorithms/expanded-ensemble.rst
198         reference-manual/algorithms/parallelization-domain-decomp.rst
199         # Interaction functions and force fields chapter
200         reference-manual/functions.rst
201         reference-manual/functions/bonded-interactions.rst
202         reference-manual/functions/force-field.rst
203         reference-manual/functions/free-energy-interactions.rst
204         reference-manual/functions/interaction-methods.rst
205         reference-manual/functions/long-range-electrostatics.rst
206         reference-manual/functions/long-range-vdw.rst
207         reference-manual/functions/nonbonded-interactions.rst
208         reference-manual/functions/polarization.rst
209         reference-manual/functions/restraints.rst
210         # Special topics chapter
211         reference-manual/special.rst
212         reference-manual/special/free-energy-implementation.rst
213         reference-manual/special/pulling.rst
214         reference-manual/special/awh.rst
215         reference-manual/special/enforced-rotation.rst
216         reference-manual/special/electric-fields.rst
217         reference-manual/special/comp-electrophys.rst
218         reference-manual/special/free-energy-pmf.rst
219         reference-manual/special/remove-fast-dgf.rst
220         reference-manual/special/viscosity-calculation.rst
221         reference-manual/special/tabulated-interaction-functions.rst
222         reference-manual/special/qmmm.rst
223         reference-manual/special/vmd-imd.rst
224         reference-manual/special/membrane-embedding.rst
225         reference-manual/special/mimic-qmmm.rst
226         reference-manual/special/density-guided-simulation.rst
227         # Analysis chapter
228         reference-manual/analysis.rst
229         reference-manual/analysis/using-groups.rst
230         reference-manual/analysis/looking-at-trajectory.rst
231         reference-manual/analysis/general-properties.rst
232         reference-manual/analysis/radial-distribution-function.rst
233         reference-manual/analysis/correlation-function.rst
234         reference-manual/analysis/curve-fitting.rst
235         reference-manual/analysis/mean-square-displacement.rst
236         reference-manual/analysis/bond-angle-dihedral.rst
237         reference-manual/analysis/radius-of-gyration.rst
238         reference-manual/analysis/rmsd.rst
239         reference-manual/analysis/covariance-analysis.rst
240         reference-manual/analysis/dihedral-pca.rst
241         reference-manual/analysis/hydrogen-bonds.rst
242         reference-manual/analysis/protein-related.rst
243         reference-manual/analysis/interface-related.rst)
244     # The image files have also been ordered by the respective
245     # chapter they are included in in the reference manual
246     set(REFERENCEMANUAL_IMAGE_FILES
247         # General folder
248         reference-manual/plots/decomp.pdf
249         reference-manual/plots/dih.pdf
250         reference-manual/plots/drift-all.pdf
251         reference-manual/plots/f-angle.pdf
252         reference-manual/plots/f-bond.pdf
253         reference-manual/plots/fp-highres.pdf
254         reference-manual/plots/int-mat.pdf
255         reference-manual/plots/mdpar.pdf
256         reference-manual/plots/parsort.pdf
257         reference-manual/plots/ring.pdf
258         reference-manual/plots/shiftf.pdf
259         # Algorithms chapter
260         reference-manual/algorithms/plots/dd-cells.pdf
261         reference-manual/algorithms/plots/dd-tric.pdf
262         reference-manual/algorithms/plots/flowchart.pdf
263         reference-manual/algorithms/plots/free1.pdf
264         reference-manual/algorithms/plots/free2.pdf
265         reference-manual/algorithms/plots/leapfrog.pdf
266         reference-manual/algorithms/plots/lincs.pdf
267         reference-manual/algorithms/plots/maxwell.pdf
268         reference-manual/algorithms/plots/mpmd-pme.pdf
269         reference-manual/algorithms/plots/nstric.pdf
270         reference-manual/algorithms/plots/par-lincs2.pdf
271         reference-manual/algorithms/plots/pbctric.pdf
272         reference-manual/algorithms/plots/rhododec.pdf
273         reference-manual/algorithms/plots/truncoct.pdf
274         reference-manual/algorithms/plots/verlet-drift.pdf
275         # Interaction functions chapter
276         reference-manual/functions/plots/angle.pdf
277         reference-manual/functions/plots/bstretch.pdf
278         reference-manual/functions/plots/chain.pdf
279         reference-manual/functions/plots/dummies.pdf
280         reference-manual/functions/plots/f-bham.pdf
281         reference-manual/functions/plots/fbposres.pdf
282         reference-manual/functions/plots/f-dih.pdf
283         reference-manual/functions/plots/f-dr.pdf
284         reference-manual/functions/plots/fig-02.pdf
285         reference-manual/functions/plots/fig-04.pdf
286         reference-manual/functions/plots/f-imps.pdf
287         reference-manual/functions/plots/f-lj.pdf
288         reference-manual/functions/plots/f-morse.pdf
289         reference-manual/functions/plots/f-pr.pdf
290         reference-manual/functions/plots/f-rbs.pdf
291         reference-manual/functions/plots/ring-imp.pdf
292         reference-manual/functions/plots/softcore.pdf
293         reference-manual/functions/plots/subst-im.pdf
294         reference-manual/functions/plots/tetra-im.pdf
295         reference-manual/functions/plots/vcrf.pdf
296         reference-manual/functions/plots/vsite-4fdn.pdf
297         # Special topics chapter
298         reference-manual/special/plots/awh-invN.pdf
299         reference-manual/special/plots/awh-pmfs.pdf
300         reference-manual/special/plots/awh-sampleweights.pdf
301         reference-manual/special/plots/awh-traj.pdf
302         reference-manual/special/plots/compelsetup.pdf
303         reference-manual/special/plots/dumaro.pdf
304         reference-manual/special/plots/dumtypes.pdf
305         reference-manual/special/plots/equipotential.pdf
306         reference-manual/special/plots/field.pdf
307         reference-manual/special/plots/gaussians.pdf
308         reference-manual/special/plots/pulldirrel.pdf
309         reference-manual/special/plots/pull.pdf
310         reference-manual/special/plots/pullref.pdf
311         reference-manual/special/plots/rotation.pdf
312         # Analysis chapter
313         reference-manual/analysis/plots/dih-def.pdf
314         reference-manual/analysis/plots/distm.pdf
315         reference-manual/analysis/plots/dssp.pdf
316         reference-manual/analysis/plots/hbond-insert.pdf
317         reference-manual/analysis/plots/hbond.pdf
318         reference-manual/analysis/plots/hpr-wheel.pdf
319         reference-manual/analysis/plots/msdwater.pdf
320         reference-manual/analysis/plots/ngmxdump.pdf
321         reference-manual/analysis/plots/phipsi.pdf
322         reference-manual/analysis/plots/rama.pdf
323         reference-manual/analysis/plots/rdfO-O.pdf
324         reference-manual/analysis/plots/rdf.pdf
325         reference-manual/analysis/plots/sgangle.pdf 
326         )
327     set(SPHINX_SOURCE_FILES
328         index.rst
329         download.rst
330         conf.py
331         links.dat
332         dev-manual/build-system.rst
333         dev-manual/change-management.rst
334         dev-manual/commitstyle.rst
335         dev-manual/documentation-generation.rst
336         dev-manual/contribute.rst
337         dev-manual/doxygen.rst
338         dev-manual/error-handling.rst
339         dev-manual/formatting.rst
340         dev-manual/gmxtree.rst
341         dev-manual/includestyle.rst
342         dev-manual/index.rst
343         dev-manual/jenkins.rst
344         dev-manual/known-issues.rst
345         dev-manual/language-features.rst
346         dev-manual/naming.rst
347         dev-manual/overview.rst
348         dev-manual/physical_validation.rst
349         dev-manual/redmine-states.png
350         dev-manual/relocatable-binaries.rst
351         dev-manual/reportstyle.rst
352         dev-manual/style.rst
353         dev-manual/testutils.rst
354         dev-manual/tools.rst
355         dev-manual/code-formatting.rst
356         fragments/doxygen-links.rst
357         how-to/index.rst
358         how-to/beginners.rst
359         how-to/topology.rst
360         how-to/special.rst
361         how-to/visualize.rst
362         install-guide/index.rst
363         release-notes/index.rst
364         release-notes/2020/major/highlights.rst
365         release-notes/2020/major/features.rst
366         release-notes/2020/major/performance.rst
367         release-notes/2020/major/tools.rst
368         release-notes/2020/major/bugs-fixed.rst
369         release-notes/2020/major/removed-functionality.rst
370         release-notes/2020/major/deprecated-functionality.rst
371         release-notes/2020/major/portability.rst
372         release-notes/2020/major/miscellaneous.rst
373         release-notes/2019/2019.6.rst
374         release-notes/2019/2019.5.rst
375         release-notes/2019/2019.4.rst
376         release-notes/2019/2019.3.rst
377         release-notes/2019/2019.2.rst
378         release-notes/2019/2019.1.rst
379         release-notes/2019/major/highlights.rst
380         release-notes/2019/major/features.rst
381         release-notes/2019/major/performance.rst
382         release-notes/2019/major/tools.rst
383         release-notes/2019/major/bugs-fixed.rst
384         release-notes/2019/major/removed-functionality.rst
385         release-notes/2019/major/deprecated-functionality.rst
386         release-notes/2019/major/portability.rst
387         release-notes/2019/major/miscellaneous.rst
388         release-notes/2018/2018.7.rst
389         release-notes/2018/2018.6.rst
390         release-notes/2018/2018.5.rst
391         release-notes/2018/2018.4.rst
392         release-notes/2018/2018.3.rst
393         release-notes/2018/2018.2.rst
394         release-notes/2018/2018.1.rst
395         release-notes/2018/major/highlights.rst
396         release-notes/2018/major/features.rst
397         release-notes/2018/major/performance.rst
398         release-notes/2018/major/tools.rst
399         release-notes/2018/major/bugs-fixed.rst
400         release-notes/2018/major/removed-features.rst
401         release-notes/2018/major/portability.rst
402         release-notes/2018/major/miscellaneous.rst
403         release-notes/2016/2016.5.rst
404         release-notes/2016/2016.4.rst
405         release-notes/2016/2016.3.rst
406         release-notes/2016/2016.2.rst
407         release-notes/2016/2016.1.rst
408         release-notes/2016/major/highlights.rst
409         release-notes/2016/major/new-features.rst
410         release-notes/2016/major/performance.rst
411         release-notes/2016/major/tools.rst
412         release-notes/2016/major/bugs-fixed.rst
413         release-notes/2016/major/removed-features.rst
414         release-notes/2016/major/miscellaneous.rst
415         release-notes/older/index.rst
416         # the entry for user-guide/index.rst should not appear here,
417         # as it will be included conditionally further down depending on
418         # if the documentation will be build with the full reference
419         # manual or without.
420         user-guide/cmdline.rst
421         user-guide/deprecation-policy.rst
422         user-guide/environment-variables.rst
423         user-guide/faq.rst
424         user-guide/floating-point.rst
425         user-guide/flow.rst
426         user-guide/force-fields.rst
427         user-guide/getting-started.rst
428         user-guide/index.rst
429         user-guide/managing-simulations.rst
430         user-guide/mdp-options.rst
431         user-guide/mdrun-features.rst
432         user-guide/mdrun-performance.rst
433         user-guide/run-time-errors.rst
434         user-guide/security.rst
435         user-guide/system-preparation.rst
436         user-guide/terminology.rst
437         )
438
439     include(SphinxMacros.cmake)
440     gmx_init_sphinx_setup(${SPHINX_INPUT_DIR})
441
442     # set temporary variables for doi inclusion
443     # into the manual, plain string + some wrapping
444     # for release builds, and dummy string for non-release
445     # builds
446     if("${GMX_MANUAL_DOI}" STREQUAL "")
447       # empty string means no doi, set dummy text
448       set(GMX_MANUAL_DOI_STRING "This is not a release build of GROMACS, so please reference")
449       set(GMX_MANUAL_DOI_STRING "${GMX_MANUAL_DOI_STRING} one of the GROMACS papers and the base release of the manual.")
450     else()
451       # release version, set plain old boring string
452       set(GMX_MANUAL_DOI_STRING "Please reference this documentation as https://doi.org/${GMX_MANUAL_DOI}.")
453     endif()
454     # same for source doi, but modify the text
455     if("${GMX_SOURCE_DOI}" STREQUAL "")
456       # empty string means no release build
457       set(GMX_SOURCE_DOI_STRING "This is not a release build of GROMACS. Please reference one of the")
458       set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} GROMACS papers, as well as the base release that this version is built from.")
459       set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} Also, please state what modifcations have been performed or where the version")
460       set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} was sourced from.")
461     else()
462       # release version, give them a doi url string
463       set(GMX_SOURCE_DOI_STRING "To cite the source code for this release, please cite")
464       set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} https://doi.org/${GMX_SOURCE_DOI}.")
465     endif()
466
467     if(IMAGE_CONVERT_POSSIBLE)
468         set(IMAGE_CONVERT_STRING "possible")
469     else()
470         set(IMAGE_CONVERT_STRING "impossible")
471     endif()
472
473     set(SPHINX_CONFIG_VARS_FILE ${SPHINX_INPUT_DIR}/conf-vars.py)
474     if (GMX_PYTHON_PACKAGE)
475         set(GMXAPI_PYTHON_STAGING_DIR ${CMAKE_BINARY_DIR}/python_packaging/src/gmxapi_staging)
476         # TODO: Resolve circular reference. We would like to get the CMake build-time directory for
477         # the gmxapi Python package from the _gmxapi target, as we do when building sample_restraint.
478         # Instead of the above hard-coded path, how can we do
479         # get_target_property(GMXAPI_PYTHON_STAGING_DIR _gmxapi staging_dir)
480         # in this context?
481     endif ()
482
483     gmx_configure_version_file(conf-vars.py.cmakein ${SPHINX_CONFIG_VARS_FILE}
484         EXTRA_VARS
485             SPHINX_EXTENSION_PATH RELENG_PATH
486             IMAGE_CONVERT_STRING
487             EXPECTED_DOXYGEN_VERSION
488             EXPECTED_SPHINX_VERSION
489             CMAKE_MINIMUM_REQUIRED_VERSION REQUIRED_CUDA_VERSION
490             REQUIRED_OPENCL_MIN_VERSION
491             REQUIRED_CUDA_COMPUTE_CAPABILITY REGRESSIONTEST_VERSION
492             SOURCE_MD5SUM REGRESSIONTEST_MD5SUM_STRING
493             GMX_TNG_MINIMUM_REQUIRED_VERSION
494             GMX_LMFIT_REQUIRED_VERSION
495             GMX_MANUAL_DOI_STRING
496             GMX_SOURCE_DOI_STRING
497             GMXAPI_PYTHON_STAGING_DIR
498         COMMENT "Configuring Sphinx configuration file")
499     gmx_add_sphinx_input_file(${SPHINX_CONFIG_VARS_FILE})
500     gmx_add_sphinx_source_files(FILES ${SPHINX_SOURCE_FILES})
501     if (EXISTS ${RELENG_PATH}/docs/FileList.cmake)
502         include(${RELENG_PATH}/docs/FileList.cmake)
503         gmx_add_sphinx_source_files(
504             FROM ${RELENG_PATH}/docs TO dev-manual/releng PREFIX releng/docs/
505             FILES ${RELENG_SPHINX_FILES})
506     else()
507         gmx_add_sphinx_source_files(FILES
508             dev-manual/releng/index.rst
509             dev-manual/releng/jenkins-howto.rst
510             dev-manual/releng/jenkins-ui.rst
511             )
512     endif()
513
514     gmx_add_sphinx_source_files(
515             FILES
516             gmxapi/index.rst
517             gmxapi/userguide/install.rst
518             gmxapi/userguide/usage.rst
519             gmxapi/userguide/userguide.rst
520     )
521
522     if (GMX_PYTHON_PACKAGE)
523         gmx_add_sphinx_source_files(
524             FILES
525             gmxapi/userguide/pythonreference.rst
526             )
527     else()
528         gmx_add_sphinx_source_files(
529             FROM ${CMAKE_CURRENT_SOURCE_DIR}/gmxapi/userguide-stub
530             TO gmxapi/userguide/ 
531             FILES pythonreference.rst 
532             )
533     endif ()
534
535     gmx_add_sphinx_source_files(
536         FILES
537         ${REFERENCEMANUAL_SPHINX_FILES_GENERAL})
538     if (IMAGE_CONVERT_POSSIBLE)
539         gmx_add_sphinx_source_files(
540             FILES
541             ${REFERENCEMANUAL_SPHINX_FILES_WITH_IMAGES}
542             ${REFERENCEMANUAL_IMAGE_FILES})
543         gmx_add_sphinx_image_conversion_files(
544             FILES
545             ${REFERENCEMANUAL_IMAGE_FILES})
546     endif()
547     gmx_add_sphinx_input_target(sphinx-input-rst)
548     gmx_add_sphinx_image_conversion_target(sphinx-image-conversion)
549     add_custom_target(sphinx-input)
550     add_dependencies(sphinx-input sphinx-input-rst sphinx-image-conversion)
551     if (GMX_PYTHON_PACKAGE)
552         add_dependencies(sphinx-input _gmxapi)
553     endif()
554     # Remove other rst files from the build tree, since they confuse Sphinx.
555     # Skip generated files in onlinehelp/, and fragments.
556     # The latter do not cause issues with obsolete files, as they
557     # are not considered as Sphinx input files, but will only be
558     # included using an explicit .. include::.
559     gmx_remove_obsolete_sphinx_input_files("^(onlinehelp|fragments)/.*\\\\.rst$")
560
561     # TODO: Make this remove obsolete .rst files.
562     # TODO: This does not work in cross-compilation scenarios; disable up to
563     # the necessary level.
564     gmx_add_custom_output_target(sphinx-programs OUTPUT STAMP
565         COMMAND ${CMAKE_COMMAND} -E make_directory onlinehelp
566         COMMAND gmx -quiet help -export rst
567         DEPENDS gmx
568         WORKING_DIRECTORY ${SPHINX_INPUT_DIR}
569         COMMENT "Generating reStructuredText help")
570     # This dependency ensures that the directories exist before the
571     # executable tries to write things there.
572     add_dependencies(sphinx-programs sphinx-input)
573
574     # Make the INSTALL file for CPack for the tarball. This gets put
575     # into the tarball via the CPack rules below, which requires that
576     # the INSTALL file is in a separate directory by itself.
577     set(TEXT_INSTALL_GUIDE_OUTPUT_DIR "install-guide/text")
578     add_custom_target(install-guide
579         COMMAND
580             ${SPHINX_EXECUTABLE}
581             -q -b text
582             -w sphinx-install.log
583             -d ${CMAKE_CURRENT_BINARY_DIR}/install-guide/_doctrees
584             -c ${SPHINX_INPUT_DIR}
585             "${SPHINX_INPUT_DIR}/install-guide"
586             "${TEXT_INSTALL_GUIDE_OUTPUT_DIR}"
587         COMMAND
588             ${CMAKE_COMMAND} -E rename
589             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/index.txt
590             ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/INSTALL
591         WORKING_DIRECTORY
592             ${CMAKE_CURRENT_BINARY_DIR}
593         COMMENT "Building INSTALL with Sphinx"
594         VERBATIM
595         )
596     add_dependencies(install-guide sphinx-input)
597     gmx_cpack_add_generated_source_directory(install-guide/text DESTINATION /)
598
599     # Sphinx cache with pickled ReST documents
600     set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
601     add_custom_target(webpage-sphinx
602         DEPENDS sphinx-programs
603         DEPENDS sphinx-input
604         DEPENDS sphinx-image-conversion
605         DEPENDS manual
606         COMMAND
607             ${CMAKE_COMMAND} -E make_directory ${SPHINX_INPUT_DIR}/_static
608         COMMAND
609             ${SPHINX_EXECUTABLE}
610             -q -b html
611             -w sphinx-html.log
612             -d "${SPHINX_CACHE_DIR}"
613             "${SPHINX_INPUT_DIR}"
614             "${HTML_OUTPUT_DIR}"
615         WORKING_DIRECTORY
616             ${CMAKE_CURRENT_BINARY_DIR}
617         COMMENT "Building HTML documentation with Sphinx"
618         VERBATIM
619         )
620
621     add_custom_target(man
622         COMMAND
623             ${SPHINX_EXECUTABLE}
624             -q -b man
625             -w sphinx-man.log
626             -d ${SPHINX_CACHE_DIR}
627             -t do_man
628             ${SPHINX_INPUT_DIR}
629             ${CMAKE_CURRENT_BINARY_DIR}/man
630         COMMENT "Building man pages with Sphinx"
631         VERBATIM)
632     add_dependencies(man sphinx-input sphinx-programs)
633     if (GMX_BUILD_HELP)
634         # If requested, install the man pages built by the 'man' target
635         # created above.  Nothing will be installed if the user did not
636         # manually build the target.
637         set(MAN_PAGE_DIR ${CMAKE_CURRENT_BINARY_DIR})
638     endif()
639
640 else()
641     set(MANUAL_BUILD_IS_POSSIBLE OFF)
642     set(MANUAL_BUILD_NOT_POSSIBLE_REASON "Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available")
643
644     add_custom_target(webpage-sphinx
645         COMMAND ${CMAKE_COMMAND} -E echo
646             "HTML pages cannot be built because Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available"
647         VERBATIM)
648     add_custom_target(install-guide
649         COMMAND ${CMAKE_COMMAND} -E echo
650             "INSTALL cannot be built because Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available"
651         VERBATIM)
652     add_custom_target(man
653         COMMAND ${CMAKE_COMMAND} -E echo
654             "man pages cannot be built because Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available"
655         VERBATIM)
656     add_custom_target(sphinx-create-texman
657         COMMAND ${CMAKE_COMMAND} -E echo
658             "Cannot prepare LaTeX input files because Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available"
659         VERBATIM)
660     add_custom_target(manual
661         COMMAND ${CMAKE_COMMAND} -E echo
662             "manual cannot be built because Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is not available")
663 endif()
664
665 if (MAN_PAGE_DIR)
666     set(MAN_PAGE_DIR ${MAN_PAGE_DIR}/man)
667     # Trailing slash on directory is significant for
668     # install(DIRECTORY). See CMake docs.
669     install(DIRECTORY ${MAN_PAGE_DIR}/
670         DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
671         COMPONENT man OPTIONAL
672         FILES_MATCHING PATTERN "*.1")
673 endif()
674 gmx_cpack_add_generated_source_directory(man)
675
676 # Determine whether we can build all the HTML pages and content linked from
677 # there.  If not, construct an informative message if the user tries to
678 # build the target; most people never need to know, unless they've asked for
679 # the webpage build.
680 set(HTML_BUILD_IS_POSSIBLE ON)
681 set(HTML_BUILD_NOT_POSSIBLE_REASON)
682 set(HTML_BUILD_WARNINGS)
683
684 # Next, turn it off if any of the preconditions are unsatisified
685 if (NOT PythonInterp_FOUND)
686     set(HTML_BUILD_IS_POSSIBLE OFF)
687     set(HTML_BUILD_NOT_POSSIBLE_REASON "Python is required")
688 elseif (NOT SPHINX_FOUND)
689     # Hardly anything gets built if Sphinx is not available, so don't bother.
690     set(HTML_BUILD_IS_POSSIBLE OFF)
691     set(HTML_BUILD_NOT_POSSIBLE_REASON "Sphinx expected minimum version ${EXPECTED_SPHINX_VERSION} is required")
692 endif()
693 if (NOT MANUAL_BUILD_IS_POSSIBLE)
694     list(APPEND HTML_BUILD_WARNINGS
695          "Reference PDF manual was not built, so links to it do not work")
696 endif()
697 if (NOT DOXYGEN_EXECUTABLE)
698     list(APPEND HTML_BUILD_WARNINGS
699         "Doxygen was not available, so links to Doxygen do not work")
700 endif()
701 if (NOT DOXYGEN_DOT_EXECUTABLE)
702     list(APPEND HTML_BUILD_WARNINGS
703         "dot/graphviz was not found, so some graphs are missing")
704 endif()
705
706 if (HTML_BUILD_IS_POSSIBLE)
707     set(_webpage_target_properties)
708     if (HTML_BUILD_WARNINGS)
709         list(APPEND _webpage_target_properties
710              COMMAND ${CMAKE_COMMAND} -E echo
711                  "webpage was built, but with the following limitations:")
712         foreach(_warning ${HTML_BUILD_WARNINGS})
713         list(APPEND _webpage_target_properties
714              COMMAND ${CMAKE_COMMAND} -E echo " - ${_warning}")
715         endforeach()
716     endif()
717
718     if (MANUAL_BUILD_IS_POSSIBLE)
719         # Make the PDF reference guide
720         # TODO Try to make the PDF arrive directly in ${HTML_OUTPUT_DIR}
721         # TODO Make this depend on the output of the manual build, so that the
722         # file actually gets copied multiple times.
723         set(_manual_target_location ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf)
724         add_custom_command(
725             OUTPUT ${_manual_target_location}
726             COMMAND ${CMAKE_COMMAND}
727                 -E remove -f ${_manual_target_location}
728             COMMAND ${CMAKE_COMMAND}
729                 -E copy ${CMAKE_CURRENT_BINARY_DIR}/manual/gromacs.pdf ${_manual_target_location}
730             DEPENDS manual
731             VERBATIM)
732         list(APPEND _webpage_target_properties
733              DEPENDS ${_manual_target_location})
734     endif()
735
736     # The Doxygen configuration in doxygen/Doxyfile-common.cmakein
737     # makes all the Doxygen output directly in
738     # ${HTML_OUTPUT_DIR}/doxygen (and makes the directory if it needs
739     # to).
740
741     # Add a top-level target that builds everything related to the webpage,
742     # for Jenkins (and possibly others) to use
743     add_custom_target(webpage ${_webpage_target_properties}
744         COMMENT "Building webpage"
745         VERBATIM)
746     add_dependencies(webpage webpage-sphinx doxygen-all)
747 else()
748     add_custom_target(webpage
749         COMMAND ${CMAKE_COMMAND} -E echo
750             "Cannot build webpage because ${HTML_BUILD_NOT_POSSIBLE_REASON}"
751         COMMENT "Webpage build not possible"
752         VERBATIM)
753 endif()