[Mlir-commits] [mlir] [mlir][cmake] Export MLIR_LINK_MLIR_DYLIB in MLIRConfig.cmake (PR #207336)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jul 3 00:28:33 PDT 2026


https://github.com/qyingwu created https://github.com/llvm/llvm-project/pull/207336

Fixes #197175.

`MLIRConfig.cmake` does not currently propagate `MLIR_LINK_MLIR_DYLIB`
to out-of-tree MLIR users. Standalone projects using
`find_package(MLIR CONFIG)` and `include(AddMLIR)` therefore do not
observe the value used by `mlir_target_link_libraries(...)` when MLIR
was configured with `-DMLIR_LINK_MLIR_DYLIB=ON`.

This mirrors LLVM's existing `LLVM_LINK_LLVM_DYLIB` export pattern by:
- defining `MLIR_CONFIG_LINK_MLIR_DYLIB` in `mlir/cmake/modules/CMakeLists.txt`
- emitting it from `mlir/cmake/modules/MLIRConfig.cmake.in`

Verification:
- configured with `-DMLIR_LINK_MLIR_DYLIB=ON` and confirmed both generated
  build-tree and install-tree `MLIRConfig.cmake` files contain
  `set(MLIR_LINK_MLIR_DYLIB ON)`
- configured with `-DMLIR_LINK_MLIR_DYLIB=OFF` and confirmed neither generated
  config contains `MLIR_LINK_MLIR_DYLIB`

>From 77325b2b497fd5f30c622b48bdb812eb140853e3 Mon Sep 17 00:00:00 2001
From: qyingwu <qiyingwu at utexas.edu>
Date: Fri, 3 Jul 2026 00:20:18 -0700
Subject: [PATCH] [mlir][cmake] Export MLIR_LINK_MLIR_DYLIB in MLIRConfig.cmake

---
 mlir/cmake/modules/CMakeLists.txt      | 5 +++++
 mlir/cmake/modules/MLIRConfig.cmake.in | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt
index 47349f0c7eb62..8b49e96bf2531 100644
--- a/mlir/cmake/modules/CMakeLists.txt
+++ b/mlir/cmake/modules/CMakeLists.txt
@@ -60,6 +60,11 @@ set(MLIR_CONFIG_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}")
 set(MLIR_CONFIG_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}")
 set(MLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE "${MLIR_SRC_SHARDER_TABLEGEN_EXE}")
 
+if (MLIR_LINK_MLIR_DYLIB)
+  set(MLIR_CONFIG_LINK_MLIR_DYLIB
+      "set(MLIR_LINK_MLIR_DYLIB ${MLIR_LINK_MLIR_DYLIB})")
+endif()
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
diff --git a/mlir/cmake/modules/MLIRConfig.cmake.in b/mlir/cmake/modules/MLIRConfig.cmake.in
index 71f3e028b1e88..ae426b43382c1 100644
--- a/mlir/cmake/modules/MLIRConfig.cmake.in
+++ b/mlir/cmake/modules/MLIRConfig.cmake.in
@@ -17,6 +17,8 @@ set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
 set(MLIR_ENABLE_BINDINGS_PYTHON "@MLIR_ENABLE_BINDINGS_PYTHON@")
 set(MLIR_ENABLE_EXECUTION_ENGINE "@MLIR_ENABLE_EXECUTION_ENGINE@")
 
+ at MLIR_CONFIG_LINK_MLIR_DYLIB@
+
 set_property(GLOBAL PROPERTY MLIR_ALL_LIBS "@MLIR_ALL_LIBS@")
 set_property(GLOBAL PROPERTY MLIR_DIALECT_LIBS "@MLIR_DIALECT_LIBS@")
 set_property(GLOBAL PROPERTY MLIR_CONVERSION_LIBS "@MLIR_CONVERSION_LIBS@")



More information about the Mlir-commits mailing list