[all-commits] [llvm/llvm-project] 501c6f: [CMake] Propagate dependencies to OBJECT libraries...

nextsilicon-itay-bookstein via All-commits all-commits at lists.llvm.org
Mon Mar 2 13:10:36 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 501c6fda951b9a50e77ee324015b0b0aea9e2a5b
      https://github.com/llvm/llvm-project/commit/501c6fda951b9a50e77ee324015b0b0aea9e2a5b
  Author: nextsilicon-itay-bookstein <55076759+nextsilicon-itay-bookstein at users.noreply.github.com>
  Date:   2026-03-02 (Mon, 02 Mar 2026)

  Changed paths:
    M clang/cmake/modules/AddClang.cmake
    M lld/tools/lld/CMakeLists.txt
    M llvm/cmake/modules/AddLLVM.cmake
    M llvm/cmake/modules/LLVM-Config.cmake
    M mlir/cmake/modules/AddMLIR.cmake

  Log Message:
  -----------
  [CMake] Propagate dependencies to OBJECT libraries in add_llvm_library (re-land) (#184201)

Previously, transitively inherited calls to
`target_include_directories(foo SYSTEM ...)` were being squashed into a
flat list of includes, effectively stripping off `-isystem` and
unintentionally forwarding warnings from such dependencies.

To correctly propagate `SYSTEM` dependencies, use
`target_link_libraries` to forward the parent target's link dependencies
to the OBJECT library (similar to the `_static` flow below). Unlike a
flat `target_include_directories`, this lets CMake resolve transitive
SYSTEM include directories through the proper dependency chain.

Note that `target_link_libraries` on an OBJECT library propagates all
usage requirements, not just includes. This also brings in transitive
`INTERFACE_COMPILE_DEFINITIONS`, `INTERFACE_COMPILE_OPTIONS`, and
`INTERFACE_COMPILE_FEATURES`. This is arguably more correct, as the
OBJECT library compiles the same sources and should see the same flags.

The existing `target_include_directories` call is retained for include
directories set directly on the target (not through link dependencies).
CMake deduplicates include directories that appear through both paths.
Compile definitions and options may technically appear twice (once via
the OBJECT library, once via the consuming target), but duplicate `-D`
and flag entries are harmless in practice.

Also fix `clang_target_link_libraries` and `mlir_target_link_libraries`
to forward the link type (PUBLIC/PRIVATE/INTERFACE) to `obj.*` targets.
Previously the type keyword was silently dropped, resulting in plain-
signature `target_link_libraries` calls. This is now required because
the new keyword-signature call in `llvm_add_library` would otherwise
conflict (CMake requires all calls on a target to use the same
signature).



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