llvm的cmake集成 [英] llvm's cmake integration

查看:159
本文介绍了llvm的cmake集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用C/C ++构建一个编译器/解释器. 当我注意到LLVM时,我认为它非常适合我的需求,因此我试图将LLVM集成到我现有的构建系统中(我使用CMake).

I'm currently building a compiler/interpreter in C/C++. When I noticed LLVM I thought it would fit greatly to what I needed and so I'm trying to integrate LLVM in my existing build system (I use CMake).

我阅读了关于CMake中的LLVM.我复制并粘贴了示例CMakeLists.txt,将LLVM_ROOT更改为〜/.llvm/(这是我下载并构建LLVM和clang的位置),它说这不是有效的LLVM安装.我可以实现的最佳结果是将LLVM_ROOT更改为〜/.llvm/llvm的错误消息找不到LLVMConfig".

I read this bout integration of LLVM in CMake. I copy and pasted the example CMakeLists.txt, changed the LLVM_ROOT to ~/.llvm/ (that's where I downloaded and build LLVM and clang) and it says it isn't a valid LLVM-install. Best result I could achieve was the error message "Can't find LLVMConfig" by changing LLVM_ROOT to ~/.llvm/llvm.

我的〜/.llvm/文件夹如下:

My ~/.llvm/ folder looks like this:

~/.llvm/llvm         # this folder contains source files
~/.llvm/build        # this folder contains object, executable and library files

我通过SVN下载了LLVM和clang.我不是用CMake构建的. 仅仅是我还是CMakeLists.txt出了问题?

I downloaded LLVM and clang via SVN. I did not build it with CMake. Is it just me or is something wrong with the CMakeLists.txt?

推荐答案

此CMake文档页面很烂,但是为LLVM开发设置CMake与其他项目没有什么不同.如果您的标头/库安装在非标准前缀中,则CMake无法猜测它.

This CMake documentation page got rotted, but setting up CMake for LLVM developing isn't different from any other project. If your headers/libs are installed into non-standard prefix, there is no way for CMake to guess it.

您需要将CMAKE_PREFIX_PATH设置为LLVM安装前缀,或者将CMAKE_MODULE_PATH设置为prefix/share/llvm/cmake才能使其正常工作.

You need to set CMAKE_PREFIX_PATH to the LLVM installation prefix or CMAKE_MODULE_PATH to prefix/share/llvm/cmake to make it work.

是的,请使用文档中的第二个代码段(在Alternativaly, you can utilize CMake’s find_package functionality.行下).

And yes, use the second code snippet from documentation (under Alternativaly, you can utilize CMake’s find_package functionality. line).

这篇关于llvm的cmake集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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