gpt4 book ai didi

从 brew 使用 LLVM 5.0.0 时出现 Cmake 错误

转载 作者:行者123 更新时间:2023-12-02 03:42:46 24 4
gpt4 key购买 nike

我正在尝试使用 Homebrew (MacOS High Sierra 10.13.3) 提供的库存 LLVM 5.0.0。 LLVM 安装在我的机器上 /usr/local/Cellar/llvm/5.0.0/

现在,在我的项目中,CMakeLists.txt 中有以下行:

# Find the LLVM library
find_package( LLVM 5.0.0 REQUIRED )
include_directories( "${LLVM_INCLUDE_DIRS}" )
link_directories(${LLVM_LIBRARY_DIRS})
message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}")

如果我在没有任何参数的情况下运行 CMake,我会得到:

CMake Error at CMakeLists.txt:74 (find_package): By not providing "FindLLVM.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "LLVM", but CMake did not find one.

Could not find a package configuration file provided by "LLVM" (requested version 5.0.0) with any of the following names:

LLVMConfig.cmake
llvm-config.cmake

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

它告诉我找不到 LLVM。因此,我将路径传递给 LLVM_DIR,如下所示:

cmake .. -DLLVM_DIR=/usr/local/Cellar/llvm/5.0.0/share/cmake/modules/

我希望一切正常。相反,我收到以下错误:

CMake Error at CMakeLists.txt:74 (find_package): Could not find a configuration file for package "LLVM" that is compatible with requested version "5.0.0".

The following configuration files were considered but not accepted:

/usr/local/Cellar/llvm/5.0.0/share/cmake/modules/llvm-config.cmake, version: unknown

由于某些原因,该版本不存在于 share/cmake/modules 目录中的任何位置。

如何在不更改 brew 安装的 LLVM 的情况下解决此问题?

最佳答案

找到了答案。我向 LLVM_DIR 传递了一条错误的路径。我只需要使用另一个目录(埋在 lib 中,而不是在 share 中):

cmake .. -DLLVM_DIR=/usr/local/Cellar/llvm/5.0.0/lib/cmake/llvm/

不确定为什么 brew 决定为 LLVM 安装 2 个版本的 CMake 助手,一个在 share 中,一个在 lib 中。

关于从 brew 使用 LLVM 5.0.0 时出现 Cmake 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47956468/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com