[Mlir-commits] [mlir] [mlir] Silence warning on unit tests on Windows (PR #191559)

Alexandre Ganea llvmlistbot at llvm.org
Fri Apr 10 15:51:57 PDT 2026


https://github.com/aganea created https://github.com/llvm/llvm-project/pull/191559

MLIR unit tests use -Wundef; gtest headers reference macros that may be unset:
```
warning: 'GTEST_LINKED_AS_SHARED_LIBRARY' is not defined, evaluates to 0 [-Wundef]
```

>From 497a8be65cc6eafb81d18da01b11cd054091b732 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <aganea at havenstudios.com>
Date: Fri, 10 Apr 2026 18:12:41 -0400
Subject: [PATCH] [mlir] Silence warning on unit tests on Windows

MLIR unit tests use -Wundef; gtest headers reference macros that may be unset:
```
warning: 'GTEST_LINKED_AS_SHARED_LIBRARY' is not defined, evaluates to 0 [-Wundef]
```
---
 mlir/unittests/CMakeLists.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mlir/unittests/CMakeLists.txt b/mlir/unittests/CMakeLists.txt
index 89332bce5fe05..0a18dc36b923a 100644
--- a/mlir/unittests/CMakeLists.txt
+++ b/mlir/unittests/CMakeLists.txt
@@ -1,5 +1,8 @@
-# To silence warning caused by Wundef.
-add_definitions(-DGTEST_NO_LLVM_SUPPORT=0)
+# To silence warnings caused by -Wundef in gtest/gmock headers.
+add_definitions(
+  -DGTEST_NO_LLVM_SUPPORT=0
+  -DGTEST_LINKED_AS_SHARED_LIBRARY=0
+  -DGTEST_CREATE_SHARED_LIBRARY=0)
 
 function(add_mlir_unittest test_dirname)
   add_unittest(MLIRUnitTests ${test_dirname} ${ARGN})



More information about the Mlir-commits mailing list