Merge topic 'implicit_lapack_library'

68dcbeee01 FindLAPACK: Test for implicitly linked LAPACK libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3451
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index c9c3cce..844d36d 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -173,11 +173,15 @@
   #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
 endif()
 
-if(_libraries_work)
-  set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
-else()
-  set(${LIBRARIES} FALSE)
-endif()
+ if(_libraries_work)
+   if("${_list}" STREQUAL "")
+     set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+   else()
+     set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
+   endif()
+ else()
+    set(${LIBRARIES} FALSE)
+ endif()
 
 endmacro()
 
@@ -206,6 +210,7 @@
 
 #intel lapack
 if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
+  if(NOT LAPACK_LIBRARIES)
   if (NOT WIN32)
     set(LAPACK_mkl_LM "-lm")
     set(LAPACK_mkl_LDL "-ldl")
@@ -280,6 +285,7 @@
     unset(LAPACK_mkl_LM)
     unset(LAPACK_mkl_LDL)
   endif ()
+  endif()
 endif()
 
 if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
@@ -426,5 +432,11 @@
   endif()
 endif()
 
+# On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines)
+# we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above.
+if (LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+  set(LAPACK_LIBRARIES "")
+endif()
+
 cmake_pop_check_state()
 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})