ENH: this should fail only if required is sent to find package

This commit is contained in:
Bill Hoffman 2008-07-21 15:11:03 -04:00
parent 834dd533ed
commit e1a2c08628
2 changed files with 215 additions and 206 deletions

View File

@ -18,7 +18,11 @@
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT _LANGUAGES_ MATCHES Fortran) if(NOT _LANGUAGES_ MATCHES Fortran)
message(FATAL_ERROR "FindBLAS is Fortran-only so Fortran must be enabled.") if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR "FindBLAS is Fortran-only so Fortran must be enabled.")
else(BLAS_FIND_REQUIRED)
MESSAGE(STATUS "Looking for BLAS... - NOT found (Fortran not enabled)")
endif(BLAS_FIND_REQUIRED)
endif(NOT _LANGUAGES_ MATCHES Fortran) endif(NOT _LANGUAGES_ MATCHES Fortran)
include(CheckFortranFunctionExists) include(CheckFortranFunctionExists)

View File

@ -1,205 +1,210 @@
# - Find a Fortran LAPACK library # - Find a Fortran LAPACK library
# N.B. Fortran only. This module cannot be used to find a C LAPACK library. # N.B. Fortran only. This module cannot be used to find a C 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 # LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK95 # link against to use LAPACK95
# #
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT _LANGUAGES_ MATCHES Fortran) if(NOT _LANGUAGES_ MATCHES Fortran)
message(FATAL_ERROR "FindLAPACK is Fortran-only so Fortran must be enabled.") if(LAPACK_FIND_REQUIRED)
endif(NOT _LANGUAGES_ MATCHES Fortran) message(FATAL_ERROR
"FindLAPACK is Fortran-only so Fortran must be enabled.")
include(CheckFortranFunctionExists) else(LAPACK_FIND_REQUIRED)
set(LAPACK_FOUND FALSE) MESSAGE(STATUS "Looking for LAPACK... - NOT found (Fortran not enabled)")
endif(LAPACK_FIND_REQUIRED)
macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas) endif(NOT _LANGUAGES_ MATCHES Fortran)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the include(CheckFortranFunctionExists)
# Check_Fortran_Function_Exists macro) whether can link against that library set(LAPACK_FOUND 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 macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas)
# the link test, LIBRARIES is set to the list of complete library paths that # This macro checks for the existence of the combination of fortran libraries
# have been found. Otherwise, LIBRARIES is set to 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
# N.B. _prefix is the prefix applied to the names of all cached variables that # combination using the name of a routine given by _name using the linker
# are generated internally and marked advanced by this macro. # flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
set(_libraries_work TRUE) # have been found. Otherwise, LIBRARIES is set to FALSE.
set(${LIBRARIES})
set(_combined_name) # N.B. _prefix is the prefix applied to the names of all cached variables that
foreach(_library ${_list}) # are generated internally and marked advanced by this macro.
set(_combined_name ${_combined_name}_${_library})
set(_libraries_work TRUE)
if(_libraries_work) set(${LIBRARIES})
IF (WIN32) set(_combined_name)
find_library(${_prefix}_${_library}_LIBRARY foreach(_library ${_list})
NAMES ${_library} set(_combined_name ${_combined_name}_${_library})
PATHS ENV LIB
) if(_libraries_work)
ENDIF (WIN32) IF (WIN32)
find_library(${_prefix}_${_library}_LIBRARY
if(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 DYLD_LIBRARY_PATH ENDIF (WIN32)
)
else(APPLE) if(APPLE)
find_library(${_prefix}_${_library}_LIBRARY find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library} NAMES ${_library}
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH
) )
endif(APPLE) else(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 LD_LIBRARY_PATH
set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) )
endif(_libraries_work) endif(APPLE)
endforeach(_library ${_list})
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
if(_libraries_work) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
# Test this combination of libraries. set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas}) endif(_libraries_work)
#message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") endforeach(_library ${_list})
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
set(CMAKE_REQUIRED_LIBRARIES) if(_libraries_work)
mark_as_advanced(${_prefix}${_combined_name}_WORKS) # Test this combination of libraries.
set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas})
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
endif(_libraries_work) check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
if(_libraries_work) set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
set(${LIBRARIES} ${${LIBRARIES}} ${_blas}) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
else(_libraries_work) endif(_libraries_work)
set(${LIBRARIES} FALSE)
endif(_libraries_work)
if(_libraries_work)
endmacro(Check_Lapack_Libraries) set(${LIBRARIES} ${${LIBRARIES}} ${_blas})
else(_libraries_work)
set(${LIBRARIES} FALSE)
set(LAPACK_LINKER_FLAGS) endif(_libraries_work)
set(LAPACK_LIBRARIES)
set(LAPACK95_LIBRARIES) endmacro(Check_Lapack_Libraries)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) set(LAPACK_LINKER_FLAGS)
find_package(BLAS) set(LAPACK_LIBRARIES)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) set(LAPACK95_LIBRARIES)
find_package(BLAS REQUIRED)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(BLAS_FOUND) find_package(BLAS)
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS REQUIRED)
#intel lapack endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(NOT LAPACK_LIBRARIES)
if(BLAS_FOUND)
check_lapack_libraries( set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
LAPACK_LIBRARIES
LAPACK #intel lapack
cheev if(NOT LAPACK_LIBRARIES)
""
"mkl_lapack" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK_LIBRARIES
) LAPACK
endif(NOT LAPACK_LIBRARIES) cheev
""
if(NOT LAPACK95_LIBRARIES) "mkl_lapack"
check_lapack_libraries( "${BLAS_LIBRARIES}"
LAPACK95_LIBRARIES )
LAPACK endif(NOT LAPACK_LIBRARIES)
cheev
"" if(NOT LAPACK95_LIBRARIES)
"mkl_lapack95" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK95_LIBRARIES
) LAPACK
endif(NOT LAPACK95_LIBRARIES) cheev
""
#acml lapack "mkl_lapack95"
if(NOT LAPACK_LIBRARIES) "${BLAS_LIBRARIES}"
)
check_lapack_libraries( endif(NOT LAPACK95_LIBRARIES)
LAPACK_LIBRARIES
LAPACK #acml lapack
cheev if(NOT LAPACK_LIBRARIES)
""
"acml" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK_LIBRARIES
) LAPACK
endif(NOT LAPACK_LIBRARIES) cheev
""
"acml"
# Apple LAPACK library? "${BLAS_LIBRARIES}"
if(NOT LAPACK_LIBRARIES) )
check_lapack_libraries( endif(NOT LAPACK_LIBRARIES)
LAPACK_LIBRARIES
LAPACK
cheev # Apple LAPACK library?
"" if(NOT LAPACK_LIBRARIES)
"Accelerate" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK_LIBRARIES
) LAPACK
endif(NOT LAPACK_LIBRARIES) cheev
""
if ( NOT LAPACK_LIBRARIES ) "Accelerate"
check_lapack_libraries( "${BLAS_LIBRARIES}"
LAPACK_LIBRARIES )
LAPACK endif(NOT LAPACK_LIBRARIES)
cheev
"" if ( NOT LAPACK_LIBRARIES )
"vecLib" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK_LIBRARIES
) LAPACK
endif ( NOT LAPACK_LIBRARIES ) cheev
""
# Generic LAPACK library? "vecLib"
if ( NOT LAPACK_LIBRARIES ) "${BLAS_LIBRARIES}"
check_lapack_libraries( )
LAPACK_LIBRARIES endif ( NOT LAPACK_LIBRARIES )
LAPACK
cheev # Generic LAPACK library?
"" if ( NOT LAPACK_LIBRARIES )
"lapack" check_lapack_libraries(
"${BLAS_LIBRARIES}" LAPACK_LIBRARIES
) LAPACK
endif ( NOT LAPACK_LIBRARIES ) cheev
""
else(BLAS_FOUND) "lapack"
message(STATUS "LAPACK requires BLAS") "${BLAS_LIBRARIES}"
endif(BLAS_FOUND) )
endif ( NOT LAPACK_LIBRARIES )
if(LAPACK_LIBRARIES)
set(LAPACK_FOUND TRUE) else(BLAS_FOUND)
else(LAPACK_LIBRARIES) message(STATUS "LAPACK requires BLAS")
set(LAPACK_FOUND FALSE) endif(BLAS_FOUND)
endif(LAPACK_LIBRARIES)
if(LAPACK_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY) set(LAPACK_FOUND TRUE)
if(LAPACK_FOUND) else(LAPACK_LIBRARIES)
message(STATUS "A library with LAPACK API found.") set(LAPACK_FOUND FALSE)
else(LAPACK_FOUND) endif(LAPACK_LIBRARIES)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR if(NOT LAPACK_FIND_QUIETLY)
"A required library with LAPACK API not found. Please specify library location." if(LAPACK_FOUND)
) message(STATUS "A library with LAPACK API found.")
else(LAPACK_FIND_REQUIRED) else(LAPACK_FOUND)
message(STATUS if(LAPACK_FIND_REQUIRED)
"A library with LAPACK API not found. Please specify library location." message(FATAL_ERROR
) "A required library with LAPACK API not found. Please specify library location."
endif(LAPACK_FIND_REQUIRED) )
endif(LAPACK_FOUND) else(LAPACK_FIND_REQUIRED)
endif(NOT LAPACK_FIND_QUIETLY) 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)