使用CMake查找BLAS包含目录 [英] Find BLAS include directory with CMake

查看:638
本文介绍了使用CMake查找BLAS包含目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CMake中,我使用 find_package(需要BLAS),然后使用 BLAS_FOUND BLAS_LINKER_FLAGS BLAS_LIBRARIES 变量。

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 ,根据已选择的BLAS实现,找到包含目录?尚未在macOS上为Accelerate框架或OpenBLAS设置。

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.

推荐答案

如果还没有提供脚本,您可以自己编写一个或扩展现有的FindBLAS.cmake来设置所需的路径(BLAS_INCLUDE_DIRS)。

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).

例如,您可以在 find_path 中使用为了搜索包含一些标准BLAS包含文件的目录,或者特别是项目中所需的目录。您可以包括可能期望在其上安装BLAS的默认公共目录,也可以包括基于环境变量的路径。 Linux的示例:

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)

这将搜索<$ / usr / include / / usr / local / include cblas.h $ c>, $ ENV {BLAS_HOME} / include 并在BLAS_INCLUDE_DIRS中设置找到的路径。

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.

您可以添加此脚本放在项目中的 src / cmake / FindBLAS.cmake 文件中,然后通过以下命令将其告知顶级Cmake文件:

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/")

这篇关于使用CMake查找BLAS包含目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆