[clang] [mlir] [CMake] Don't reference unexported targets from dependency-only configs (PR #222630)

Eugene Epshteyn via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 05:41:20 PDT 2026


eugeneepshteyn wrote:

**Verification** (configure-only, no build needed to reproduce):

Configuring with `-DLLVM_ENABLE_PROJECTS=flang -DLLVM_ENABLE_RUNTIMES=flang-rt` and then running `find_package` against the generated build tree, exactly as `runtimes/CMakeLists.txt` does:

| | `ClangConfig` | `ClangTargets` | config includes targets | `find_package(Clang)` | `find_package(MLIR)` |
|---|---|---|---|---|---|
| before | present | absent | yes | **error** | **error** |
| after | present | absent | no | ok | ok |

Control, with `-DLLVM_ENABLE_PROJECTS='clang;mlir;flang'` (both explicitly enabled): targets files are exported and the configs include them, as before — unchanged by this patch.

An alternative fix would be to emit `include(... OPTIONAL)`, matching the distribution path in `LLVMDistributionSupport.cmake`; I chose the explicit guard because it mirrors the two existing `LLVM_DEPENDENCY_ONLY_PROJECTS` checks in the same files. Happy to switch if you prefer the other form.


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


More information about the cfe-commits mailing list