Commit 03aea106 authored by Davis King's avatar Davis King

Added some logic to find and link LAPACK libraries.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403821
parent 0597e537
......@@ -51,6 +51,8 @@ set (DLIB_ENABLE_ASSERTS_STR
"Enable this if you want to turn on the DLIB_ASSERT macro" )
set (DLIB_USE_BLAS_STR
"Disable this if you don't want to use a BLAS library" )
set (DLIB_USE_LAPACK_STR
"Disable this if you don't want to use a LAPACK library" )
set (DLIB_LINK_WITH_LIBPNG_STR
"Disable this if you don't want to link against libpng" )
......@@ -59,6 +61,7 @@ option(DLIB_NO_GUI_SUPPORT ${DLIB_NO_GUI_SUPPORT_STR} OFF)
option(DLIB_ENABLE_STACK_TRACE ${DLIB_ENABLE_STACK_TRACE_STR} OFF)
option(DLIB_ENABLE_ASSERTS ${DLIB_ENABLE_ASSERTS_STR} OFF)
option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON)
option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON)
option(DLIB_LINK_WITH_LIBPNG ${DLIB_LINK_WITH_LIBPNG_STR} ON)
......@@ -148,9 +151,11 @@ if (NOT DLIB_ISO_CPP_ONLY)
endif()
if (DLIB_USE_BLAS)
# Try to find a BLAS library
if (DLIB_USE_BLAS OR DLIB_USE_LAPACK)
# Try to find BLAS and LAPACK
include(cmake_find_blas.txt)
if (DLIB_USE_BLAS)
if (blas_found)
set (dlib_needed_libraries ${dlib_needed_libraries} ${blas_libraries})
else()
......@@ -158,6 +163,15 @@ if (NOT DLIB_ISO_CPP_ONLY)
endif()
endif()
if (DLIB_USE_LAPACK)
if (lapack_found)
set (dlib_needed_libraries ${dlib_needed_libraries} ${lapack_libraries})
else()
set(DLIB_USE_LAPACK OFF CACHE STRING ${DLIB_USE_LAPACK_STR} FORCE )
endif()
endif()
endif()
target_link_libraries(dlib ${dlib_needed_libraries} )
......@@ -183,6 +197,12 @@ else()
remove_global_define(DLIB_USE_BLAS)
endif()
if (DLIB_USE_LAPACK AND lapack_found)
add_global_define(DLIB_USE_LAPACK)
else()
remove_global_define(DLIB_USE_LAPACK)
endif()
if (DLIB_ISO_CPP_ONLY)
add_global_define(DLIB_ISO_CPP_ONLY)
......
......@@ -3,12 +3,14 @@
# information about it at http://www.cmake.org
#
#
# This cmake file tries to find an installed BLAS library. It looks
# for an installed copy of the Intel MKL library first and then
# attempts to find some other BLAS library.
# This cmake file tries to find an installed BLAS and LAPACK libraries.
# It looks for an installed copy of the Intel MKL library first and then
# attempts to find some other BLAS and LAPACK libraries.
#
# blas_found - True if BLAS is available
# lapack_found - True if LAPACK is available
# blas_libraries - link against these to use BLAS library
# lapack_libraries - link against these to use LAPACK library
# setting this makes CMake allow normal looking if else statements
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
......@@ -17,7 +19,7 @@ SET(blas_found 0)
if (UNIX)
message(STATUS "Searching for a BLAS library")
message(STATUS "Searching for BLAS and LAPACK")
include(CheckTypeSize)
check_type_size( "void*" SIZE_OF_VOID_PTR)
......@@ -48,8 +50,23 @@ if (UNIX)
# if we found the MKL
if (mkl_mkl AND mkl_core AND mkl_guide AND mkl_pthread)
set(blas_libraries ${mkl_mkl} ${mkl_core} ${mkl_guide} ${mkl_pthread})
set(lapack_libraries ${mkl_mkl} ${mkl_core} ${mkl_guide} ${mkl_pthread})
set(blas_found 1)
message(STATUS "Found Intel MKL BLAS library")
set(lapack_found 1)
message(STATUS "Found Intel MKL BLAS/LAPACK library")
endif()
# try to find some other LAPACK libraries if we didn't find the MKL
if (NOT lapack_found)
find_library(lapack_lib lapack)
if (lapack_lib)
set(lapack_libraries ${lapack_lib})
set(lapack_found 1)
message(STATUS "Found LAPACK library")
endif()
mark_as_advanced( lapack_lib)
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment