mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
FindBLAS: Detect implicitly linked BLAS library
Run the Check_Fortran_Libraries macro with an *empty* list of libraries to detect whether the compiler implicitly links BLAS. If this works, set `BLAS_LIBRARIES` to a placeholder value to get through the rest of our logic. At the end replace the placeholder by a real empty string again to report to callers.
This commit is contained in:
committed by
Brad King
parent
2c807b75f3
commit
5b8f69ebe9
@@ -22,7 +22,8 @@
|
||||
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
|
||||
# and -L).
|
||||
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
|
||||
# link against to use BLAS
|
||||
# link against to use BLAS (may be empty if compiler implicitly links
|
||||
# BLAS)
|
||||
# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
|
||||
# to link against to use BLAS95 interface
|
||||
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
|
||||
@@ -163,7 +164,11 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
|
||||
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
|
||||
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
|
||||
endif()
|
||||
if(NOT _libraries_work)
|
||||
if(_libraries_work)
|
||||
if("${_list}" STREQUAL "")
|
||||
set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
|
||||
endif()
|
||||
else()
|
||||
set(${LIBRARIES} FALSE)
|
||||
endif()
|
||||
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
|
||||
@@ -180,6 +185,20 @@ else ()
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
# Implicitly linked BLAS libraries
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
""
|
||||
""
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
# gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
|
||||
@@ -500,6 +519,7 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Generic BLAS library?
|
||||
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
@@ -702,5 +722,11 @@ else()
|
||||
find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines)
|
||||
# we used a placeholder for empty BLAS_LIBRARIES to get through our logic above.
|
||||
if (BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
|
||||
set(BLAS_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
cmake_pop_check_state()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
Reference in New Issue
Block a user