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.
37 EXECUTE_PROCESS(COMMAND "date" "+%F" OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE)
39 set(${RESULT} "????-??-??")
43 if(GMX_BUILD_MANPAGES)
44 set(MAN1_PATH ${CMAKE_BINARY_DIR}/man/man1)
45 file(MAKE_DIRECTORY ${MAN1_PATH})
48 FILE(READ "${CMAKE_SOURCE_DIR}/admin/programs.txt" contents)
50 # Convert file contents into a CMake list. First escape ;
51 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
52 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
55 foreach(line ${contents})
56 if (${line} MATCHES "^HEAD\\|")
57 string(REGEX REPLACE "^HEAD\\|" "" DESC ${line})
58 set(PROGMANPAGES "${PROGMANPAGES}.Sh \"${DESC}\"\n.IX Subsection \"${DESC}\"\n.Vb\n.ta 16n\n")
59 elseif(${line} MATCHES "^END$")
60 set(PROGMANPAGES "${PROGMANPAGES}.Ve\n")
61 elseif(${line} MATCHES "\\|")
62 string(REGEX REPLACE "\\|" "\t" line ${line})
63 set(PROGMANPAGES "${PROGMANPAGES}\\& ${line}\n")
65 message(WARNING "Incorrectly formated line \"${line}\" in programs.txt")
69 configure_file(${CMAKE_SOURCE_DIR}/man/man7/gromacs.7.cmakein ${CMAKE_BINARY_DIR}/man/man7/gromacs.7)
70 install(FILES ${CMAKE_BINARY_DIR}/man/man7/gromacs.7 DESTINATION
71 ${MAN_INSTALL_DIR}/man7)
72 #man-pages are only avalaible if they are either build or this is a source archive
73 elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/admin/.isreposource")
74 install(FILES ${CMAKE_SOURCE_DIR}/man/man7/gromacs.7 DESTINATION
75 ${MAN_INSTALL_DIR}/man7)
78 function (gmx_add_man_page EXENAME)
79 if(GMX_BUILD_MANPAGES)
80 file(STRINGS ${CMAKE_SOURCE_DIR}/admin/programs.txt DESC
81 REGEX "^${EXENAME}\\|" LIMIT_COUNT 1)
82 #Regex breaks with a "|" in description. Cmake doesn't support
84 string(REGEX REPLACE "^.*\\|" "" DESC "${DESC}")
86 message(WARNING "Missing description for ${EXENAME}")
88 add_custom_command(TARGET ${EXENAME} POST_BUILD
89 #The redirect is a hack to avoid showing copyright.
90 #Ideally -quiet would also cause programs to not print copyright.
91 COMMAND ${CMAKE_COMMAND} -DINFILE=${EXENAME}${GMX_BINARY_SUFFIX}.nroff
92 -DOUTFILE=${MAN1_PATH}/${EXENAME}.1 -DDESC=" - ${DESC}"
93 -DEXENAME=${EXENAME}${GMX_BINARY_SUFFIX}
94 -P ${CMAKE_SOURCE_DIR}/cmake/CreateManPage.cmake)
95 install(FILES ${MAN1_PATH}/${EXENAME}.1 DESTINATION
96 ${MAN_INSTALL_DIR}/man1 OPTIONAL)
97 elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/admin/.isreposource")
98 install(FILES ${CMAKE_SOURCE_DIR}/man/man1/${EXENAME}.1 DESTINATION
99 ${MAN_INSTALL_DIR}/man1)