2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2014,2015, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 # This directory provides a unified place for building all kinds of
36 # GROMACS documentation. This includes some "static" content (Doxygen
37 # code documentation, reference manual, install guide, old online HTML
38 # pages), 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
54 # Even if we aren't going to make the full webpage, set up to put all
55 # the documentation output in the same place, for convenience
56 set(HTML_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
57 file(MAKE_DIRECTORY ${HTML_OUTPUT_DIR})
59 set(MAN_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
61 find_package(PythonInterp)
62 find_package(Sphinx 1.2.3 COMPONENTS pygments)
64 add_subdirectory(old-html)
65 add_subdirectory(doxygen)
67 option(GMX_BUILD_WEBPAGE "Whether to try to configure to build the GROMACS static webpages" OFF)
68 mark_as_advanced(GMX_BUILD_WEBPAGE)
69 option(GMX_BUILD_MANUAL "Whether to try to configure to build the PDF manual" OFF)
70 mark_as_advanced(GMX_BUILD_MANUAL)
72 # Make sure we only do detection of manual-building dependencies
73 # when the user opted in for that.
74 add_subdirectory(manual)
78 # We need to copy all the Sphinx input files to a single directory, and
79 # since some of them are (or will be) generated, we just copy everything
80 # into the build tree, to this directory.
81 set(SPHINX_INPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx-input)
82 set(SPHINX_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/conf.py)
83 set(SPHINX_CONFIG_VARS_FILE ${SPHINX_INPUT_DIR}/conf-vars.py)
84 gmx_configure_version_file(conf-vars.py.cmakein ${SPHINX_CONFIG_VARS_FILE}
86 GMX_CMAKE_MINIMUM_REQUIRED_VERSION REQUIRED_CUDA_VERSION
87 REQUIRED_CUDA_COMPUTE_CAPABILITY REGRESSIONTEST_VERSION
88 SOURCE_MD5SUM REGRESSIONTESTS_MD5SUM
89 COMMENT "Configuring Sphinx configuration file")
90 set(SPHINX_SOURCE_FILES
94 install-guide/index.rst
97 user-guide/getting-started.rst
98 user-guide/cutoff-schemes.rst
99 user-guide/file-formats.rst
101 user-guide/plotje.gif
106 set(SPHINX_INPUT_FILES ${SPHINX_CONFIG_VARS_FILE})
107 foreach(_file ${SPHINX_SOURCE_FILES})
109 OUTPUT ${SPHINX_INPUT_DIR}/${_file}
110 COMMAND ${CMAKE_COMMAND} -E copy
111 ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
112 ${SPHINX_INPUT_DIR}/${_file}
114 ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
115 COMMENT "Copying Sphinx input file ${_file}"
117 list(APPEND SPHINX_INPUT_FILES ${SPHINX_INPUT_DIR}/${_file})
119 gmx_add_custom_output_target(sphinx-input OUTPUT STAMP
120 DEPENDS ${SPHINX_INPUT_FILES})
121 gmx_add_custom_output_target(sphinx-programs OUTPUT STAMP
122 COMMAND ${CMAKE_COMMAND} -E make_directory programs
123 COMMAND gmx -quiet help -export rst
125 WORKING_DIRECTORY ${SPHINX_INPUT_DIR}
126 COMMENT "Generating reStructuredText help")
127 # This dependency ensures that the directories exist before the
128 # executable tries to write things there.
129 add_dependencies(sphinx-programs sphinx-input)
131 # Make the INSTALL file for CPack for the tarball. This gets put
132 # into the tarball via the CPack rules below, which requires that
133 # the INSTALL file is in a separate directory by itself.
134 set(TEXT_INSTALL_GUIDE_OUTPUT_DIR "install-guide/text")
135 add_custom_target(install-guide
139 -w sphinx-install.log
140 -d ${CMAKE_CURRENT_BINARY_DIR}/install-guide/_doctrees
141 -c ${SPHINX_INPUT_DIR}
142 "${SPHINX_INPUT_DIR}/install-guide"
143 "${TEXT_INSTALL_GUIDE_OUTPUT_DIR}"
145 ${CMAKE_COMMAND} -E rename
146 ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/index.txt
147 ${TEXT_INSTALL_GUIDE_OUTPUT_DIR}/INSTALL
149 ${CMAKE_CURRENT_BINARY_DIR}
150 COMMENT "Building INSTALL with Sphinx"
153 add_dependencies(install-guide sphinx-input)
154 gmx_cpack_add_generated_source_directory(install-guide/text DESTINATION /)
156 # For a real build of the webpage, the md5sum of the tarballs must
157 # already be known, and so we may as well require that the real
158 # build of the webpage take place from cmake run from the unpacked
159 # tarball. Then, the *_MD5SUM and *_TARBALL variables will be able
160 # to be set on the cmake command line (e.g. by a Jenkins job
161 # configuration), and we can require that they are set. For local
162 # building of the webpages (e.g. for debugging), those variables
163 # can be left unset, and if so, the download section will not be
165 if(SOURCE_IS_SOURCE_DISTRIBUTION AND GMX_BUILD_WEBPAGE)
166 foreach(VAR SOURCE_MD5SUM REGRESSIONTESTS_MD5SUM SOURCE_TARBALL REGRESSIONTESTS_TARBALL)
167 if(NOT DEFINED ${VAR})
168 message(FATAL_ERROR "The build of the webpage requires that ${VAR} is set in the cmake cache, e.g. on the CMake command line")
171 set(BUILD_DOWNLOAD_SECTION on)
173 if (SOURCE_TARBALL AND SOURCE_MD5SUM AND
174 REGRESSIONTESTS_TARBALL AND REGRESSIONTESTS_MD5SUM)
175 set(BUILD_DOWNLOAD_SECTION on)
177 set(BUILD_DOWNLOAD_SECTION off)
181 # Sphinx cache with pickled ReST documents
182 set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
184 add_custom_target(webpage-sphinx
186 ${CMAKE_COMMAND} -E make_directory ${SPHINX_INPUT_DIR}/_static
191 -d "${SPHINX_CACHE_DIR}"
192 "${SPHINX_INPUT_DIR}"
195 ${CMAKE_CURRENT_BINARY_DIR}
196 COMMENT "Building HTML documentation with Sphinx"
199 add_dependencies(webpage-sphinx sphinx-input sphinx-programs)
201 add_custom_target(man
206 -d ${SPHINX_CACHE_DIR}
209 ${CMAKE_CURRENT_BINARY_DIR}/man
210 COMMENT "Building man pages with Sphinx"
212 add_dependencies(man sphinx-input sphinx-programs)
213 if (NOT SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_HELP)
214 set(MAN_PAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/man)
217 if (SOURCE_IS_SOURCE_DISTRIBUTION OR (GMX_BUILD_HELP AND SPHINX_FOUND))
218 install(DIRECTORY ${MAN_PAGE_DIR}/
219 DESTINATION ${MAN_INSTALL_DIR}/man1
220 COMPONENT man OPTIONAL
221 FILES_MATCHING PATTERN "*.1")
222 install(DIRECTORY ${MAN_PAGE_DIR}/
223 DESTINATION ${MAN_INSTALL_DIR}/man7
224 COMPONENT man OPTIONAL
225 FILES_MATCHING PATTERN "*.7")
227 gmx_cpack_add_generated_source_directory(man)
229 set(HTML_BUILD_IS_POSSIBLE OFF)
230 # We can only configure to build the webpage if the user asked for it,
231 # the build is outside of the source dir, and all the components can
232 # be built. There's no intrinsic need to be talkative if we fail -
233 # most people never need to know, unless they've asked for the webpage
235 if(GMX_BUILD_WEBPAGE)
236 set(HTML_BUILD_IS_POSSIBLE ON)
237 # Next, turn it off in any of the preconditions are unsatisified
239 if(NOT GMX_BUILD_HELP)
240 set(HTML_BUILD_IS_POSSIBLE OFF)
241 message(STATUS "Cannot build webpage without GMX_BUILD_HELP=on")
244 if(NOT MANUAL_BUILD_IS_POSSIBLE)
245 set(HTML_BUILD_IS_POSSIBLE OFF)
246 message(STATUS "Cannot build webpage without being able to build the reference PDF manual")
249 if(NOT PYTHON_EXECUTABLE)
250 set(HTML_BUILD_IS_POSSIBLE OFF)
251 message(STATUS "Cannot build webpage without python")
255 set(HTML_BUILD_IS_POSSIBLE OFF)
256 message(STATUS "Cannot build webpage without sphinx")
259 if(NOT DOXYGEN_EXECUTABLE)
260 set(HTML_BUILD_IS_POSSIBLE OFF)
261 message(STATUS "Cannot build webpage without doxygen")
264 if(NOT DOXYGEN_MSCGEN_EXECUTABLE)
265 set(HTML_BUILD_IS_POSSIBLE OFF)
266 message(STATUS "Cannot build webpage without mscgen")
270 if(HTML_BUILD_IS_POSSIBLE)
271 # If building the webpage from the repo, then tarballs may not
272 # exist, and if so, it would not make sense to build that part of
273 # the front page from index.rst.
274 if(BUILD_DOWNLOAD_SECTION)
275 # Copy the source tarball to the webpage output
277 OUTPUT ${HTML_OUTPUT_DIR}/gromacs-${GMX_VERSION_STRING}.tar.gz
278 COMMAND ${CMAKE_COMMAND}
279 -E copy ${SOURCE_TARBALL} ${HTML_OUTPUT_DIR}/gromacs-${GMX_VERSION_STRING}.tar.gz
283 # Copy the regressiontests tarball to the webpage output
285 OUTPUT ${HTML_OUTPUT_DIR}/regressiontests-${GMX_VERSION_STRING}.tar.gz
286 COMMAND ${CMAKE_COMMAND}
287 -E copy ${REGRESSIONTESTS_TARBALL} ${HTML_OUTPUT_DIR}/regressiontests-${GMX_VERSION_STRING}.tar.gz
291 # Add other dependencies for doing the webpage build from the real
293 list(APPEND extra_webpage_dependencies
294 ${HTML_OUTPUT_DIR}/gromacs-${GMX_VERSION_STRING}.tar.gz
295 ${HTML_OUTPUT_DIR}/regressiontests-${GMX_VERSION_STRING}.tar.gz
299 # Make the PDF reference guide
300 # TODO Try to make the PDF arrive directly in ${HTML_OUTPUT_DIR}
302 OUTPUT ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf
303 COMMAND ${CMAKE_COMMAND}
304 -E remove -f ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf
305 COMMAND ${CMAKE_COMMAND}
306 -E copy ${CMAKE_CURRENT_BINARY_DIR}/manual/gromacs.pdf ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf
307 # UseLATEX.cmake makes a target called pdf, not ${CMAKE_CURRENT_BINARY_DIR}/manual/gromacs.pdf
312 # TODO Move content from the "old" html output into the new user
313 # guide, or delete, as appropriate.
314 if(NOT SOURCE_IS_SOURCE_DISTRIBUTION)
315 # TODO If content remains here once the user guide is in
316 # decent shape, try to make the generated HTML arrive directly
317 # in ${HTML_OUTPUT_DIR}
318 add_custom_target(webpage-html
319 ${CMAKE_COMMAND} -E copy_directory old-html/final ${HTML_OUTPUT_DIR}
321 add_dependencies(webpage-html html)
323 # In the source distribution, the html pages are already
324 # built, so we can avoid making gmx via the html target
325 add_custom_target(webpage-html
326 ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/old-html/final ${HTML_OUTPUT_DIR}
330 # The Doxygen configuration in doxygen/Doxyfile-common.cmakein
331 # makes all the Doxygen output directly in
332 # ${HTML_OUTPUT_DIR}/doxygen (and makes the directory if it needs
335 # Add a top-level target for the others to hook onto
336 add_custom_target(webpage
338 ${HTML_OUTPUT_DIR}/manual-${GMX_VERSION_STRING}.pdf
339 ${extra_webpage_dependencies}
342 add_dependencies(webpage webpage-sphinx webpage-html doxygen-all)
344 add_custom_target(webpage
345 COMMAND ${CMAKE_COMMAND} -E echo "Cannot build webpage because of missing requirements. Check cmake status output for reasons"
346 COMMENT "Webpage build disabled"