1#
2# @copyright (c) 2009-2014 The University of Tennessee and The University of
3# Tennessee Research Foundation. All rights reserved. @copyright (c) 2012-2016
4# Inria. All rights reserved. @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI
5# UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
6#
7# * Find SCALAPACK library This module finds an installed fortran library that
8#   implements the SCALAPACK linear-algebra interface.
9#
10# This module sets the following variables: SCALAPACK_FOUND - set to true if a
11# library implementing the SCALAPACK interface is found SCALAPACK_LINKER_FLAGS -
12# uncached list of required linker flags (excluding -l and -L).
13# SCALAPACK_LIBRARIES - uncached list of libraries (using full path name) to
14# link against to use SCALAPACK SCALAPACK95_LIBRARIES - uncached list of
15# libraries (using full path name) to link against to use SCALAPACK95
16# SCALAPACK95_FOUND - set to true if a library implementing the SCALAPACK f95
17# interface is found BLA_STATIC  if set on this determines what kind of linkage
18# we do (static) BLA_VENDOR  if set checks only the specified vendor, if not set
19# checks all the possibilities BLA_F95     if set on tries to find the f95
20# interfaces for BLAS/SCALAPACK The user can give specific paths where to find
21# the libraries adding cmake options at configure (ex: cmake path/to/project
22# -DSCALAPACK_DIR=path/to/scalapack): SCALAPACK_DIR            - Where to find
23# the base directory of scalapack SCALAPACK_INCDIR         - Where to find the
24# header files SCALAPACK_LIBDIR         - Where to find the library files The
25# module can also look for the following environment variables if paths are not
26# given as cmake variable: SCALAPACK_DIR, SCALAPACK_INCDIR, SCALAPACK_LIBDIR
27# Note that if BLAS_DIR is set, it will also look for scalapack in it List of
28# vendors (BLA_VENDOR) valid in this module Intel(mkl), ACML, Apple, NAS,
29# Generic
30
31# =============================================================================
32# Copyright 2007-2009 Kitware, Inc.
33#
34# Distributed under the OSI-approved BSD License (the "License"); see
35# accompanying file Copyright.txt for details.
36#
37# This software is distributed WITHOUT ANY WARRANTY; without even the implied
38# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# License for more information.
40# =============================================================================
41# (To distribute this file outside of CMake, substitute the full License text
42# for the above reference.)
43
44# Some macros to print status when search for headers and libs This macro
45# informs why the _lib_to_find file has not been found
46macro(Print_Find_Library_Blas_Status _libname _lib_to_find)
47
48  # save _libname upper/lower case
49  string(TOUPPER ${_libname} LIBNAME)
50  string(TOLOWER ${_libname} libname)
51
52  # print status message(" ")
53  if(${LIBNAME}_LIBDIR)
54    message("${Yellow}${LIBNAME}_LIBDIR is defined but ${_lib_to_find}"
55            "has not been found in ${ARGN}${ColourReset}")
56  else()
57    if(${LIBNAME}_DIR)
58      message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}"
59              "has not been found in ${ARGN}${ColourReset}")
60    else()
61      message(
62        "${Yellow}${_lib_to_find} not found."
63        "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR"
64        "are defined so that we look for ${_lib_to_find} in"
65        "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB,"
66        "Mac: DYLD_LIBRARY_PATH,"
67        "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES,"
68        "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}")
69      if(_lib_env)
70        message("${Yellow}${_lib_to_find} has not been found in"
71                "${_lib_env}${ColourReset}")
72      endif()
73    endif()
74  endif()
75  message(
76    "${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\n"
77    "- Option 1: Provide the installation directory of the library with cmake option: -D${LIBNAME}_DIR=your/path/to/${libname}/\n"
78    "- Option 2: Provide the directory where to find the library with cmake option: -D${LIBNAME}_LIBDIR=your/path/to/${libname}/lib/\n"
79    "- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
80    "- Option 4: If your library provides a PkgConfig file, make sure pkg-config finds your library${ColourReset}"
81  )
82
83endmacro()
84
85if(NOT SCALAPACK_FOUND)
86  set(SCALAPACK_DIR
87      ""
88      CACHE PATH "Installation directory of SCALAPACK library")
89  if(NOT SCALAPACK_FIND_QUIETLY)
90    message(
91      STATUS
92        "A cache variable, namely SCALAPACK_DIR, has been set to specify the install directory of SCALAPACK"
93    )
94  endif()
95endif(NOT SCALAPACK_FOUND)
96
97option(SCALAPACK_VERBOSE "Print some additional information during SCALAPACK
98libraries detection" OFF)
99mark_as_advanced(SCALAPACK_VERBOSE)
100if(BLAS_VERBOSE)
101  set(SCALAPACK_VERBOSE ON)
102endif()
103set(_scalapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
104
105get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
106if(NOT _LANGUAGES_ MATCHES Fortran)
107  include(CheckFunctionExists)
108else(NOT _LANGUAGES_ MATCHES Fortran)
109  include(CheckFortranFunctionExists)
110endif(NOT _LANGUAGES_ MATCHES Fortran)
111
112set(SCALAPACK_FOUND FALSE)
113set(SCALAPACK95_FOUND FALSE)
114
115# TODO: move this stuff to separate module
116
117macro(
118  Check_Scalapack_Libraries
119  LIBRARIES
120  _prefix
121  _name
122  _flags
123  _list
124  _blaslapack
125  _mpi
126  _threads)
127  # This macro checks for the existence of the combination of fortran libraries
128  # given by _list.  If the combination is found, this macro checks (using the
129  # Check_Fortran_Function_Exists macro) whether can link against that library
130  # combination using the name of a routine given by _name using the linker
131  # flags given by _flags.  If the combination of libraries is found and passes
132  # the link test, LIBRARIES is set to the list of complete library paths that
133  # have been found.  Otherwise, LIBRARIES is set to FALSE.
134
135  # N.B. _prefix is the prefix applied to the names of all cached variables that
136  # are generated internally and marked advanced by this macro.
137
138  set(_libraries_work TRUE)
139  set(${LIBRARIES})
140  set(_combined_name)
141  set(ENV_MKLROOT "$ENV{MKLROOT}")
142  set(ENV_BLAS_DIR "$ENV{BLAS_DIR}")
143  set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}")
144  set(ENV_SCALAPACK_DIR "$ENV{SCALAPACK_DIR}")
145  set(ENV_SCALAPACK_LIBDIR "$ENV{SCALAPACK_LIBDIR}")
146  if(NOT _libdir)
147    if(BLAS_LIBDIR)
148      list(APPEND _libdir "${BLAS_LIBDIR}")
149    elseif(BLAS_DIR)
150      list(APPEND _libdir "${BLAS_DIR}")
151      list(APPEND _libdir "${BLAS_DIR}/lib")
152      if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
153        list(APPEND _libdir "${BLAS_DIR}/lib64")
154        list(APPEND _libdir "${BLAS_DIR}/lib/intel64")
155      else()
156        list(APPEND _libdir "${BLAS_DIR}/lib32")
157        list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
158      endif()
159    elseif(ENV_BLAS_LIBDIR)
160      list(APPEND _libdir "${ENV_BLAS_LIBDIR}")
161    elseif(ENV_BLAS_DIR)
162      list(APPEND _libdir "${ENV_BLAS_DIR}")
163      list(APPEND _libdir "${ENV_BLAS_DIR}/lib")
164      if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
165        list(APPEND _libdir "${ENV_BLAS_DIR}/lib64")
166        list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64")
167      else()
168        list(APPEND _libdir "${ENV_BLAS_DIR}/lib32")
169        list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32")
170      endif()
171    endif()
172    if(SCALAPACK_LIBDIR)
173      list(APPEND _libdir "${SCALAPACK_LIBDIR}")
174    elseif(SCALAPACK_DIR)
175      list(APPEND _libdir "${SCALAPACK_DIR}")
176      list(APPEND _libdir "${SCALAPACK_DIR}/lib")
177      if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
178        list(APPEND _libdir "${SCALAPACK_DIR}/lib64")
179        list(APPEND _libdir "${SCALAPACK_DIR}/lib/intel64")
180      else()
181        list(APPEND _libdir "${SCALAPACK_DIR}/lib32")
182        list(APPEND _libdir "${SCALAPACK_DIR}/lib/ia32")
183      endif()
184    elseif(ENV_SCALAPACK_LIBDIR)
185      list(APPEND _libdir "${ENV_SCALAPACK_LIBDIR}")
186    elseif(ENV_SCALAPACK_DIR)
187      list(APPEND _libdir "${ENV_SCALAPACK_DIR}")
188      list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib")
189      if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
190        list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib64")
191        list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/intel64")
192      else()
193        list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib32")
194        list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/ia32")
195      endif()
196    else()
197      if(ENV_MKLROOT)
198        list(APPEND _libdir "${ENV_MKLROOT}/lib")
199        if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
200          list(APPEND _libdir "${ENV_MKLROOT}/lib64")
201          list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64")
202        else()
203          list(APPEND _libdir "${ENV_MKLROOT}/lib32")
204          list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32")
205        endif()
206      endif()
207      if(WIN32)
208        string(REPLACE ":" ";" _libdir2 "$ENV{LIB}")
209      elseif(APPLE)
210        string(REPLACE ":" ";" _libdir2 "$ENV{DYLD_LIBRARY_PATH}")
211      else()
212        string(REPLACE ":" ";" _libdir2 "$ENV{LD_LIBRARY_PATH}")
213      endif()
214      list(APPEND _libdir "${_libdir2}")
215      list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
216      list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
217    endif()
218  endif()
219
220  if(SCALAPACK_VERBOSE)
221    message("${Cyan}Try to find SCALAPACK libraries: ${_list}")
222  endif()
223
224  foreach(_library ${_list})
225    set(_combined_name ${_combined_name}_${_library})
226
227    if(_libraries_work)
228      if(BLA_STATIC)
229        if(WIN32)
230          set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
231        endif(WIN32)
232        if(APPLE)
233          set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
234        else(APPLE)
235          set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
236        endif(APPLE)
237      else(BLA_STATIC)
238        if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
239          # for ubuntu's libblas3gf and libscalapack3gf packages
240          set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}
241                                          .so.3gf)
242        endif()
243      endif(BLA_STATIC)
244      find_library(
245        ${_prefix}_${_library}_LIBRARY
246        NAMES ${_library}
247        HINTS ${_libdir})
248      mark_as_advanced(${_prefix}_${_library}_LIBRARY)
249      # Print status if not found
250      # -------------------------
251      if(NOT ${_prefix}_${_library}_LIBRARY
252         AND NOT SCALAPACK_FIND_QUIETLY
253         AND SCALAPACK_VERBOSE)
254        print_find_library_blas_status(scalapack ${_library} ${_libdir})
255      endif()
256      set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
257      set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
258    endif(_libraries_work)
259  endforeach(_library ${_list})
260
261  if(_libraries_work)
262    # Test this combination of libraries.
263    if(UNIX AND BLA_STATIC)
264      set(CMAKE_REQUIRED_LIBRARIES
265          ${_flags}
266          "-Wl,--start-group"
267          ${${LIBRARIES}}
268          ${_blaslapack}
269          "-Wl,--end-group"
270          ${_mpi}
271          ${_threads})
272    else(UNIX AND BLA_STATIC)
273      set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blaslapack}
274                                   ${_mpi} ${_threads})
275    endif(UNIX AND BLA_STATIC)
276    if(SCALAPACK_VERBOSE)
277      message("${Cyan}SCALAPACK libs found. Try to compile symbol ${_name} with"
278              "following libraries: ${CMAKE_REQUIRED_LIBRARIES}")
279    endif()
280    if(NOT SCALAPACK_FOUND)
281      unset(${_prefix}${_combined_name}_WORKS CACHE)
282    endif()
283    if(NOT _LANGUAGES_ MATCHES Fortran)
284      check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
285    else(NOT _LANGUAGES_ MATCHES Fortran)
286      check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
287    endif(NOT _LANGUAGES_ MATCHES Fortran)
288    set(CMAKE_REQUIRED_LIBRARIES)
289    mark_as_advanced(${_prefix}${_combined_name}_WORKS)
290    set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
291  endif(_libraries_work)
292
293  if(_libraries_work)
294    set(${LIBRARIES} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads})
295  else(_libraries_work)
296    set(${LIBRARIES} FALSE)
297  endif(_libraries_work)
298
299endmacro(Check_Scalapack_Libraries)
300
301set(SCALAPACK_LINKER_FLAGS)
302set(SCALAPACK_LIBRARIES)
303set(SCALAPACK95_LIBRARIES)
304
305if(NOT BLAS_FOUND)
306  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
307    find_package(BLAS)
308  else()
309    find_package(BLAS REQUIRED)
310  endif()
311endif()
312
313if(NOT LAPACK_FOUND)
314  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
315    find_package(LAPACK)
316  else()
317    find_package(LAPACK REQUIRED)
318  endif()
319endif()
320
321if(NOT MPI_FOUND)
322  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
323    find_package(MPI)
324  else()
325    find_package(MPI REQUIRED)
326  endif()
327endif()
328
329if(BLAS_FOUND
330   AND LAPACK_FOUND
331   AND MPI_FOUND)
332  set(SCALAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
333  list(APPEND SCALAPACK_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
334  if($ENV{BLA_VENDOR} MATCHES ".+")
335    set(BLA_VENDOR $ENV{BLA_VENDOR})
336  else($ENV{BLA_VENDOR} MATCHES ".+")
337    if(NOT BLA_VENDOR)
338      set(BLA_VENDOR "All")
339    endif(NOT BLA_VENDOR)
340  endif($ENV{BLA_VENDOR} MATCHES ".+")
341
342  # Generic SCALAPACK library
343  if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
344    if(NOT SCALAPACK_LIBRARIES)
345      check_scalapack_libraries(
346        SCALAPACK_LIBRARIES
347        SCALAPACK
348        pdgemm
349        ""
350        "scalapack" # scalapack lib to look for
351        "${LAPACK_LIBRARIES};${BLAS_LIBRARIES}" # blas and lapack libs
352        "${MPI_Fortran_LIBRARIES}" # mpi libs
353        "" # threads libs
354      )
355    endif(NOT SCALAPACK_LIBRARIES)
356  endif()
357  # intel scalapack
358  if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
359    if(UNIX AND NOT WIN32)
360      find_library(M_LIBRARY NAMES m)
361      mark_as_advanced(M_LIBRARY)
362      if(M_LIBRARY)
363        set(LM "-lm")
364      else()
365        set(LM "")
366      endif()
367    endif()
368    if(_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
369      if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
370        find_package(Threads)
371      else()
372        find_package(Threads REQUIRED)
373      endif()
374
375      set(SCALAPACK_SEARCH_LIBS "")
376
377      if(BLA_F95)
378        set(SCALAPACK_mkl_SEARCH_SYMBOL "PDGEMM")
379        set(_LIBRARIES SCALAPACK95_LIBRARIES)
380        set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES})
381        list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64")
382      else()
383        set(SCALAPACK_mkl_SEARCH_SYMBOL "pdgemm")
384        set(_LIBRARIES SCALAPACK_LIBRARIES)
385        set(_BLAS_LIBRARIES ${BLAS_LIBRARIES})
386        list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64")
387      endif()
388
389      # First try empty scalapack libs
390      if(NOT ${_LIBRARIES})
391        check_scalapack_libraries(
392          ${_LIBRARIES}
393          BLAS
394          ${SCALAPACK_mkl_SEARCH_SYMBOL}
395          ""
396          ""
397          "${_BLAS_LIBRARIES}"
398          ""
399          "${MPI_Fortran_LIBRARIES}")
400      endif()
401      # Then try the search libs
402      foreach(IT ${SCALAPACK_SEARCH_LIBS})
403        # First try mkl_blacs_openmpi (OpenMPI derived)
404        if(NOT ${_LIBRARIES})
405          check_scalapack_libraries(
406            ${_LIBRARIES}
407            BLAS
408            ${SCALAPACK_mkl_SEARCH_SYMBOL}
409            ""
410            "${IT};mkl_blacs_openmpi_lp64"
411            "${_BLAS_LIBRARIES}"
412            ""
413            "${MPI_Fortran_LIBRARIES}")
414        endif()
415        # First try mkl_blacs_intelmpi (MPICH derived)
416        if(NOT ${_LIBRARIES})
417          check_scalapack_libraries(
418            ${_LIBRARIES}
419            BLAS
420            ${SCALAPACK_mkl_SEARCH_SYMBOL}
421            ""
422            "${IT};mkl_blacs_intelmpi_lp64"
423            "${_BLAS_LIBRARIES}"
424            ""
425            "${MPI_Fortran_LIBRARIES}")
426        endif()
427      endforeach()
428    endif()
429  endif()
430else(
431  BLAS_FOUND
432  AND LAPACK_FOUND
433  AND MPI_FOUND)
434  message(STATUS "SCALAPACK requires BLAS, LAPACK, and MPI")
435endif(
436  BLAS_FOUND
437  AND LAPACK_FOUND
438  AND MPI_FOUND)
439
440if(BLA_F95)
441  if(SCALAPACK95_LIBRARIES)
442    set(SCALAPACK95_FOUND TRUE)
443  else(SCALAPACK95_LIBRARIES)
444    set(SCALAPACK95_FOUND FALSE)
445  endif(SCALAPACK95_LIBRARIES)
446
447  if(NOT SCALAPACK_FIND_QUIETLY)
448    if(SCALAPACK95_FOUND)
449      message(STATUS "A library with SCALAPACK95 API found.")
450      message(STATUS "SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARIES}")
451    else(SCALAPACK95_FOUND)
452      message(
453        WARNING
454          "BLA_VENDOR has been set to ${BLA_VENDOR} but SCALAPACK 95 libraries could not be found or check of symbols failed."
455          "\nPlease indicate where to find SCALAPACK libraries. You have three options:\n"
456          "- Option 1: Provide the installation directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\n"
457          "- Option 2: Provide the directory where to find BLAS libraries with cmake option: -DBLAS_LIBDIR=your/path/to/blas/libs\n"
458          "- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
459          "\nTo follow libraries detection more precisely you can activate a verbose mode with -DSCALAPACK_VERBOSE=ON at cmake configure."
460          "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name."
461          "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit),"
462          "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model),"
463          "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
464    endif(NOT SCALAPACK_FIND_QUIETLY)
465    if(SCALAPACK_FIND_REQUIRED)
466      message(
467        FATAL_ERROR
468          "A required library with SCALAPACK95 API not found.\
469          Please specify library location: -DSCALAPACK_DIR=/your/path/to/scalapack")
470    else(SCALAPACK_FIND_REQUIRED)
471      if(NOT SCALAPACK_FIND_QUIETLY)
472        message(
473          STATUS
474            "A library with SCALAPACK95 API not found.\
475            Please specify library location: -DSCALAPACK_DIR=/your/path/to/scalapack")
476      endif(NOT SCALAPACK_FIND_QUIETLY)
477    endif(SCALAPACK_FIND_REQUIRED)
478  endif(SCALAPACK95_FOUND)
479
480  set(SCALAPACK_FOUND "${SCALAPACK95_FOUND}")
481  set(SCALAPACK_LIBRARIES "${SCALAPACK95_LIBRARIES}")
482else(BLA_F95)
483  if(SCALAPACK_LIBRARIES)
484    set(SCALAPACK_FOUND TRUE)
485  else(SCALAPACK_LIBRARIES)
486    set(SCALAPACK_FOUND FALSE)
487  endif(SCALAPACK_LIBRARIES)
488
489  if(NOT SCALAPACK_FOUND)
490    if(NOT SCALAPACK_FIND_QUIETLY)
491        message(WARNING
492            "BLA_VENDOR has been set to ${BLA_VENDOR} but SCALAPACK libraries could not be found or check of symbols failed."
493            "\nPlease indicate where to find SCALAPACK libraries. You have three options:\n"
494            "- Option 1: Provide the installation directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\n"
495            "- Option 2: Provide the directory where to find BLAS libraries with cmake option: -DBLAS_LIBDIR=your/path/to/blas/libs\n"
496            "- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
497            "\nTo follow libraries detection more precisely you can activate a verbose mode with -DSCALAPACK_VERBOSE=ON at cmake configure."
498            "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name."
499            "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit),"
500            "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model),"
501            "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
502    endif(NOT SCALAPACK_FIND_QUIETLY)
503
504    if(SCALAPACK_FIND_REQUIRED)
505        message(
506            FATAL_ERROR
507                "A required library with SCALAPACK API not found.\
508                Please specify library location: -DSCALAPACK_DIR=/your/path/to/scalapack")
509    else(SCALAPACK_FIND_REQUIRED)
510        if(NOT SCALAPACK_FIND_QUIETLY)
511            message(STATUS
512                "A library with SCALAPACK API not found.\
513                Please specify library location: -DSCALAPACK_DIR=/your/path/to/scalapack")
514        endif(NOT SCALAPACK_FIND_QUIETLY)
515    endif(SCALAPACK_FIND_REQUIRED)
516  endif(NOT SCALAPACK_FOUND)
517endif(BLA_F95)
518
519set(CMAKE_FIND_LIBRARY_SUFFIXES ${_scalapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
520
521if(SCALAPACK_LIBRARIES)
522  list(GET SCALAPACK_LIBRARIES 0 first_lib)
523  get_filename_component(first_lib_path "${first_lib}" PATH)
524  if(${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)")
525    string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" ""
526                         not_cached_dir "${first_lib_path}")
527    set(SCALAPACK_DIR_FOUND
528        "${not_cached_dir}"
529        CACHE PATH "Installation directory of SCALAPACK library" FORCE)
530  else()
531    set(SCALAPACK_DIR_FOUND
532        "${first_lib_path}"
533        CACHE PATH "Installation directory of SCALAPACK library" FORCE)
534  endif()
535endif()
536mark_as_advanced(SCALAPACK_DIR)
537mark_as_advanced(SCALAPACK_DIR_FOUND)
538