xtensor-stack / xtensor-blas

BLAS extension to xtensor
BSD 3-Clause "New" or "Revised" License
155 stars 54 forks source link

Could NOT find BLAS (missing: BLAS_LIBRARIES) #230

Closed 3e33 closed 1 year ago

3e33 commented 1 year ago

find_package(OpenBLAS) works in my own CMakeLists, but because xtensor-blasConfig.cmake has find_dependency(BLAS) it fails there.

xtensor-blas/lib/cmake/xtensor-blas/xtensor-blasConfig.cmake:47 (find_dependency)

I've already tried set(BLA_VENDOR OpenBLAS) and the settings in the documentation and all of it fails.

3e33 commented 1 year ago

I managed to fix this by adding list(APPEND CMAKE_PREFIX_PATH <PATH TO OpenBLAS FOLDER>). If anyone knows a less hacky way though please let me know.

stellarpower commented 1 year ago

Good catch, I was trying to do the same in my CMakeLists, and this seems to go against the docs as you linked. Typical CMake dependencies mess :roll_eyes:

This worked for me. Even without the edits to the cmake config file. I am using mamba for managing dependencies and buildtools, and CMake version 3.25.2:

find_package( BLAS REQUIRED )
message( STATUS BLAS found: ${BLAS_LIBRARIES} )
list(APPEND Libraries ${BLAS_LIBRARIES})

find_package(xtensor-blas     REQUIRED)
include_directories(${xtensor-blas_INCLUDE_DIRS})
list(APPEND Libraries    xtensor-blas)

In theory this is doing the same as you tried (and I tried myself from the xtensor-blas docs), so not sure what has gone on there - but I was googling and landed here: https://cmake.org/cmake/help/latest/module/FindBLAS.html

I presume this is hooking into a script provided by CMake to find a vendor-neutral BLAS, which (for me at least) is then setting things up correctly. OpenBLAS is in the mamba environment, so this may be faciitated by not having any other BLAS implementations in the search path.

3e33 commented 1 year ago

@stellarpower I edited my comment a little. The path in CMAKE_PREFIX_PATH needs to be the path into the OpenBLAS folder. It's not simply where all packages are installed, but the OpenBLAS folder itself. That's what makes it strange. That's the only way it's working for me if I have OpenBLAS downloaded without package managers.