ENH: FindBLAS.cmake&FindLAPACK updated to support intel mkl 10

This commit is contained in:
Alin Elena 2008-03-24 11:49:48 -04:00
parent 05c7777eb7
commit dc108e0dfc
1 changed files with 196 additions and 180 deletions

View File

@ -1,180 +1,196 @@
# - Find LAPACK library # - Find LAPACK library
# This module finds an installed fortran library that implements the LAPACK # This module finds an installed fortran library that implements the LAPACK
# linear-algebra interface (see http://www.netlib.org/lapack/). # linear-algebra interface (see http://www.netlib.org/lapack/).
# #
# The approach follows that taken for the autoconf macro file, acx_lapack.m4 # The approach follows that taken for the autoconf macro file, acx_lapack.m4
# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). # (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
# #
# This module sets the following variables: # This module sets the following variables:
# LAPACK_FOUND - set to true if a library implementing the LAPACK interface # LAPACK_FOUND - set to true if a library implementing the LAPACK interface
# is found # is found
# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l # LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L). # and -L).
# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to # LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK # link against to use LAPACK
# # LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK95
include(CheckFortranFunctionExists)
set(LAPACK_FOUND FALSE) #
macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas) include(CheckFortranFunctionExists)
# This macro checks for the existence of the combination of fortran libraries set(LAPACK_FOUND FALSE)
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas)
# combination using the name of a routine given by _name using the linker # This macro checks for the existence of the combination of fortran libraries
# flags given by _flags. If the combination of libraries is found and passes # given by _list. If the combination is found, this macro checks (using the
# the link test, LIBRARIES is set to the list of complete library paths that # Check_Fortran_Function_Exists macro) whether can link against that library
# have been found. Otherwise, LIBRARIES is set to FALSE. # combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# N.B. _prefix is the prefix applied to the names of all cached variables that # the link test, LIBRARIES is set to the list of complete library paths that
# are generated internally and marked advanced by this macro. # have been found. Otherwise, LIBRARIES is set to FALSE.
set(_libraries_work TRUE) # N.B. _prefix is the prefix applied to the names of all cached variables that
set(${LIBRARIES}) # are generated internally and marked advanced by this macro.
set(_combined_name)
foreach(_library ${_list}) set(_libraries_work TRUE)
set(_combined_name ${_combined_name}_${_library}) set(${LIBRARIES})
set(_combined_name)
if(_libraries_work) foreach(_library ${_list})
if(APPLE) set(_combined_name ${_combined_name}_${_library})
find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library} if(_libraries_work)
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH IF (WIN32)
) find_library(${_prefix}_${_library}_LIBRARY
else(APPLE) NAMES ${_library}
find_library(${_prefix}_${_library}_LIBRARY PATHS ENV LIB
NAMES ${_library} )
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH ENDIF (WIN32)
)
endif(APPLE) if(APPLE)
find_library(${_prefix}_${_library}_LIBRARY
mark_as_advanced(${_prefix}_${_library}_LIBRARY) NAMES ${_library}
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH
set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) )
endif(_libraries_work) else(APPLE)
endforeach(_library ${_list}) find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
if(_libraries_work) PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH
# Test this combination of libraries. )
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas}) endif(APPLE)
#message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) mark_as_advanced(${_prefix}_${_library}_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
mark_as_advanced(${_prefix}${_combined_name}_WORKS) set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif(_libraries_work)
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endforeach(_library ${_list})
endif(_libraries_work)
if(_libraries_work)
if(NOT _libraries_work) # Test this combination of libraries.
set(${LIBRARIES} FALSE) set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas})
endif(NOT _libraries_work) #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
endmacro(Check_Lapack_Libraries) set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
set(LAPACK_LINKER_FLAGS) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
set(LAPACK_LIBRARIES) endif(_libraries_work)
if(NOT _libraries_work)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) set(${LIBRARIES} FALSE)
find_package(BLAS) endif(NOT _libraries_work)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS REQUIRED) endmacro(Check_Lapack_Libraries)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(BLAS_FOUND) set(LAPACK_LINKER_FLAGS)
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) set(LAPACK_LIBRARIES)
set(LAPACK95_LIBRARIES)
#intel lapack
if(NOT LAPACK_LIBRARIES)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
check_lapack_libraries( find_package(BLAS)
LAPACK_LIBRARIES else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
LAPACK find_package(BLAS REQUIRED)
cheev endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
""
"mkl_lapack" if(BLAS_FOUND)
"${BLAS_LIBRARIES}" set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
)
endif(NOT LAPACK_LIBRARIES) #intel lapack
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
#acml lapack LAPACK_LIBRARIES
if(NOT LAPACK_LIBRARIES) LAPACK
cheev
check_lapack_libraries( ""
LAPACK_LIBRARIES "mkl_lapack"
LAPACK "${BLAS_LIBRARIES}"
cheev )
"" endif(NOT LAPACK_LIBRARIES)
"acml"
"${BLAS_LIBRARIES}" if(NOT LAPACK95_LIBRARIES)
) check_lapack_libraries(
endif(NOT LAPACK_LIBRARIES) LAPACK95_LIBRARIES
LAPACK
cheev
# Apple LAPACK library? ""
if(NOT LAPACK_LIBRARIES) "mkl_lapack95"
check_lapack_libraries( "${BLAS_LIBRARIES}"
LAPACK_LIBRARIES )
LAPACK endif(NOT LAPACK95_LIBRARIES)
cheev
"" #acml lapack
"Accelerate" if(NOT LAPACK_LIBRARIES)
"${BLAS_LIBRARIES}"
) check_lapack_libraries(
endif(NOT LAPACK_LIBRARIES) LAPACK_LIBRARIES
LAPACK
if ( NOT LAPACK_LIBRARIES ) cheev
check_lapack_libraries( ""
LAPACK_LIBRARIES "acml"
LAPACK "${BLAS_LIBRARIES}"
cheev )
"" endif(NOT LAPACK_LIBRARIES)
"vecLib"
"${BLAS_LIBRARIES}"
) # Apple LAPACK library?
endif ( NOT LAPACK_LIBRARIES ) if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
# Generic LAPACK library? "Accelerate"
if ( NOT LAPACK_LIBRARIES ) "${BLAS_LIBRARIES}"
check_lapack_libraries( )
LAPACK_LIBRARIES endif(NOT LAPACK_LIBRARIES)
LAPACK
cheev if ( NOT LAPACK_LIBRARIES )
"" check_lapack_libraries(
"lapack" LAPACK_LIBRARIES
"${BLAS_LIBRARIES}" LAPACK
) cheev
endif ( NOT LAPACK_LIBRARIES ) ""
"vecLib"
else(BLAS_FOUND) "${BLAS_LIBRARIES}"
message(STATUS "LAPACK requires BLAS") )
endif(BLAS_FOUND) endif ( NOT LAPACK_LIBRARIES )
if(LAPACK_LIBRARIES) # Generic LAPACK library?
set(LAPACK_FOUND TRUE) if ( NOT LAPACK_LIBRARIES )
else(LAPACK_LIBRARIES) check_lapack_libraries(
set(LAPACK_FOUND FALSE) LAPACK_LIBRARIES
endif(LAPACK_LIBRARIES) LAPACK
cheev
if(NOT LAPACK_FIND_QUIETLY) ""
if(LAPACK_FOUND) "lapack"
message(STATUS "A library with LAPACK API found.") "${BLAS_LIBRARIES}"
else(LAPACK_FOUND) )
if(LAPACK_FIND_REQUIRED) endif ( NOT LAPACK_LIBRARIES )
message(FATAL_ERROR
"A required library with LAPACK API not found. Please specify library location." else(BLAS_FOUND)
) message(STATUS "LAPACK requires BLAS")
else(LAPACK_FIND_REQUIRED) endif(BLAS_FOUND)
message(STATUS
"A library with LAPACK API not found. Please specify library location." if(LAPACK_LIBRARIES)
) set(LAPACK_FOUND TRUE)
endif(LAPACK_FIND_REQUIRED) else(LAPACK_LIBRARIES)
endif(LAPACK_FOUND) set(LAPACK_FOUND FALSE)
endif(NOT LAPACK_FIND_QUIETLY) endif(LAPACK_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY)
if(LAPACK_FOUND)
message(STATUS "A library with LAPACK API found.")
else(LAPACK_FOUND)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with LAPACK API not found. Please specify library location."
)
else(LAPACK_FIND_REQUIRED)
message(STATUS
"A library with LAPACK API not found. Please specify library location."
)
endif(LAPACK_FIND_REQUIRED)
endif(LAPACK_FOUND)
endif(NOT LAPACK_FIND_QUIETLY)