在源代码目录外编译clang例子
之前bitcode读写的例子编译一直报错,CMakeLists.txt改的面目全非,搜索过程中找到一个llvm工具编译的通用模版。
如何为独立的clang tool编写CMakeLists.txt
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH=/Users/fancy/Documents/LLVM/build/
DCMAKE_PREFIX_PATH指定你的llvm编译生成目录
CMakeLists.txt:
1 | cmake_minimum_required(VERSION 3.4.3) |
COMPONENT_LIST添加你的代码需要的库名称(模块名就行,不需要完整的文件名)
https://heejune.me/2016/08/17/build-your-own-clang-example-outside-of-the-llvm-source-tree/
https://qiita.com/Chironian/items/8770c8ab833086fb51a9#328cmakeliststxt%E3%81%BE%E3%81%A8%E3%82%81