[Mlir-commits] [mlir] 9325f22 - [MLIR] Normalize path separator in MLIRConfig.cmake (#208659)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 13 05:52:42 PDT 2026


Author: Michael Kruse
Date: 2026-07-13T12:52:37Z
New Revision: 9325f22f1cf17a6f192519163dd449d684700d2a

URL: https://github.com/llvm/llvm-project/commit/9325f22f1cf17a6f192519163dd449d684700d2a
DIFF: https://github.com/llvm/llvm-project/commit/9325f22f1cf17a6f192519163dd449d684700d2a.diff

LOG: [MLIR] Normalize path separator in MLIRConfig.cmake (#208659)

Under Windows, the paths may contain `\` path separators.
`MLIR_TABLEGEN_EXE` is added into MLIRConfig.cmake where backslashes are
interpreted as escape characters. This results in syntax errors during
`find_package(MLIR)`.

Fix by using CMake-normalized paths (`/` separator under all platforms).
LLVM/Clang do not put their tablegen paths in their config files.

Added: 
    

Modified: 
    mlir/cmake/modules/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt
index 8a00a3d4de98c..42362d864874c 100644
--- a/mlir/cmake/modules/CMakeLists.txt
+++ b/mlir/cmake/modules/CMakeLists.txt
@@ -56,9 +56,11 @@ set(MLIR_CONFIG_INCLUDE_DIRS
   "${MLIR_BINARY_DIR}/include"
   )
 # Refer to the best host mlir-tblgen, which might be a host-optimized version
-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}")
+# TO_CMAKE_PATH normalizes path separators across platforms. Backslashes would
+# cause a syntax error in MLIRConfig.cmake.
+file(TO_CMAKE_PATH "${MLIR_TABLEGEN_EXE}" MLIR_CONFIG_TABLEGEN_EXE)
+file(TO_CMAKE_PATH "${MLIR_PDLL_TABLEGEN_EXE}" MLIR_CONFIG_PDLL_TABLEGEN_EXE)
+file(TO_CMAKE_PATH "${MLIR_SRC_SHARDER_TABLEGEN_EXE}" MLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE)
 set(MLIR_CONFIG_LINK_MLIR_DYLIB ${MLIR_LINK_MLIR_DYLIB})
 llvm_canonicalize_cmake_booleans(
   MLIR_CONFIG_LINK_MLIR_DYLIB


        


More information about the Mlir-commits mailing list