diff --git a/CMakeModules/FindCBLAS.cmake b/CMakeModules/FindCBLAS.cmake index ee47b3af5a..d08b3c25aa 100644 --- a/CMakeModules/FindCBLAS.cmake +++ b/CMakeModules/FindCBLAS.cmake @@ -21,6 +21,29 @@ SET(CBLAS_INCLUDE_DIR CACHE STRING SET(CBLAS_INCLUDE_FILE CACHE STRING "CBLAS header name") + +# If a valid PkgConfig configuration for cblas is found, this overrides and cancels +# all further checks. +FIND_PACKAGE(PkgConfig) +IF(PKG_CONFIG_FOUND) + PKG_CHECK_MODULES(PC_CBLAS cblas) +ENDIF(PKG_CONFIG_FOUND) + +IF(PC_CBLAS_FOUND) + + FOREACH(PC_LIB ${PC_CBLAS_LIBRARIES}) + FIND_LIBRARY(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_CBLAS_LIBRARY_DIRS} ) + IF (NOT ${PC_LIB}_LIBRARY) + message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_CBLAS_LIBRARY_DIRS}") + ENDIF (NOT ${PC_LIB}_LIBRARY) + LIST(APPEND CBLAS_LIBRARIES ${${PC_LIB}_LIBRARY}) + ENDFOREACH(PC_LIB) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CBLAS DEFAULT_MSG CBLAS_LIBRARIES) + MARK_AS_ADVANCED(CBLAS_LIBRARIES) + +ELSE(PC_CBLAS_FOUND) + SET(INTEL_MKL_ROOT_DIR CACHE STRING "Root directory of the Intel MKL") @@ -277,3 +300,5 @@ IF(NOT CBLAS_FIND_QUIETLY) MESSAGE(STATUS "CBLAS library not found.") ENDIF() ENDIF(NOT CBLAS_FIND_QUIETLY) + +ENDIF(PC_CBLAS_FOUND)