将CMake与LLVM一起使用时出错

AUD*_*IUV 6 c++ ubuntu cmake llvm

所以我正在尝试使用LLVM构建一个玩具编译器,我想使用CMake作为我的构建系统.我尝试使用LLVM网站上的示例CMakeLists.txt,但运行时遇到以下错误cmake:

CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178  (include):
  include could not find load file:

    /usr/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)


CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:181 (include):
  include could not find load file:

    /usr/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)
Run Code Online (Sandbox Code Playgroud)

当我去调查问题时,我发现我的系统上的路径实际上是/usr/share/llvm-3.8/.当我尝试将路径更改为/usr/share/llvm/预期时,我收到另一个错误:

CMake Error at /usr/share/llvm/cmake/LLVMExports.cmake:1034 (message):
  The imported target "LLVMSupport" references the file

     "/usr/lib/libLLVMSupport.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/share/llvm/cmake/LLVMExports.cmake"

  but not all the files it references.
Run Code Online (Sandbox Code Playgroud)

我真的不是CMake如何工作的专家,所以我不确定从哪里开始.我正在运行Ubuntu 16.04,我尝试通过各种不同的软件包安装LLVM,结果相同.这是Ubuntu的包装系统的问题,还是我能解决的问题?

Cod*_*oka 5

AFAIK,这是 Ubuntu 打包中的一个众所周知的错误。Ubuntu 16.04 上的 llvm-3.8-dev 中仍然存在原始问题,请参见此处此处

尝试LLVMExports.cmake通过手动设置导入前缀进行修复时

set(_IMPORT_PREFIX "/usr/lib/llvm-3.8")
Run Code Online (Sandbox Code Playgroud)

CMake 能够找到libLLVMSupport.a和其他库。但是,我遇到了以下问题

 The imported target "PollyISL" references the file

    "/usr/lib/llvm-3.8/lib/libPollyISL.a"

 but this file does not exist.  Possible reasons include:
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是,libPollyISL.aLLVM 安装目录中甚至不存在库。因此,问题不仅仅是 CMake 配置。

为了节省时间,请自己从源代码构建 LLVM 并设置 LLVM_DIR 环境变量。请参阅本教程