FindBLAS, FindLAPACK unset custom LIBRARIES values
Description
When using the FindBLAS and FindLAPACK modules with a custom BLAS library (by passing BLAS_LIBRARIES
on the configure line), it appears that these modules are overwriting the custom options and then failing to configure the library properly.
Details
For libraries in the Julia ecosystem we use a BLAS/LAPACK wrapper called libblastrampoline, which is a light weight shared library that lets us redirect the function calls at runtime. To link against this library, I have created a CMake file that is included in projects to setup the relevant BLAS/LAPACK variables (file here https://github.com/JuliaPackaging/Yggdrasil/commit/55bff4fe203da46b6436d72f6df417800d6cb66f), i.e.:
# FindBLAS overrides
set( BLAS_FOUND 1 )
set( BLAS_LIBRARIES "${BB_LIBDIR}/lib${BLASTRAMPOLINE_LIB}.${BB_DLLEXT}" )
set( BLAS_LINKER_FLAGS "${BLASTRAMPOLINE_LIB}" )
# FindLAPACK overrides
set( LAPACK_FOUND 1 )
set( LAPACK_LIBRARIES "${BB_LIBDIR}/lib${BLASTRAMPOLINE_LIB}.${BB_DLLEXT}" )
set( LAPACK_LINKER_FLAGS "${BLASTRAMPOLINE_LIB}" )
What I have noticed though is that when using the built-in FindBLAS module, I get a BLAS not found problem. I did some tracing and watching of the BLAS_FOUND
and BLAS_LIBRARIES
variables, and the trace seems to suggest that my custom settings for the BLAS_LIBRARIES
variable is getting removed at the begining of the built-in module:
Put cmake in trace mode, but with variables expanded.
Put cmake in trace mode, but output only lines of a specified file. Multiple options are allowed.
Re-run cmake no build system arguments
CMake Debug Log at /workspace/destdir/lib/cmake/blastrampoline/yggdrasilenv.cmake:35 (set):
Variable "BLAS_FOUND" was accessed using MODIFIED_ACCESS with value "1".
Call Stack (most recent call first):
CMakeLists.txt:36 (project)
CMake Debug Log at /workspace/destdir/lib/cmake/blastrampoline/yggdrasilenv.cmake:36 (set):
Variable "BLAS_LIBRARIES" was accessed using MODIFIED_ACCESS with value
"/workspace/destdir/lib/libblastrampoline.so".
Call Stack (most recent call first):
CMakeLists.txt:36 (project)
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/bin/x86_64-linux-gnu-libgfortran5-cxx11/x86_64-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/bin/x86_64-linux-gnu-libgfortran5-cxx11/x86_64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_BIGOBJ
-- Performing Test HAVE_BIGOBJ - Failed
-- Looking for pow in m
-- Looking for pow in m - found
-- Detected Ceres version: 2.2.0 from /workspace/srcdir/ceres-solver/include/ceres/version.h
-- Found Eigen version 3.4.0: /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/share/eigen3/cmake
-- Enabling use of Eigen as a sparse linear algebra library.
-- Did not find CUDA, disabling CUDA support.
-- Building without CUDA.
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(254): if(NOT ( CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED ) )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(263): function(_add_blas_target )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(279): if(CMAKE_Fortran_COMPILER_LOADED )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(281): else()
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(282): include(/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/CheckFunctionExists.cmake )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(284): include(/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(286): if(BLA_PREFER_PKGCONFIG )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(302): function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(390): set(BLAS_LINKER_FLAGS )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(391): set(BLAS_LIBRARIES )
CMake Debug Log at /workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake:391 (set):
Variable "BLAS_LIBRARIES" was accessed using REMOVED_ACCESS with value "".
Call Stack (most recent call first):
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindLAPACK.cmake:247 (find_package)
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindLAPACK.cmake:283 (_lapack_find_dependency)
CMakeLists.txt:272 (find_package)
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(392): set(BLAS95_LIBRARIES )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(393): set(_blas_fphsa_req_var BLAS_LIBRARIES )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(394): if(NOT BLA_VENDOR )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(402): if(NOT BLA_SIZEOF_INTEGER )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(404): set(_blas_sizeof_integer ANY )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(414): if(BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(435): if(BLA_VENDOR MATCHES Intel OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(696): if(BLA_F95 )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(705): if(BLA_VENDOR STREQUAL Goto OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(721): if(BLA_VENDOR STREQUAL FlexiBLAS OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(745): if(BLA_VENDOR STREQUAL OpenBLAS OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(797): if(BLA_VENDOR MATCHES Arm OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(833): if(BLA_VENDOR STREQUAL FLAME OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(857): if(BLA_VENDOR MATCHES AOCL OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(889): if(BLA_VENDOR STREQUAL ATLAS OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(905): if(BLA_VENDOR STREQUAL PhiPACK OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(921): if(BLA_VENDOR STREQUAL CXML OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(943): if(BLA_VENDOR STREQUAL DXML OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(965): if(BLA_VENDOR STREQUAL SunPerf OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(984): if(BLA_VENDOR MATCHES SCSL OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1011): if(BLA_VENDOR STREQUAL SGIMATH OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1027): if(BLA_VENDOR MATCHES IBMESSL OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1054): if(BLA_VENDOR MATCHES ACML OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1200): if(BLA_VENDOR STREQUAL Apple OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1222): if(BLA_VENDOR STREQUAL NAS OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1244): if(BLA_VENDOR MATCHES EML OR BLA_VENDOR STREQUAL All )
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1272): if(NOT BLAS_LIBRARIES AND ( BLA_VENDOR MATCHES ^Fujitsu_SSL2 OR BLA_VENDOR STREQUAL All ) )
CMake Debug Log at /workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake:1272 (if):
Variable "BLAS_LIBRARIES" was accessed using UNKNOWN_READ_ACCESS with value
"".
Call Stack (most recent call first):
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindLAPACK.cmake:247 (find_package)
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindLAPACK.cmake:283 (_lapack_find_dependency)
CMakeLists.txt:272 (find_package)
/workspace/x86_64-linux-musl-cxx11/artifacts/51c3dfdadb11b1fb58fe33aa320447630cfba341/share/cmake-3.28/Modules/FindBLAS.cmake(1308): if(BLA_VENDOR STREQUAL NVHPC OR BLA_VENDOR STREQUAL All )
Because the variable is getting unset, the subsequent find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES )
is failing, so the BLAS library is getting reported as missing.
Expected behavior
I want to be able to override the BLAS library by using the BLAS_LIBRARIES
, BLAS_FOUND
or other variables I pass into the configure line to link against a custom BLAS/LAPACK library.
I have tested this with FindBLAS, but since the lines also exist in FindLAPACK, I believe there will be a similar problem as well.
CMake version tested: 3.28.1