[Mlir-commits] [mlir] [mlir][CMake] Modify the behavior of `add_mlir_aggregate ` and add `mlir_c_target_link_libraries`. (PR #141435)
Fabian Mora
llvmlistbot at llvm.org
Mon May 26 09:47:29 PDT 2025
================
@@ -565,6 +580,26 @@ function(add_mlir_aggregate name)
" OBJECTS = ${_local_objects}\n"
" DEPS = ${_local_deps}\n\n")
endforeach()
+
+ if (MLIR_LINK_MLIR_DYLIB)
+ # This builds a regex with all the libraries contained in `libMLIR.so`.
+ # These libraries will be filtered out from the dependencies added by the
+ # EMBED_LIBS.
+ list(GET mlir_libs 0 _libs_regex)
+ list(REMOVE_AT mlir_libs 0)
+ set(_libs_regex "(${_libs_regex}")
+ foreach (lib ${mlir_libs})
+ string(APPEND _libs_regex "|${lib}")
----------------
fabianmcg wrote:
> why? one can freely use [add_mlir_library](https://github.com/llvm/llvm-project/blob/main/mlir/examples/standalone/lib/Standalone/CMakeLists.txt#L1) or [add_mlir_public_c_library](https://github.com/llvm/llvm-project/blob/main/mlir/examples/standalone/lib/CAPI/CMakeLists.txt#L1) downstream right?
I'd discourage that, but yes it's possible. The issue is that `add_mlir_library` has an explicit contract that every downstream user should follow, they all should add `EXCLUDE_FROM_LIBMLIR`. But I recognize this could be simplified.
> does the _deps need to be a genex? If not you can just do [list/set difference](https://stackoverflow.com/a/59578250)?
Nope, as soon as you have `genex` you need `genex` to do any manipulation.
https://github.com/llvm/llvm-project/pull/141435
More information about the Mlir-commits
mailing list