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