I recently built and installed llvm to my system with the expectation that this would be what is neccessary to build qtcreator: https://paste.ubuntu.com/p/23GCCS5xxS/
Based on what I saw there, I set the variable as such:
➜ qt6.2 git:(6.2) ✗ echo $LLVM_INSTALL_DIR
/usr/local/lib/cmake/llvm/
However when configuring Qt6.2, it still gives
WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either set CMAKE_PREFIX_PATH or LLVM_INSTALL_DIR to the location of your llvm installation.
And from what I understand, when I built llvm, I didn't build Clang with it. Based on https://clang.llvm.org/get_started.html it gives the following line:
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
make
#This builds both LLVM and Clang for debug mode.
Which is frustrating because I now have to build it again, which takes forever. I'd just like the command that builds and installs everything from llvm, so I don't have to keep going back to these things. Is that possible?
To build everything, do this:
$ git clone --depth 1 --branch llvmorg-19.1.0 https://github.com/llvm/llvm-project.git
$ cmake -S llvm-project/llvm -B llvm-project/build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=all \
-DLLVM_ENABLE_RUNTIMES=all
$ cmake --build llvm-project/build -j8
$ cmake --install llvm-project/build --prefix /usr/local # or somewhere else
You might also be interested in the following build flags for the first CMake command:
-DLLVM_ENABLE_ASSERTIONS=ON
-- good for debugging-DLLVM_ENABLE_EH=ON
-- enable if your application uses C++ exceptions-DLLVM_ENABLE_RTTI=ON
-- enable if your application uses C++ RTTIAlso see the upstream documentation: https://llvm.org/docs/CMake.html
Note that some of the LLVM projects can only be built with clang. I won't get into bootstrapping issues, but if the build fails, you can winnow down the list of projects from all
to a subset of the following: clang
, clang-tools-extra
, cross-project-tests
, libc
, libclc
, lld
, lldb
, openmp
, polly
, and pstl
.
You can also reduce the list of runtimes to a subset of compiler-rt
, libc
, libcxx
, libcxxabi
, libunwind
, and openmp
.
Note that LLVM_ENABLE_PROJECTS
and LLVM_ENABLE_RUNTIMES
should not overlap. The latter builds each target with the just-built clang.