[Mlir-commits] [mlir] [mlir] Fix MLIR dylib CMake config when LLVM_BUILD_LLVM_DYLIB is OFF (PR #155488)
Christopher Bate
llvmlistbot at llvm.org
Thu Aug 28 17:02:27 PDT 2025
================
@@ -172,8 +172,11 @@ set(MLIR_INSTALL_AGGREGATE_OBJECTS 1 CACHE BOOL
set(MLIR_BUILD_MLIR_C_DYLIB 0 CACHE BOOL "Builds libMLIR-C shared library.")
-set(MLIR_LINK_MLIR_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
- "Link tools against libMLIR.so")
+set(MLIR_BUILD_MLIR_DYLIB 0 CACHE BOOL "Builds the libMLIR shared library")
+set(MLIR_LINK_MLIR_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL "Link tools against libMLIR.so")
+if (MLIR_LINK_MLIR_DYLIB)
----------------
christopherbate wrote:
Here you're setting non-cache variable `MLIR_BUILD_MLIR_DYLIB`, but line 175 is populating a cache variable MLIR_BUILD_MLIR_DYLIB. Both will persist and hold different values, which can be an endless source of confusion (for me at least). Maybe other CMake users find this intuitive (that a non-cache variable overrides the cache variable of the same name if set), but I suspect most people don't know that two different kinds of variables are being created here.
Personally I think it makes more sense to force-set the cache variable
```
if(<condition>)
set(MLIR_BUILD_MLIR_DYLIB ON CACHE BOOL "" FORCE)
endif()
```
https://github.com/llvm/llvm-project/pull/155488
More information about the Mlir-commits
mailing list