在cmake构建中使用LLVM [英] Use LLVM in a cmake build

查看:778
本文介绍了在cmake构建中使用LLVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建自己的使用LLVM的项目.我已在官方网站(最新版本)上下载了源代码和预编译的软件包.

I'm trying to build my own project that use LLVM. I downloaded the source code and the precompiled package on the official web site (last version).

http://releases.llvm.org/download.html

我下载了:

LLVM source code
Clang for Windows (64-bit)

仅供参考,我不构建LLVM ...只想使用它!

FYI, I don't build LLVM... only want to use it !

我按照这里的指示进行: http://llvm.org/docs/CMake.html#在您的项目中嵌入llvm

I followed the instruction here : http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project

在在您的项目中嵌入LLVM"部分

in the section : "Embedding LLVM in your project"

因此,我添加了以下代码:

So, I added this code :

find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message("LLVM_INCLUDE_DIRS=${LLVM_INCLUDE_DIRS}")
message("LLVM_DEFINITIONS=${LLVM_DEFINITIONS}")

但是我收到一些cmake错误消息,这是我的输出:

But I got several cmake error messages, here is my output :

-- Using LLVMConfig.cmake in: C:\\Luciad_src\\libs\\LLVM\\cmake\\modules
LLVM_INCLUDE_DIRS=
LLVM_DEFINITIONS=
CMake Error at C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:31 (list):
  list sub-command REMOVE_ITEM requires two or more arguments.
Call Stack (most recent call first):
  C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:256 (is_llvm_target_library)
  components/query/CMakeLists.txt:15 (llvm_map_components_to_libnames)

我的脚本或使用的软件包是否有问题?有什么主意吗?

Is there a problem with my script, or the packages I use ? Any idea ?

感谢您的帮助

推荐答案

您可以将LLVM作为二进制或源程序包.

You can have the LLVM as binary or source package.

二进制软件包不包括CMake支持.如果比较两个安装(左侧为二进制文件,右侧为构建并安装后的源代码),则可以看到不同之处:

The binary package does not include CMake support. If you compare both installations (binary on the left, source after building and installing it on the right) you can see the difference:

LLVM-5.0.0-win64.exe < => llvm-5.0.1.src. tar.xz (已构建并安装)

LLVM-5.0.0-win64.exe <=> llvm-5.0.1.src.tar.xz (build and installed)

因此,您需要先构建并安装源包才能获得CMake支持.在Windows计算机上,我需要一个具有管理员权限的cmd shell ,一个Visual Studio安装,转到下载和提取的源并执行以下操作:

So you need to build and install the source package first to get CMake support. On my Windows machine I needed a cmd shell with administrator rights, a Visual Studio installation, go to the downloaded and extracted sources and do:

> mkdir mybuilddir
> cd mybuilddir
> cmake ..
> cmake --build . --config Release --target INSTALL

如果我现在使用您的CMake示例,我将得到:

If I now use your CMake example I get:

-- Found LLVM 5.0.1
-- Using LLVMConfig.cmake in: C:/Program Files (x86)/LLVM/lib/cmake/llvm
LLVM_INCLUDE_DIRS=C:/Program Files (x86)/LLVM/include
LLVM_DEFINITIONS=-DLLVM_BUILD_GLOBAL_ISEL -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Configuring done

这篇关于在cmake构建中使用LLVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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