Enable uncrustify for OpenCL
[gromacs.git] / src / gromacs / gromacs-config.cmake.cmakein
blob116b24fe71f4a56823d27fbf4915e8306d5af48c
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2014,2016, 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.
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 set(_gmx_cmake_dir ${CMAKE_CURRENT_LIST_DIR})
36 get_filename_component(_gmx_root_dir "${_gmx_cmake_dir}" PATH)
37 get_filename_component(_gmx_root_dir "${_gmx_root_dir}" PATH)
38 get_filename_component(_gmx_root_dir "${_gmx_root_dir}" PATH)
40 # Find the exported targets (file name depends on whether shared or static
41 # libraries were built to allow both to coexist in the same prefix), and
42 # import them.
43 set(_gmx_import_file ${_gmx_cmake_dir}/libgromacs.cmake)
44 if (GROMACS_PREFER_STATIC OR NOT EXISTS ${_gmx_import_file})
45     set(_gmx_import_file_static ${_gmx_cmake_dir}/libgromacs_static.cmake)
46     if (EXISTS ${_gmx_import_file_static})
47         set(_gmx_import_file ${_gmx_import_file_static})
48     endif()
49     unset(_gmx_import_file_static)
50 endif()
51 if (NOT EXISTS ${_gmx_import_file})
52     message(FATAL_ERROR
53         "The GROMACS installation at ${_gmx_root_dir} does not contain "
54         "libgromacs.cmake or libgromacs_static.cmake to define the imported "
55         "targets.")
56 endif()
57 include(${_gmx_import_file})
58 unset(_gmx_import_file)
60 get_target_property(_libs libgromacs INTERFACE_LINK_LIBRARIES)
61 if (_libs MATCHES "tng_io::tng_io")
62     include(CMakeFindDependencyMacro)
63     find_dependency(TNG_IO)
64 endif()
65 unset(_libs)
67 set(GROMACS_INCLUDE_DIRS)
68 set(_include_dirs "@INSTALLED_HEADER_INCLUDE_DIRS@")
69 foreach (_dir ${_include_dirs})
70     if (IS_ABSOLUTE ${_dir})
71         list(APPEND GROMACS_INCLUDE_DIRS ${_dir})
72     else()
73         list(APPEND GROMACS_INCLUDE_DIRS ${_gmx_root_dir}/${_dir})
74     endif()
75 endforeach()
76 set(GROMACS_LIBRARIES libgromacs @GMX_STDLIB_LIBRARIES@)
77 set(GROMACS_DEFINITIONS @INSTALLED_HEADER_DEFINITIONS@)
78 set(GROMACS_IS_DOUBLE @GMX_DOUBLE@)
79 if (DEFINED GROMACS_SUFFIX AND NOT "${GROMACS_SUFFIX}" STREQUAL "@GMX_LIBS_SUFFIX@")
80     message(FATAL_ERROR "GROMACS_SUFFIX is set inconsistently, expected '@GMX_LIBS_SUFFIX@'")
81 endif()
82 set(GROMACS_SUFFIX "@GMX_LIBS_SUFFIX@")
83 set(GROMACS_CXX_COMPILER "@GROMACS_CXX_COMPILER@")
84 set(GROMACS_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
85 set(GROMACS_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
86 set(GROMACS_CXX_FLAGS "@GMX_CXX11_FLAGS@ @GMX_STDLIB_CXX_FLAGS@")
88 # Produce a message, since find_package() prints nothing on success.
89 include(FindPackageMessage)
90 # The version info is set by CMake when it determines whether this file
91 # is suitable (by calling the version file, which sets PACKAGE_VERSION).
92 # TODO: Make also the full version string available from somewhere.
93 set(_gmx_info "${GROMACS_VERSION}")
94 if (GROMACS_SUFFIX)
95     set(_gmx_info "${_gmx_info} (suffix: ${GROMACS_SUFFIX})")
96 endif()
97 find_package_message(GROMACS "Found GROMACS: ${_gmx_info}" "${CMAKE_CURRENT_LIST_FILE}")
99 unset(_gmx_cmake_dir)
100 unset(_gmx_root_dir)
101 unset(_gmx_info)
103 #####################################################################
104 # Macros for use in calling code
106 # This does not work as a function if called as gromacs_check_double(GMX_DOUBLE)
107 # (i.e., with the parameter value equal to the formal parameter name) because
108 # of scoping rules.
109 macro (gromacs_check_double GMX_DOUBLE)
110     if (${GMX_DOUBLE} AND NOT GROMACS_IS_DOUBLE)
111         message(FATAL_ERROR
112             "The found GROMACS installation is compiled in mixed precision, "
113             "but double-precision compilation was requested with ${GMX_DOUBLE}=${${GMX_DOUBLE}}")
114     elseif (NOT ${GMX_DOUBLE} AND GROMACS_IS_DOUBLE)
115         message(FATAL_ERROR
116             "The found GROMACS installation is compiled in double precision, "
117             "but mixed-precision compilation was requested with ${GMX_DOUBLE}=${${GMX_DOUBLE}}")
118     endif()
119 endmacro()
121 function (gromacs_check_compiler LANG)
122     if (NOT LANG STREQUAL CXX)
123         message(FATAL_ERROR
124             "gromacs_check_compiler(CXX) is currently the only supported call")
125     endif()
126     # Deal with possible symlinks (it is fine if one of the used compilers was
127     # a symlink to another one).
128     get_filename_component(_cmake_compiler_realpath ${CMAKE_${LANG}_COMPILER} REALPATH)
129     if (NOT "${_cmake_compiler_realpath}" STREQUAL "${GROMACS_${LANG}_COMPILER}" OR
130         NOT "${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "${GROMACS_${LANG}_COMPILER_ID}" OR
131         NOT "${CMAKE_${LANG}_COMPILER_VERSION}" STREQUAL "${GROMACS_${LANG}_COMPILER_VERSION}")
132         message(WARNING
133             "You are compiling with a different C++ compiler from the one that was "
134             "used to compile GROMACS. This may lead to linking or runtime problems. "
135             "GROMACS was compiled with "
136             "${GROMACS_${LANG}_COMPILER_ID} ${GROMACS_${LANG}_COMPILER_VERSION} "
137             "(${GROMACS_${LANG}_COMPILER}).")
138     endif()
139 endfunction()