From 875c772d9726d99cbdaad71124b6dccfe8d4e6b8 Mon Sep 17 00:00:00 2001
From: Matthieu Kuhn <mkuhn@scm.gforge.inria.fr>
Date: Fri, 17 Nov 2017 15:53:12 +0100
Subject: [PATCH] Fix TMG: added C function detection when required (e.g. with
 pastix@solverstack)

---
 modules/find/FindTMG.cmake | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/find/FindTMG.cmake b/modules/find/FindTMG.cmake
index 745cb45..860a5c6 100644
--- a/modules/find/FindTMG.cmake
+++ b/modules/find/FindTMG.cmake
@@ -251,7 +251,15 @@ if (LAPACK_FOUND)
 	endif (NOT _LANGUAGES_ MATCHES Fortran)
 	mark_as_advanced(TMG_WORKS)
       endif()
-
+      if (TMG_WORKS)
+        unset(TMG_WORKS CACHE)
+        if (_LANGUAGES_ MATCHES C)
+	  check_function_exists(LAPACKE_zlatms_work TMG_WORKS)
+        endif (_LANGUAGES_ MATCHES C)
+	mark_as_advanced(TMG_WORKS)
+        unset(TMG_WORKS_C CACHE)
+      endif()
+      
       if(TMG_WORKS)
 	# save link with dependencies
 	set(TMG_LIBRARIES_DEP "${REQUIRED_LIBS}")
@@ -263,7 +271,7 @@ if (LAPACK_FOUND)
 	list(REMOVE_DUPLICATES TMG_LINKER_FLAGS)
       else()
 	if(NOT TMG_FIND_QUIETLY)
-	  message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails")
+	  message(STATUS "Looking for tmg: test of dlarnv and dlagsy or LAPACKE_zlatms_work with tmg and lapack libraries fails")
 	  message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
 	  message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
 	  message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
-- 
GitLab