Unverified Commit 5408b17f authored by aviezab's avatar aviezab Committed by GitHub
Browse files

Linux Distro Detection to fix issue number #2159 #154 (#2169)

Check if the blas found by pkgconfig is valid before using it.
parent 0419b816
...@@ -30,6 +30,7 @@ SET(lapack_with_underscore 0) ...@@ -30,6 +30,7 @@ SET(lapack_with_underscore 0)
SET(lapack_without_underscore 0) SET(lapack_without_underscore 0)
message(STATUS "Searching for BLAS and LAPACK") message(STATUS "Searching for BLAS and LAPACK")
INCLUDE(CheckFunctionExists)
if (UNIX OR MINGW) if (UNIX OR MINGW)
message(STATUS "Searching for BLAS and LAPACK") message(STATUS "Searching for BLAS and LAPACK")
...@@ -62,11 +63,15 @@ if (UNIX OR MINGW) ...@@ -62,11 +63,15 @@ if (UNIX OR MINGW)
return() return()
endif() endif()
# First, search for libraries via pkg-config, which is the cleanest path # First, search for libraries via pkg-config, which is the cleanest path
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(BLAS_REFERENCE cblas) pkg_check_modules(BLAS_REFERENCE cblas)
pkg_check_modules(LAPACK_REFERENCE lapack) pkg_check_modules(LAPACK_REFERENCE lapack)
if (BLAS_REFERENCE_FOUND AND LAPACK_REFERENCE_FOUND) # Make sure the cblas found by pkgconfig actually has cblas symbols.
SET(CMAKE_REQUIRED_LIBRARIES "${BLAS_REFERENCE_LDFLAGS}")
CHECK_FUNCTION_EXISTS(cblas_ddot HAVE_CBLAS)
if (BLAS_REFERENCE_FOUND AND LAPACK_REFERENCE_FOUND AND HAVE_CBLAS)
set(blas_libraries "${BLAS_REFERENCE_LDFLAGS}") set(blas_libraries "${BLAS_REFERENCE_LDFLAGS}")
set(lapack_libraries "${LAPACK_REFERENCE_LDFLAGS}") set(lapack_libraries "${LAPACK_REFERENCE_LDFLAGS}")
set(blas_found 1) set(blas_found 1)
...@@ -75,7 +80,7 @@ if (UNIX OR MINGW) ...@@ -75,7 +80,7 @@ if (UNIX OR MINGW)
message(STATUS "Found BLAS and LAPACK via pkg-config") message(STATUS "Found BLAS and LAPACK via pkg-config")
return() return()
endif() endif()
include(CheckTypeSize) include(CheckTypeSize)
check_type_size( "void*" SIZE_OF_VOID_PTR) check_type_size( "void*" SIZE_OF_VOID_PTR)
...@@ -189,8 +194,6 @@ if (UNIX OR MINGW) ...@@ -189,8 +194,6 @@ if (UNIX OR MINGW)
$ENV{OPENBLAS_HOME}/lib $ENV{OPENBLAS_HOME}/lib
) )
INCLUDE (CheckFunctionExists)
if (NOT blas_found) if (NOT blas_found)
find_library(cblas_lib NAMES openblasp openblas PATHS ${extra_paths}) find_library(cblas_lib NAMES openblasp openblas PATHS ${extra_paths})
if (cblas_lib) if (cblas_lib)
...@@ -337,7 +340,6 @@ elseif(WIN32 AND NOT MINGW) ...@@ -337,7 +340,6 @@ elseif(WIN32 AND NOT MINGW)
find_library(mkl_intel mkl_intel_c ${mkl_search_path}) find_library(mkl_intel mkl_intel_c ${mkl_search_path})
endif() endif()
INCLUDE (CheckFunctionExists)
# Get mkl_include_dir # Get mkl_include_dir
set(mkl_include_search_path set(mkl_include_search_path
...@@ -432,7 +434,6 @@ endif() ...@@ -432,7 +434,6 @@ endif()
# If using lapack, determine whether to mangle functions # If using lapack, determine whether to mangle functions
if (lapack_found) if (lapack_found)
include(CheckFunctionExists)
include(CheckFortranFunctionExists) include(CheckFortranFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${lapack_libraries}) set(CMAKE_REQUIRED_LIBRARIES ${lapack_libraries})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment