summaryrefslogtreecommitdiffstats
path: root/Modules/FindBLAS.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2017-12-15 19:42:24 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2017-12-15 20:24:25 (GMT)
commita9c42e3ec09fa9cdf308344d12b0cc8c2e44d905 (patch)
treebc6bf1e8c8303e5cc1d60424df934c7462035e81 /Modules/FindBLAS.cmake
parentc095e2ad540edee8521b891f0eba9ebeb3ce5ac3 (diff)
downloadCMake-a9c42e3ec09fa9cdf308344d12b0cc8c2e44d905.zip
CMake-a9c42e3ec09fa9cdf308344d12b0cc8c2e44d905.tar.gz
CMake-a9c42e3ec09fa9cdf308344d12b0cc8c2e44d905.tar.bz2
FindBLAS: optionally query pkg-config for a library
This is more or less what Gentoo implements for years, but in a more sophisticated version that uses the target mode now offered by pkg_check_modules().
Diffstat (limited to 'Modules/FindBLAS.cmake')
-rw-r--r--Modules/FindBLAS.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 0e5fa11..8e8c6f4 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -27,10 +27,17 @@
# to link against to use BLAS95 interface
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
# is found
+#
+# The following variables can be used to control this module:
+#
+# ::
+#
# BLA_STATIC if set on this determines what kind of linkage we do (static)
# BLA_VENDOR if set checks only the specified vendor, if not set checks
# all the possibilities
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
+# BLA_PREFER_PKGCONFIG if set pkg-config will be used to search for a BLAS
+# library first and if one is found that is preferred
#
# List of vendors (BLA_VENDOR) valid in this module:
#
@@ -79,6 +86,18 @@ if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_C
endif()
endif()
+if(BLA_PREFER_PKGCONFIG)
+ find_package(PkgConfig)
+ pkg_check_modules(PKGC_BLAS IMPORTED_TARGET blas)
+ if(PKGC_BLAS_FOUND)
+ set(BLAS_LIBRARIES PkgConfig::PKGC_BLAS)
+ find_package_handle_standard_args(BLAS
+ REQUIRED_VARS BLAS_LIBRARIES
+ VERSION_VAR PKGC_BLAS_VERSION)
+ return()
+ endif()
+endif()
+
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the