1. create testTool
folder under <source root>/tools/
$ cd <clang source root>/tools
$ mkdir testTool & cd testTools
2. create CMakeList.cmake
file and copy below code into it & save
$ vi CMakeList.cmake
add_llvm_tool(testTool)
3. create LLVMBuild.txt
file to describe your tool
$ vi LLVMBuild.txt
[component_0]
type = Tool
name = testTool
parent = Tools
required_libraries =
This is an empty tool project, so we do not need any libraries. If you need, you can do as below:
required_libraries = AsmPrinter DebugInfoDWARF MC Object Support all-targets
4. create main.cpp
file and copy below code into it & save
$ vi main.cpp
#include <cstdio>
int main() {printf("Hello LLVM, I am your new tool, my name is testTool!");}
5. done!
$ cd <where you want to build>
$ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=<where you want to install>
$ ninja testTool