1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-16 06:44:57 +00:00
gnss-sdr/cmake/Modules/AvoidAccelerate.cmake
Carles Fernandez 9dc57a61d0
Improve finding of BLAS libraries in macOS / Macports
MacPorts' lapack is not guaranteed to produce libblas.dylib. For example if the +openblas variant is used, then lapack uses openblas.
This commit tries to find and use libopenblas.dylib if  libblas.dylib is not found.
Fixes usage of BLAS_ROOT
2022-04-22 12:11:06 +02:00

61 lines
1.6 KiB
CMake

# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2011-2020 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
# Avoid using the BLAS and LAPACK implementations that comes with the Accelerate
# framework, which causes a bug when the BeiDou constellation is enabled
if(NOT BLAS_ROOT)
set(BLAS_ROOT_USER_DEFINED /usr/local/lib)
else()
set(BLAS_ROOT_USER_DEFINED ${BLAS_ROOT})
endif()
if(DEFINED ENV{BLAS_ROOT})
set(BLAS_ROOT_USER_DEFINED
${BLAS_ROOT_USER_DEFINED}
$ENV{BLAS_ROOT}
)
endif()
find_library(BLAS_LIBRARIES
NAMES libblas.dylib libopenblas.dylib
PATHS
${BLAS_ROOT_USER_DEFINED}
${BLAS_ROOT_USER_DEFINED}/lapack
/opt/local/lib/lapack
/opt/local/lib/
/usr/local/opt/lapack/lib
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)
if(BLAS_LIBRARIES)
set(BLAS_FOUND TRUE)
message(STATUS "BLAS library found at ${BLAS_LIBRARIES}")
endif()
find_library(LAPACK_LIBRARIES
liblapack.dylib
PATHS
${BLAS_ROOT_USER_DEFINED}
${BLAS_ROOT_USER_DEFINED}/lapack
/opt/local/lib/lapack
/usr/local/opt/lapack/lib
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)
if(LAPACK_LIBRARIES)
set(LAPACK_FOUND TRUE)
message(STATUS "LAPACK library found at ${LAPACK_LIBRARIES}")
endif()