summaryrefslogtreecommitdiff
path: root/Modules/FindBLAS.cmake
diff options
context:
space:
mode:
authorHubertus van Dam <hvandam@bnl.gov>2018-08-28 11:02:58 -0700
committerBrad King <brad.king@kitware.com>2018-08-30 10:51:20 -0400
commit5b8f69ebe9e82feb8bcd7dade76bb7fa88c8051b (patch)
treea9fc009811592cfc74c84799d66809221dd49fd5 /Modules/FindBLAS.cmake
parent2c807b75f3283d30ecde55be5b434be65d0ea141 (diff)
downloadcmake-5b8f69ebe9e82feb8bcd7dade76bb7fa88c8051b.tar.gz
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.
Diffstat (limited to 'Modules/FindBLAS.cmake')
-rw-r--r--Modules/FindBLAS.cmake30
1 files changed, 28 insertions, 2 deletions
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 5ba7e4fb82..1a89068034 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -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})