1# - Try to find LAPACK and BLAS libraries
2# Once done, this will define
3#  LAPACKLIBS_LIBRARIES, all libraries to link against
4#  LAPACKLIBS_FOUND, If false, do not try to use LAPACK library features.
5#
6# Users may wish to set:
7#  LAPACKLIBS_ROOT_DIR, location to start searching for LAPACK libraries
8#
9# Original Author:
10# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
11# http://academic.cleardefinition.com
12# Iowa State University HCI Graduate Program/VRAC
13#
14# Copyright Iowa State University 2009-2010.
15# Distributed under the Boost Software License, Version 1.0.
16# (See accompanying file LICENSE_1_0.txt or copy at
17# http://www.boost.org/LICENSE_1_0.txt)
18
19set(_check)
20
21set(LAPACKLIBS_ROOT_DIR
22	"${LAPACKLIBS_ROOT_DIR}"
23	CACHE
24	PATH
25	"Directory to search for LAPACK libraries")
26
27if(APPLE)
28	find_library(LAPACKLIBS_VECLIB_FRAMEWORK veclib)
29	find_library(LAPACKLIBS_ACCELERATE_FRAMEWORK accelerate)
30	mark_as_advanced(LAPACKLIBS_VECLIB_FRAMEWORK
31		LAPACKLIBS_ACCELERATE_FRAMEWORK)
32
33	set(LAPACKLIBS_LIBRARIES
34		"${LAPACKLIBS_VECLIB_FRAMEWORK}"
35		"${LAPACKLIBS_ACCELERATE_FRAMEWORK}")
36	list(APPEND
37		_check
38		LAPACKLIBS_VECLIB_FRAMEWORK
39		LAPACKLIBS_ACCELERATE_FRAMEWORK)
40elseif(WIN32)
41	# Tested to work with the files from http://www.fi.muni.cz/~xsvobod2/misc/lapack/
42	# You might also see http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html for
43	# the libraries and headers.
44
45	# Good luck!
46
47	find_library(LAPACKLIBS_LAPACK_LIBRARY
48		NAMES
49		lapack_win32_MT
50		lapack
51		lapackd
52		HINTS
53		${LAPACKLIBS_ROOT_DIR}
54		PATH_SUFFIXES
55		lapack-MT-release
56		lapack-MT-debug
57		lib)
58	find_library(LAPACKLIBS_BLAS_LIBRARY
59		NAMES
60		blas_win32_MT
61		blas
62		blasd
63		HINTS
64		${LAPACKLIBS_ROOT_DIR}
65		PATH_SUFFIXES
66		lapack-MT-release
67		lapack-MT-debug
68		lib)
69	set(LAPACKLIBS_LIBRARIES
70		"${LAPACKLIBS_LAPACK_LIBRARY}"
71		"${LAPACKLIBS_BLAS_LIBRARY}")
72	list(APPEND _check LAPACKLIBS_LAPACK_LIBRARY LAPACKLIBS_BLAS_LIBRARY)
73elseif(UNIX)
74	# All other Linux/Unix should have lapack without a fuss
75	list(APPEND _check LAPACKLIBS_LAPACK_LIBRARY)
76	find_library(LAPACKLIBS_LAPACK_LIBRARY lapack)
77	set(LAPACKLIBS_LIBRARIES "${LAPACKLIBS_LAPACK_LIBRARY}")
78endif()
79
80# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
81# all listed variables are TRUE
82include(FindPackageHandleStandardArgs)
83find_package_handle_standard_args(LAPACKLibs
84	DEFAULT_MSG
85	${_check})
86
87if(LAPACKLIBS_FOUND)
88	mark_as_advanced(LAPACKLIBS_ROOT_DIR
89		LAPACKLIBS_LAPACK_LIBRARY
90		LAPACKLIBS_BLAS_LIBRARY)
91endif()
92