[clang] RFC: [cmake] Export CLANG_RESOURCE_DIR in ClangConfig (PR #97197)

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 00:09:14 PDT 2024


kimgr wrote:

I think at the time we started doing this, Clang's builtin includes lookup basically did `$dirname($0)/../lib/llvm-$version/clang/$version/include`. So when building `include-what-you-use` in a separate tree, the resulting binary didn't have the builtin headers in the right place, and we wouldn't be able to run tests.

We support three build modes:

* as part of LLVM+Clang with `LLVM_EXTERNAL_PROJECTS=iwyu` and `LLVM_EXTERNAL_IWYU_SOURCE_DIR`
* with `CMAKE_PREFIX_PATH` pointing to a package-installed LLVM+Clang
* with `CMAKE_PREFIX_PATH` pointing to an LLVM+Clang build tree

In the first case, depending on the `Headers` target makes sure all headers are copied into the build tree.

For the latter two we synthesize a `Headers` target (because it's not exported) based on the Clang resource dir.

https://github.com/llvm/llvm-project/pull/97197


More information about the cfe-commits mailing list