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