In CMake I use find_package(BLAS REQUIRED)
and I use the BLAS_FOUND
, BLAS_LINKER_FLAGS
, BLAS_LIBRARIES
variables as appropriate.
My question is, how do I, based on the BLAS implementation that has been selected, find the include directory that should be included in CMake?
BLAS_INCLUDE_DIR
is not being set on macOS for either the Accelerate framework nor OpenBLAS. Also it's not part of the documentation for FindBLAS.
If there isn't a script already provided, you can write one yourself or extend the existing FindBLAS.cmake to set required path (BLAS_INCLUDE_DIRS).
For example you could use find_path
in order to search for the directory containing some standard BLAS include files, or specifically the ones required in your project. You can include as default common directories where you might expect BLAS to be installed, or paths based on environment variables. An example for Linux:
find_path(BLAS_INCLUDE_DIRS cblas.h
/usr/include
/usr/local/include
$ENV{BLAS_HOME}/include)
This will search for cblas.h
in /usr/include/
, /usr/local/include
, $ENV{BLAS_HOME}/include
and set the found path in BLAS_INCLUDE_DIRS.
You can add this script in a src/cmake/FindBLAS.cmake
file in your project and then tell your top level Cmake file about it with:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/src/cmake/")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With