2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # 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 # Try to find gnu scientific library GSL
37 # http://www.gnu.org/software/gsl/ and
38 # http://gnuwin32.sourceforge.net/packages/gsl.htm
40 # Once run this will define:
42 # GSL_FOUND = system has GSL lib
44 # GSL_LIBRARIES = full path to the libraries
45 # on Unix/Linux with additional linker flags from "gsl-config --libs"
47 # CMAKE_GSL_CXX_FLAGS = Unix compiler flags for GSL, essentially "`gsl-config --cxxflags`"
49 # GSL_INCLUDE_DIR = where to find headers
51 # GSL_LINK_DIRECTORIES = link directories, useful for rpath on Unix
52 # GSL_EXE_LINKER_FLAGS = rpath on Unix
57 # www.mip.informatik.uni-kiel.de
58 # --------------------------------
61 # JW tested with gsl-1.8, Windows XP, MSVS 7.1, MSVS 8.0
62 SET(GSL_POSSIBLE_ROOT_DIRS
69 $ENV{EXTERN_LIBS_DIR}/gsl
72 FIND_PATH(GSL_INCLUDE_DIR
73 NAMES gsl/gsl_cdf.h gsl/gsl_randist.h
74 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
76 DOC "GSL header include dir"
79 FIND_LIBRARY(GSL_GSL_LIBRARY
81 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
83 DOC "GSL library dir" )
85 FIND_LIBRARY(GSL_GSLCBLAS_LIBRARY
86 NAMES gslcblas libgslcblas
87 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
89 DOC "GSL cblas library dir" )
91 SET(GSL_LIBRARIES ${GSL_GSL_LIBRARY})
94 # "GSL_GSL_LIBRARY=${GSL_GSL_LIBRARY}\n"
95 # "GSL_GSLCBLAS_LIBRARY=${GSL_GSLCBLAS_LIBRARY}\n"
96 # "GSL_LIBRARIES=${GSL_LIBRARIES}")
102 SET(GSL_CONFIG_PREFER_PATH
107 CACHE STRING "preferred path to GSL (gsl-config)")
108 FIND_PROGRAM(GSL_CONFIG gsl-config
109 ${GSL_CONFIG_PREFER_PATH}
112 # MESSAGE("DBG GSL_CONFIG ${GSL_CONFIG}")
116 MESSAGE(STATUS "GSL using gsl-config ${GSL_CONFIG}")
117 # set CXXFLAGS to be fed into CXX_FLAGS by the user:
118 EXEC_PROGRAM(${GSL_CONFIG}
120 OUTPUT_VARIABLE GSL_CXX_FLAGS )
121 #SET(GSL_CXX_FLAGS "`${GSL_CONFIG} --cflags`")
123 # set INCLUDE_DIRS to prefix+include
124 EXEC_PROGRAM(${GSL_CONFIG}
126 OUTPUT_VARIABLE GSL_PREFIX)
127 SET(GSL_INCLUDE_DIR ${GSL_PREFIX}/include CACHE STRING INTERNAL)
129 # set link libraries and link flags
131 #SET(GSL_LIBRARIES "`${GSL_CONFIG} --libs`")
133 # extract link dirs for rpath
134 EXEC_PROGRAM(${GSL_CONFIG}
136 OUTPUT_VARIABLE GSL_CONFIG_LIBS )
137 SET(GSL_LIBRARIES "${GSL_CONFIG_LIBS}")
139 # split off the link dirs (for rpath)
140 # use regular expression to match wildcard equivalent "-L*<endchar>"
141 # with <endchar> is a space or a semicolon
142 STRING(REGEX MATCHALL "[-][L]([^ ;])+"
143 GSL_LINK_DIRECTORIES_WITH_PREFIX
144 "${GSL_CONFIG_LIBS}" )
145 # MESSAGE("DBG GSL_LINK_DIRECTORIES_WITH_PREFIX=${GSL_LINK_DIRECTORIES_WITH_PREFIX}")
147 # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
149 IF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
150 STRING(REGEX REPLACE "[-][L]" "" GSL_LINK_DIRECTORIES ${GSL_LINK_DIRECTORIES_WITH_PREFIX} )
151 ENDIF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
152 SET(GSL_EXE_LINKER_FLAGS "-Wl,-rpath,${GSL_LINK_DIRECTORIES}" CACHE STRING INTERNAL)
153 # MESSAGE("DBG GSL_LINK_DIRECTORIES=${GSL_LINK_DIRECTORIES}")
154 # MESSAGE("DBG GSL_EXE_LINKER_FLAGS=${GSL_EXE_LINKER_FLAGS}")
156 # ADD_DEFINITIONS("-DHAVE_GSL")
157 # SET(GSL_DEFINITIONS "-DHAVE_GSL")
165 MESSAGE(STATUS "Using GSL from ${GSL_PREFIX}")
169 INCLUDE(UsePkgConfig) #needed for PKGCONFIG(...)
171 MESSAGE(STATUS "GSL using pkgconfig")
172 # PKGCONFIG(gsl includedir libdir linkflags cflags)
173 PKGCONFIG(gsl GSL_INCLUDE_DIR GSL_LINK_DIRECTORIES GSL_LIBRARIES GSL_CXX_FLAGS)
181 ENDIF(GSL_INCLUDE_DIR)
189 IF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
193 ENDIF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
197 # ==========================================
199 # make FIND_PACKAGE friendly
200 IF(NOT GSL_FIND_QUIETLY)
201 IF(GSL_FIND_REQUIRED)
202 MESSAGE(FATAL_ERROR "GSL required, please specify it's location.")
203 ELSE(GSL_FIND_REQUIRED)
204 MESSAGE(STATUS "GSL was not found.")
205 ENDIF(GSL_FIND_REQUIRED)
206 ENDIF(NOT GSL_FIND_QUIETLY)