Remove cycle suppression
[gromacs.git] / cmake / FindLmfit.cmake
blob5bf489a96f616f9ad340fd1939e652bb01572dcc
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 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 # This package tries to find an external lmfit library. It is intended
36 # to work with pkg-config, because that is the mechanism supported in
37 # lmfit. Upon exit, the following variables may be set:
39 # LMFIT_FOUND       - lmfit was found
40 # LMFIT_INCLUDE_DIR - lmfit include directory
41 # LMFIT_LIBRARIES   - lmfit libraries
42 # LMFIT_LINKS_OK    - lmfit libraries link correctly
43 # LMFIT_VERSION     - lmfit version string as "major.minor"
45 # If you cannot use pkg-config for some reason, then setting
46 # LMFIT_INCLUDE_DIRS and LMFIT_LIBRARY_DIRS on the cmake command line
47 # to suitable values will work.
49 include(CMakePushCheckState)
50 cmake_push_check_state()
52 find_package(PkgConfig QUIET)
53 if(PKG_CONFIG_FOUND)
54     if(LMFIT_FIND_VERSION)
55         # lmfit doesn't support CMake-based find_package version
56         # checking in 6.1, so this code does nothing.
57         if(LMFIT_FIND_VERSION_EXACT)
58             pkg_check_modules(PC_LMFIT lmfit=${LMFIT_FIND_VERSION})
59         else()
60             pkg_check_modules(PC_LMFIT lmfit>=${LMFIT_FIND_VERSION})
61         endif()
62     else()
63         pkg_check_modules(PC_LMFIT lmfit)
64         if (PC_LMFIT_VERSION)
65             string(REGEX REPLACE "^([0-9]+):([0-9]+)" "\\1.\\2" LMFIT_VERSION "${PC_LMFIT_VERSION}")
66         endif()
67     endif()
68 endif()
70 # Try to find lmfit, perhaps with help from pkg-config
71 find_path(LMFIT_INCLUDE_DIRS lmcurve.h HINTS "${PC_LMFIT_INCLUDE_DIRS}" PATH_SUFFIXES include)
72 find_library(LMFIT_LIBRARY_DIRS NAMES lmfit HINTS "${PC_LMFIT_LIBRARY_DIRS}" PATH_SUFFIXES lib64 lib)
74 # Make sure we can also link, so that cross-compilation is properly supported
75 if (LMFIT_INCLUDE_DIRS AND LMFIT_LIBRARY_DIRS)
76     include(CheckCXXSourceCompiles)
77     set(CMAKE_REQUIRED_INCLUDES ${LMFIT_INCLUDE_DIRS})
78     set(CMAKE_REQUIRED_LIBRARIES ${LMFIT_LIBRARY_DIRS})
79     check_cxx_source_compiles("#include <lmcurve.h>\nint main(){lmcurve(0,0,0,0,0,0,0,0);}" LMFIT_LINKS_OK)
80 endif()
82 if (LMFIT_LINKS_OK)
83     set(LMFIT_INCLUDE_DIR ${LMFIT_INCLUDE_DIRS})
84     set(LMFIT_LIBRARIES ${LMFIT_LIBRARY_DIRS})
85 endif()
87 include(FindPackageHandleStandardArgs)
88 find_package_handle_standard_args(lmfit
89     FOUND_VAR
90     LMFIT_FOUND
91     REQUIRED_VARS
92     LMFIT_INCLUDE_DIR
93     LMFIT_LIBRARIES
94     LMFIT_LINKS_OK
95     VERSION_VAR
96     LMFIT_VERSION)
98 mark_as_advanced(LMFIT_INCLUDE_DIRS LMFIT_LIBRARY_DIRS)
100 cmake_pop_check_state()