Add initial support for python bindings
[alexxy/gromacs.git] / src / pygromacs / cmake / modules / FindGROMACS.cmake
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2014, 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 # This file should remain version-agnostic, with all things specific to a
36 # particular GROMACS version remaining in the package configuration files.
37 # This find module only provides some convenience functionality to manage the
38 # suffixes etc.
39 # That should allow using the same FindGROMACS.cmake file with multiple
40 # different GROMACS installations on the same machine.
41
42 # Propagate all flags passed to parent find_package() to the config call below.
43 set(_gmx_find_args "")
44 if (GROMACS_FIND_VERSION)
45     if (GROMACS_FIND_VERSION VERSION_LESS "5.1")
46         message(FATAL_ERROR
47             "This version of FindGROMACS.cmake requires GROMACS-provided "
48             "package configuration files, and only works to find "
49             "GROMACS 5.1 or later.")
50     endif()
51     list(APPEND _gmx_find_args ${GROMACS_FIND_VERSION})
52     if (GROMACS_FIND_VERSION_EXACT)
53         list(APPEND _gmx_find_args EXACT)
54     endif()
55 endif()
56 if (GROMACS_FIND_REQUIRED)
57     list(APPEND _gmx_find_args REQUIRED)
58 endif()
59 if (GROMACS_FIND_QUIETLY)
60     list(APPEND _gmx_find_args QUIET)
61 endif()
62
63 # Determine the actual name of the package configuration files.
64 set(_gmx_pkg_name gromacs)
65 if (DEFINED GROMACS_SUFFIX)
66     set(_gmx_pkg_name gromacs${GROMACS_SUFFIX})
67 endif()
68 # Delegate all the actual work to the package configuration files.
69 # The CONFIGS option is not really necessary, but provides a bit better error
70 # messages, since we actually know what the config file should be called.
71 find_package(GROMACS ${_gmx_find_args} CONFIG
72              NAMES ${_gmx_pkg_name}
73              CONFIGS ${_gmx_pkg_name}-config.cmake)
74 unset(_gmx_find_args)
75 unset(_gmx_pkg_name)