Add some missing copyright headers.
[alexxy/gromacs.git] / admin / includedeps.cmake
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 function (generate_module_file_list SRCDIR OUTFILE)
36     set(PATH_LIST)
37     foreach (MODULE analysisdata commandline linearalgebra onlinehelp
38                     options selection trajectoryanalysis utility)
39         list(APPEND PATH_LIST "${SRCDIR}/src/gromacs/${MODULE}/*.cpp")
40         list(APPEND PATH_LIST "${SRCDIR}/src/gromacs/${MODULE}/*.h")
41     endforeach ()
42     list(APPEND PATH_LIST "${SRCDIR}/src/testutils/*.cpp")
43     list(APPEND PATH_LIST "${SRCDIR}/src/testutils/*.h")
44     set(FILE_LIST)
45     foreach (PATH_EXPR ${PATH_LIST})
46         file(GLOB_RECURSE FOUND_FILES ${PATH_EXPR})
47         list(APPEND FILE_LIST ${FOUND_FILES})
48     endforeach ()
49     string(REPLACE ";" "\n" FILE_LIST "${FILE_LIST}")
50     file(WRITE ${OUTFILE} "${FILE_LIST}")
51 endfunction ()
52
53 function (generate_installed_file_list SRCDIR BUILDDIR OUTFILE)
54     file(GLOB_RECURSE INSTALL_FILE_LIST "${BUILDDIR}/cmake_install.cmake")
55     set(MATCH_REGEX "${SRCDIR}/.*\\.h")
56     set(HEADER_LIST)
57     foreach (INSTALL_FILE ${INSTALL_FILE_LIST})
58         file(STRINGS ${INSTALL_FILE} HEADER_LINES REGEX "${MATCH_REGEX}")
59         foreach (HEADER_LINE ${HEADER_LINES})
60             string (REGEX MATCH "${MATCH_REGEX}" HEADER "${HEADER_LINE}")
61             list(APPEND HEADER_LIST "${HEADER}")
62         endforeach ()
63     endforeach ()
64     string(REPLACE ";" "\n" HEADER_LIST "${HEADER_LIST}")
65     file(WRITE ${OUTFILE} "${HEADER_LIST}")
66 endfunction ()
67
68 if (NOT DEFINED SRCDIR OR NOT DEFINED BUILDDIR OR NOT DEFINED OUTDIR)
69     message(FATAL_ERROR "Required input variable (SRCDIR, BUILDDIR, OUTDIR) not set")
70 endif ()
71
72 if (NOT DEFINED PYTHON_EXECUTABLE)
73     set(PYTHON_EXECUTABLE python)
74 endif ()
75
76 if (NOT DEFINED MODE OR MODE STREQUAL "CHECK")
77     set(GRAPHOPTIONS)
78 elseif (MODE STREQUAL "GRAPHS")
79     set(GRAPHOPTIONS
80         --module-graph module-deps.dot --module-file-graphs
81         -o ${OUTDIR})
82 else ()
83     message(FATAL_ERROR "Unknown mode ${MODE}")
84 endif ()
85
86 file(MAKE_DIRECTORY ${OUTDIR})
87 generate_module_file_list(${SRCDIR} ${OUTDIR}/module-files.txt)
88 generate_installed_file_list(${SRCDIR} ${BUILDDIR} ${OUTDIR}/installed-headers.txt)
89 execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SRCDIR}/admin/includedeps.py
90                         -f ${OUTDIR}/module-files.txt
91                         --installed ${OUTDIR}/installed-headers.txt
92                         -R ${SRCDIR}/src -R ${BUILDDIR}/src
93                         #-I ${SRCDIR}/src/gromacs/legacyheaders
94                         -I ${BUILDDIR}/src/gromacs/utility
95                         ${GRAPHOPTIONS})
96
97 if (MODE STREQUAL "GRAPHS" AND DOT_EXECUTABLE)
98     file(GLOB DOT_INPUT_FILES ${OUTDIR}/*.dot)
99     execute_process(COMMAND ${DOT_EXECUTABLE} -Tpng -O ${DOT_INPUT_FILES})
100 endif ()