I am trying to make an LLVM / Clang-based tool ( basically a recreation of cc1_main that I can compile to web assembly using emscripten in a single monolithic build ), and I have heard on on the discord the LLVM target_link_libraries automatically sets up the include directories for the project. However, I have not found this to be the case ( editor-wasmv3/CMakeLists.txt at main · AlistairKeiller/editor-wasmv3 · GitHub ). This build will always error with Clang/Frontend/CompilerInstance.h: No such file or directory
( or whatever I try to include ). I can get this build to work by manually specifying include directories, but I am left wondering:
what is the cleanest way to set up this project’s build system?
The standard procedure is described here.
That uses the system install of LLVM, which I have not been able to get working when targeting webassembly with emscripten.
The system install probably only supports arm64 or x86. For web assembly, you have to install LLVM yourself and enable the web assembly target.
If I have to do a custom build of LLVM anyway, I would much prefer it to be in a monolithic build ( like with LLVM_EXTERNAL_PROJECTS ) rather than installing it and using it in a component build. I redid my test repo to be as similar as possible to clang-tools-extra/tool-template, but includes still do not work. Where does clang-tools-extra/tool-template include the necessary directories and how can I replicate it with LLVM_EXTERNAL_PROJECTS?
Ok, my solution is just to fork LLVM and make my project in the clang-tools-extra, thanks for the help
I missed this earlier, but you’ll need to manually set up your include directories to contain the Clang source dirs. You can see how Swift does it here and here.
> ninja install-clang-libraries install-llvm-libraries install-clang-headers install-llvm-headers
> ninja install-cmake-exports
This should suffice for the guidelines described above.