Bazel to CMake: Make globs relative and exclude directories

This matches bazel behavior and allows the use of glob results for creating target names.

PiperOrigin-RevId: 306350229
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
index b5c59fb..e92f32f 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -28,6 +28,10 @@
 import bazel_to_cmake_targets
 
 
+def _expand_cmake_var(var):
+  return "${" + var + "}"
+
+
 class BuildFileFunctions(object):
   """Object passed to `exec` that has handlers for BUILD file functions."""
 
@@ -291,18 +295,23 @@
       # Bazel `*.mlir` glob -> CMake Variable `_GLOB_X_MLIR`
       var = "_GLOB_" + pattern.replace("*", "X").replace(".", "_").upper()
       glob_vars.append(var)
-      self.converter.body += f"file(GLOB {var} CONFIGURE_DEPENDS {pattern})\n"
+      self.converter.body += (
+          f"file(GLOB {var} LIST_DIRECTORIES false"
+          f" RELATIVE {_expand_cmake_var('CMAKE_CURRENT_SOURCE_DIR')}"
+          f" CONFIGURE_DEPENDS {pattern})\n")
     for pattern in exclude:
       if "**" in pattern:
         raise NotImplementedError("Recursive globs not supported")
       exclude_var = ("_GLOB_" +
                      pattern.replace("*", "X").replace(".", "_").upper())
-      self.converter.body += (f"file(GLOB {exclude_var} CONFIGURE_DEPENDS "
-                              f"{pattern})\n")
+      self.converter.body += (
+          f"file(GLOB {exclude_var} LIST_DIRECTORIES false"
+          f" RELATIVE {_expand_cmake_var('CMAKE_CURRENT_SOURCE_DIR')}"
+          f" CONFIGURE_DEPENDS {pattern})\n")
       for glob_var in glob_vars:
-        self.converter.body += ("list(REMOVE_ITEM " + glob_var + " ${" +
-                                exclude_var + "})\n")
-    return ["${" + var + "}" for var in glob_vars]
+        self.converter.body += (
+            f"list(REMOVE_ITEM {glob_var} {_expand_cmake_var(exclude_var)})\n")
+    return [_expand_cmake_var(var) for var in glob_vars]
 
   # TODO(gcmn) implement these types of functions in a less hard-coded way
   def platform_trampoline_deps(self, basename, path="base"):
diff --git a/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Flow/IR/CMakeLists.txt b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
index 03f2ee3..bbec79d 100644
--- a/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/IR/CMakeLists.txt b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
index 3e63bb4..b84e542 100644
--- a/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Target/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Target/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/IREE/IR/CMakeLists.txt b/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
index 915182d..01bfa74 100644
--- a/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt b/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
index 4cba52a..da8150b 100644
--- a/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
index abc772c..095e366 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
index 8c8a73a..0b41319 100644
--- a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_embed_data(
   NAME
     tensorlist_imports
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
index c0aa73b..e914107 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Shape/IR/CMakeLists.txt b/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
index 1c1e063..df37045 100644
--- a/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VM/IR/CMakeLists.txt b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
index 19ac435..05b1fe4 100644
--- a/iree/compiler/Dialect/VM/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt b/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
index ccdd396..6495524 100644
--- a/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt b/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
index 666308d..7a671ba 100644
--- a/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
index c51879a..6ea6209 100644
--- a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     IR
diff --git a/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Translation/CodegenPasses/test/CMakeLists.txt b/iree/compiler/Translation/CodegenPasses/test/CMakeLists.txt
index 75333e5..0e11307 100644
--- a/iree/compiler/Translation/CodegenPasses/test/CMakeLists.txt
+++ b/iree/compiler/Translation/CodegenPasses/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Translation/SPIRV/IndexComputation/test/CMakeLists.txt b/iree/compiler/Translation/SPIRV/IndexComputation/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Translation/SPIRV/IndexComputation/test/CMakeLists.txt
+++ b/iree/compiler/Translation/SPIRV/IndexComputation/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Translation/SPIRV/LinalgToSPIRV/test/CMakeLists.txt b/iree/compiler/Translation/SPIRV/LinalgToSPIRV/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Translation/SPIRV/LinalgToSPIRV/test/CMakeLists.txt
+++ b/iree/compiler/Translation/SPIRV/LinalgToSPIRV/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/CMakeLists.txt b/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/CMakeLists.txt
index 17d53b9..fcc538b 100644
--- a/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/CMakeLists.txt
+++ b/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/compiler/Translation/test/CMakeLists.txt b/iree/compiler/Translation/test/CMakeLists.txt
index 0fb4804..a936b24 100644
--- a/iree/compiler/Translation/test/CMakeLists.txt
+++ b/iree/compiler/Translation/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/modules/check/test/CMakeLists.txt b/iree/modules/check/test/CMakeLists.txt
index 38ccc33..43636c0 100644
--- a/iree/modules/check/test/CMakeLists.txt
+++ b/iree/modules/check/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/samples/custom_modules/dialect/CMakeLists.txt b/iree/samples/custom_modules/dialect/CMakeLists.txt
index 61a68cc..af49b15 100644
--- a/iree/samples/custom_modules/dialect/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_TD CONFIGURE_DEPENDS *.td)
+file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
 iree_cc_library(
   NAME
     dialect
diff --git a/iree/samples/custom_modules/dialect/test/CMakeLists.txt b/iree/samples/custom_modules/dialect/test/CMakeLists.txt
index 000c9be..303f0ca 100644
--- a/iree/samples/custom_modules/dialect/test/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/test/e2e/linalg_path/CMakeLists.txt b/iree/test/e2e/linalg_path/CMakeLists.txt
index 92b4749..e2b4157 100644
--- a/iree/test/e2e/linalg_path/CMakeLists.txt
+++ b/iree/test/e2e/linalg_path/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/test/e2e/models/CMakeLists.txt b/iree/test/e2e/models/CMakeLists.txt
index ad0bce3..e83dc0e 100644
--- a/iree/test/e2e/models/CMakeLists.txt
+++ b/iree/test/e2e/models/CMakeLists.txt
@@ -14,8 +14,8 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
-file(GLOB _GLOB_MNIST_MLIR CONFIGURE_DEPENDS mnist.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_MNIST_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS mnist.mlir)
 list(REMOVE_ITEM _GLOB_X_MLIR ${_GLOB_MNIST_MLIR})
 iree_lit_test_suite(
   NAME
diff --git a/iree/test/e2e/regression/CMakeLists.txt b/iree/test/e2e/regression/CMakeLists.txt
index 92b4749..e2b4157 100644
--- a/iree/test/e2e/regression/CMakeLists.txt
+++ b/iree/test/e2e/regression/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit
diff --git a/iree/tools/test/CMakeLists.txt b/iree/tools/test/CMakeLists.txt
index c4a9d23..658aa8e 100644
--- a/iree/tools/test/CMakeLists.txt
+++ b/iree/tools/test/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 iree_add_all_subdirs()
 
-file(GLOB _GLOB_X_MLIR CONFIGURE_DEPENDS *.mlir)
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
 iree_lit_test_suite(
   NAME
     lit