[CMake] Propagate dependencies to OBJECT libraries in `add_llvm_library` (#183541) 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 should be 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).
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.