Reformat existing LGPL copyright notices.
[alexxy/gromacs.git] / share / man / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2012,2013, 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.
8 #
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.
13 #
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.
18 #
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.
23 #
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.
31 #
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.
34
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)
42     else()
43         message(STATUS "Building the man pages is not available when "
44             "cross-compiling the developer version from git")
45     endif()
46 else()
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.")
50     endif()
51 endif()
52
53 if(GMX_BUILD_MANPAGES)
54     # create gromacs.7
55     FILE(READ "${CMAKE_SOURCE_DIR}/admin/programs.txt" contents)
56
57     # Convert file contents into a CMake list. First escape ;
58     STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
59     STRING(REGEX REPLACE "\n" ";" contents "${contents}")
60
61     set(PROGMANPAGES "")
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")
71         else()
72             message(WARNING "Incorrectly formated line \"${line}\" in programs.txt")
73         endif()
74     endforeach()
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
78         COMPONENT man)
79
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"
87         VERBATIM)
88     install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1
89         DESTINATION ${MAN_INSTALL_DIR}
90         COMPONENT man)
91     set_directory_properties(PROPERTIES
92         ADDITIONAL_MAKE_CLEAN_FILES man1)
93
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
98         COMPONENT man)
99     install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/man1
100         DESTINATION ${MAN_INSTALL_DIR}
101         COMPONENT man)
102 endif()