[all-commits] [llvm/llvm-project] 2d51e6: [CMake] Don't reference unexported targets from de...

Eugene Epshteyn via All-commits all-commits at lists.llvm.org
Thu Sep 10 10:27:20 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d51e69fd09e4bdeeed441c8c5fc256584178c79
      https://github.com/llvm/llvm-project/commit/2d51e69fd09e4bdeeed441c8c5fc256584178c79
  Author: Eugene Epshteyn <eepshteyn at nvidia.com>
  Date:   2026-09-10 (Thu, 10 Sep 2026)

  Changed paths:
    M clang/cmake/modules/CMakeLists.txt
    M mlir/cmake/modules/CMakeLists.txt

  Log Message:
  -----------
  [CMake] Don't reference unexported targets from dependency-only configs (#222630)

#221724 stopped exporting a project's targets file when that project is
enabled only as another project's dependency, but the build-tree
`ClangConfig.cmake` and `MLIRConfig.cmake` still include it
unconditionally. `find_package()` therefore finds the config and fails
inside it:

```
CMake Error at build/lib/cmake/clang/ClangConfig.cmake:19 (include):
  include could not find requested file:
    build/lib/cmake/clang/ClangTargets.cmake
Call Stack (most recent call first):
  CMakeLists.txt:90 (find_package)
```

This breaks any configuration that enables Flang without also enabling
Clang or MLIR explicitly: `runtimes/CMakeLists.txt` calls
`find_package(Clang ...)`, which is deliberately not `REQUIRED` and is
expected to tolerate an unavailable package — but a *half-generated*
package is a hard error rather than a "not found". Concretely,
`-DLLVM_ENABLE_PROJECTS=flang -DLLVM_ENABLE_RUNTIMES=flang-rt` fails at
`runtimes-configure`, which is the configuration premerge uses for
flang-rt changes.

This patch guards the include the same way the export itself is guarded,
so a dependency-only project generates a config without a dangling
include. The install-tree path already handles this through
`get_config_exports_includes()`; only the build-tree path was missed.

MLIR has the same defect and is fixed here too. It is currently latent
only because `runtimes/CMakeLists.txt` calls `find_package(Clang)` and
not `find_package(MLIR)`; a `find_package(MLIR)` against a
dependency-only build tree fails identically at `MLIRConfig.cmake:33`.

Assisted-by: AI



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list