@@ -88,15 +88,15 @@ find_library(ATLAS_LIB
88
88
NAMES_PER_DIR
89
89
PATH_SUFFIXES atlas )
90
90
91
- pkg_check_modules (pc_atlas_lapack lapack-atlas QUIET )
91
+ pkg_check_modules (pc_atlas_lapack lapack-atlas )
92
92
93
93
find_library (LAPACK_ATLAS
94
94
NAMES ptlapack lapack_atlas lapack
95
95
NAMES_PER_DIR
96
96
PATH_SUFFIXES atlas
97
97
HINTS ${pc_atlas_lapack_LIBRARY_DIRS} ${pc_atlas_lapack_LIBDIR} )
98
98
99
- pkg_check_modules (pc_atlas_blas blas-atlas QUIET )
99
+ pkg_check_modules (pc_atlas_blas blas-atlas )
100
100
101
101
find_library (BLAS_LIBRARY
102
102
NAMES ptf77blas f77blas blas
@@ -159,10 +159,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
159
159
set (_lapack_hints ${_pgi_path} /../ )
160
160
endif ()
161
161
162
- pkg_check_modules (pc_lapack lapack-netlib QUIET )
163
- if (NOT pc_lapack_FOUND )
164
- pkg_check_modules (pc_lapack lapack QUIET ) # Netlib on Cygwin, Homebrew and others
165
- endif ()
162
+ pkg_search_module (pc_lapack lapack lapack-netlib )
163
+
166
164
find_library (LAPACK_LIB
167
165
NAMES lapack
168
166
NAMES_PER_DIR
@@ -176,7 +174,7 @@ else()
176
174
endif ()
177
175
178
176
if (LAPACKE IN_LIST LAPACK_FIND_COMPONENTS )
179
- pkg_check_modules (pc_lapacke lapacke QUIET )
177
+ pkg_check_modules (pc_lapacke lapacke )
180
178
find_library (LAPACKE_LIBRARY
181
179
NAMES lapacke
182
180
NAMES_PER_DIR
@@ -205,9 +203,9 @@ if(LAPACKE IN_LIST LAPACK_FIND_COMPONENTS)
205
203
mark_as_advanced (LAPACKE_LIBRARY LAPACKE_INCLUDE_DIR )
206
204
endif (LAPACKE IN_LIST LAPACK_FIND_COMPONENTS )
207
205
208
- pkg_check_modules (pc_blas blas-netlib QUIET )
206
+ pkg_check_modules (pc_blas blas-netlib )
209
207
if (NOT pc_blas_FOUND )
210
- pkg_check_modules (pc_blas blas QUIET ) # Netlib on Cygwin and others
208
+ pkg_check_modules (pc_blas blas ) # Netlib on Cygwin and others
211
209
endif ()
212
210
find_library (BLAS_LIBRARY
213
211
NAMES refblas blas
@@ -239,15 +237,15 @@ endfunction(netlib_libs)
239
237
#===============================
240
238
function (openblas_libs )
241
239
242
- pkg_check_modules (pc_lapack lapack-openblas QUIET )
240
+ pkg_check_modules (pc_lapack lapack-openblas )
243
241
find_library (LAPACK_LIBRARY
244
242
NAMES lapack
245
243
NAMES_PER_DIR
246
244
HINTS ${pc_lapack_LIBRARY_DIRS} ${pc_lapack_LIBDIR}
247
245
PATH_SUFFIXES openblas )
248
246
249
247
250
- pkg_check_modules (pc_blas blas-openblas QUIET )
248
+ pkg_check_modules (pc_blas blas-openblas )
251
249
find_library (BLAS_LIBRARY
252
250
NAMES openblas blas
253
251
NAMES_PER_DIR
@@ -341,7 +339,7 @@ if(NOT (OpenBLAS IN_LIST LAPACK_FIND_COMPONENTS
341
339
endif ()
342
340
endif ()
343
341
344
- find_package (PkgConfig QUIET )
342
+ find_package (PkgConfig )
345
343
346
344
# ==== generic MKL variables ====
347
345
@@ -350,7 +348,7 @@ if(MKL IN_LIST LAPACK_FIND_COMPONENTS)
350
348
# double-quotes are necessary per CMake to_cmake_path docs.
351
349
file (TO_CMAKE_PATH "$ENV{MKLROOT} " MKLROOT )
352
350
353
- list (APPEND CMAKE_PREFIX_PATH ${MKLROOT} /bin /pkgconfig )
351
+ list (APPEND CMAKE_PREFIX_PATH ${MKLROOT} /tools /pkgconfig )
354
352
355
353
if (NOT WIN32 )
356
354
find_package (Threads )
@@ -370,7 +368,7 @@ if(MKL IN_LIST LAPACK_FIND_COMPONENTS)
370
368
371
369
unset (_mkl_libs )
372
370
if (LAPACK95 IN_LIST LAPACK_FIND_COMPONENTS )
373
- list ( APPEND _mkl_libs mkl_blas95_${_mkl_bitflag}lp64 mkl_lapack95_${_mkl_bitflag}lp64 )
371
+ set ( _mkl_libs mkl_blas95_${_mkl_bitflag}lp64 mkl_lapack95_${_mkl_bitflag}lp64 )
374
372
endif ()
375
373
376
374
unset (_tbb )
@@ -381,15 +379,15 @@ if(MKL IN_LIST LAPACK_FIND_COMPONENTS)
381
379
list (APPEND _mkl_libs tbb.lib )
382
380
endif ()
383
381
elseif (OpenMP IN_LIST LAPACK_FIND_COMPONENTS )
384
- pkg_check_modules (pc_mkl mkl-${_mkltype}-${_mkl_bitflag}lp64-iomp QUIET )
382
+ pkg_check_modules (pc_mkl mkl-${_mkltype}-${_mkl_bitflag}lp64-iomp )
385
383
386
384
set (_mp iomp5 )
387
385
if (WIN32 )
388
386
set (_mp libiomp5md ) # "lib" is indeed necessary, even on CMake 3.14.0
389
387
endif ()
390
388
list (APPEND _mkl_libs mkl_intel_thread mkl_core ${_mp} )
391
389
else ()
392
- pkg_check_modules (pc_mkl mkl-${_mkltype}-${_mkl_bitflag}lp64-seq QUIET )
390
+ pkg_check_modules (pc_mkl mkl-${_mkltype}-${_mkl_bitflag}lp64-seq )
393
391
list (APPEND _mkl_libs mkl_sequential mkl_core )
394
392
endif ()
395
393
@@ -434,9 +432,41 @@ elseif(OpenBLAS IN_LIST LAPACK_FIND_COMPONENTS)
434
432
435
433
endif ()
436
434
435
+ # -- verify library works
436
+
437
+ set (CMAKE_REQUIRED_FLAGS )
438
+ set (CMAKE_REQUIRED_LINK_OPTIONS )
439
+ set (CMAKE_REQUIRED_INCLUDES )
440
+ set (CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARY} )
441
+
442
+ if (LAPACK_LIBRARY )
443
+ if (CMAKE_Fortran_COMPILER )
444
+ include (CheckFortranSourceCompiles )
445
+ check_fortran_source_compiles ("program check_lapack
446
+ implicit none
447
+ double precision, external :: disnan
448
+ print *, disnan(0.)
449
+ end" LAPACK_real64_links SRC_EXT f90 )
450
+
451
+ check_fortran_source_compiles ("program check_lapack
452
+ implicit none
453
+ real, external :: sisnan
454
+ print *, sisnan(0.)
455
+ end" LAPACK_real32_links SRC_EXT f90 )
456
+
457
+ if (LAPACK_real64_links OR LAPACK_real32_links )
458
+ set (LAPACK_links TRUE )
459
+ endif ()
460
+ else (CMAKE_Fortran_COMPILER )
461
+ set (LAPACK_links TRUE ) # complex to check with various distinct LapackE APIs
462
+ endif (CMAKE_Fortran_COMPILER )
463
+ endif (LAPACK_LIBRARY )
464
+
465
+ set (CMAKE_REQUIRED_LIBRARIES )
466
+
437
467
include (FindPackageHandleStandardArgs )
438
468
find_package_handle_standard_args (LAPACK
439
- REQUIRED_VARS LAPACK_LIBRARY
469
+ REQUIRED_VARS LAPACK_LIBRARY LAPACK_links
440
470
HANDLE_COMPONENTS )
441
471
442
472
set (BLAS_LIBRARIES ${BLAS_LIBRARY} )
0 commit comments