2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012,2013, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # 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 if(NOT SOURCE_IS_SOURCE_DISTRIBUTION)
36 if(NOT CMAKE_CROSSCOMPILING)
37 # Defaults to off to avoid breaking the build.
38 # Can be changed if someone finds a nice solution for cases where the
39 # binary does not execute on the compilation host.
40 option(GMX_BUILD_MANPAGES "Build man pages" OFF)
41 mark_as_advanced(GMX_BUILD_MANPAGES)
43 message(STATUS "Building the man pages is not available when "
44 "cross-compiling the developer version from git")
47 # Make sure source package contains all man pages.
48 if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/man1/gmx-view.1")
49 message(FATAL_ERROR "Man pages are missing from source package.")
53 if(GMX_BUILD_MANPAGES)
55 FILE(READ "${CMAKE_SOURCE_DIR}/admin/programs.txt" contents)
57 # Convert file contents into a CMake list. First escape ;
58 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
59 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
62 foreach(line ${contents})
63 if (${line} MATCHES "^HEAD\\|")
64 string(REGEX REPLACE "^HEAD\\|" "" DESC ${line})
65 set(PROGMANPAGES "${PROGMANPAGES}.Sh \"${DESC}\"\n.IX Subsection \"${DESC}\"\n.Vb\n.ta 16n\n")
66 elseif(${line} MATCHES "^END$")
67 set(PROGMANPAGES "${PROGMANPAGES}.Ve\n")
68 elseif(${line} MATCHES "\\|")
69 string(REGEX REPLACE "\\|" "\t" line ${line})
70 set(PROGMANPAGES "${PROGMANPAGES}\\& ${line}\n")
72 message(WARNING "Incorrectly formated line \"${line}\" in programs.txt")
75 configure_file(man7/gromacs.7.cmakein man7/gromacs.7)
76 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man7/gromacs.7
77 DESTINATION ${MAN_INSTALL_DIR}/man7
80 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1)
81 # TODO: It could be nicer to not do this as part of the ALL target,
82 # but instead on demand as part of make install.
83 add_custom_target(man ALL
84 gmx -quiet help -export man
85 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
86 COMMENT "Generating man pages for programs"
88 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1
89 DESTINATION ${MAN_INSTALL_DIR}
91 set_directory_properties(PROPERTIES
92 ADDITIONAL_MAKE_CLEAN_FILES man1)
94 # man pages are only available if they are either build or this is a source archive
95 elseif(SOURCE_IS_SOURCE_DISTRIBUTION)
96 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man7/gromacs.7
97 DESTINATION ${MAN_INSTALL_DIR}/man7
99 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/man1
100 DESTINATION ${MAN_INSTALL_DIR}