Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何将OpenBLAS定义为CMake中的子目录?_C++_Cmake_Openblas - Fatal编程技术网

C++ 如何将OpenBLAS定义为CMake中的子目录?

C++ 如何将OpenBLAS定义为CMake中的子目录?,c++,cmake,openblas,C++,Cmake,Openblas,我正在使用OpenBLAS进行BLAS和LAPACK例行调用。我不希望我的C++库的用户群必须在他们的机器上安装依赖项。因此,我想在我的第三方中提供OpenBLAS库,并在本地建立CMake链接 树 这是这个最小示例项目的树 OBLASCmake/ ├─ third_party/ │ ├─ OpenBLAS-0.3.15 ├─ CMakeLists.txt ├─ main.cpp main.cpp 使用此cmake运行测试的结果是42.52的输出,作为两个向量的点积 CMakeLists(

我正在使用
OpenBLAS
进行
BLAS
LAPACK
例行调用。我不希望我的
C++
库的用户群必须在他们的机器上安装依赖项。因此,我想在我的
第三方
中提供
OpenBLAS
库,并在本地建立
CMake
链接

树 这是这个最小示例项目的树

OBLASCmake/
├─ third_party/
│  ├─ OpenBLAS-0.3.15
├─ CMakeLists.txt
├─ main.cpp

main.cpp 使用此cmake运行测试的结果是
42.52
的输出,作为两个向量的点积

CMakeLists(我想要的) 此定义本地安装的方法无法正常工作

cmake_minimum_required(VERSION 3.19)
project(OBLASCMake)

set(CMAKE_CXX_STANDARD 11)

add_library(OBLASCMake SHARED main.cpp)
# cant use add_subdirectory and find_package
# add_subdirectory(third_party/OpenBLAS-0.3.15)
set(OpenBLAS_DIR ${CMAKE_SOURCE_DIR}/third_party/OpenBLAS-0.3.15)
find_package(OpenBLAS REQUIRED HINTS ${CMAKE_SOURCE_DIR}/third_party/OpenBLAS-0.3.15)

add_executable(test1 main.cpp)
target_link_libraries(test1 OBLASCMake)
enable_testing()
add_test(NAME RunTest COMMAND ${CMAKE_BINARY_DIR}/test1)
使用CMake生成将导致以下错误消息:

CMake Error at CMakeLists.txt:12 (find_package):
  Could not find a package configuration file provided by "OpenBLAS" with any
  of the following names:

    OpenBLASConfig.cmake
    openblas-config.cmake

  Add the installation prefix of "OpenBLAS" to CMAKE_PREFIX_PATH or set
  "OpenBLAS_DIR" to a directory containing one of the above files.  If
  "OpenBLAS" provides a separate development package or SDK, be sure it has
  been installed.
第三方/OpenBLAS-0.3.15/
中有一个
OpenBLASConfig.cmake
文件,但cmake没有看到它。有人知道为什么cmake无法查看配置文件吗


谢谢您的时间。

在我看来,您是在定义
OpenBLAS\u DIR
而没有在
find\u包
调用中实际使用它(这可能需要绝对
路径
提示
)。

我不是cmake专家,但可能您必须使用绝对路径,如
set(OpenBLAS\u DIR)${CMAKE_SOURCE_DIR_ALWAYS_忘记确切的_NAME}/third_party/OpenBLAS-0.3.15“
对于相同的依赖项,您不使用
add_子目录
find_package
。选择一个。我已经根据前两个注释进行了更新。仍然收到相同的错误消息@AlexReinking@GeneralCode好吧,做你所做的也是为了暗示。
cmake_minimum_required(VERSION 3.19)
project(OBLASCMake)

set(CMAKE_CXX_STANDARD 11)

add_library(OBLASCMake SHARED main.cpp)
# cant use add_subdirectory and find_package
# add_subdirectory(third_party/OpenBLAS-0.3.15)
set(OpenBLAS_DIR ${CMAKE_SOURCE_DIR}/third_party/OpenBLAS-0.3.15)
find_package(OpenBLAS REQUIRED HINTS ${CMAKE_SOURCE_DIR}/third_party/OpenBLAS-0.3.15)

add_executable(test1 main.cpp)
target_link_libraries(test1 OBLASCMake)
enable_testing()
add_test(NAME RunTest COMMAND ${CMAKE_BINARY_DIR}/test1)
CMake Error at CMakeLists.txt:12 (find_package):
  Could not find a package configuration file provided by "OpenBLAS" with any
  of the following names:

    OpenBLASConfig.cmake
    openblas-config.cmake

  Add the installation prefix of "OpenBLAS" to CMAKE_PREFIX_PATH or set
  "OpenBLAS_DIR" to a directory containing one of the above files.  If
  "OpenBLAS" provides a separate development package or SDK, be sure it has
  been installed.