[clang] RFC: [cmake] Export CLANG_RESOURCE_DIR in ClangConfig (PR #97197)
Evan Wilde via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 12 08:51:30 PDT 2024
etcwilde wrote:
So, Swift actually has/had a similar issue. We embed a copy of clang in Swift, so we needed to find the corresponding clang resource headers and install them with our compiler which is why I wrote https://github.com/llvm/llvm-project/pull/88317 to expose them. It adds the clang-resource-headers as an interface library to the ClangConfig.cmake that gets loaded when you do `find_package(Clang CONFIG)`. "Linking" against that interface library adds the clang-resource-header location to your include search paths.
```cmake
# Find 'ClangConfig.cmake' and import its targets
find_package(Clang CONFIG REQUIRED)
# Pass the location as a header-search path to "SomeLibrary"
target_link_libraries(SomeLibrary PRIVATE clang-resource-headers)
# Alternatively, if you just want the location, it's available as a target-property:
get_target_property(CLANG_IMPORT_HEADERS clang-resource-headers INTERFACE_INCLUDE_DIRECTORIES)
```
To install the `ClangConfig.cmake` and the clang cmake exports files in the LLVM build/install, I believe the install component is `clang-cmake-exports`.
https://github.com/llvm/llvm-project/pull/97197
More information about the cfe-commits
mailing list