[llvm] [cmake] Fix DIA SDK detection from VSINSTALLDIR (PR #218499)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 12:49:43 PDT 2026


https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/218499

The DIA SDK wasn't automatically detected after #160354, because `if($Env{VSINSTALLDIR})` would be evaluated as [`if(<string>)`](https://cmake.org/cmake/help/latest/command/if.html#string) after expansion. This always evaluates to false unless it's one of the true constants like `1` or `ON`. In turn the DIA SDK was never automatically detected.

The current 23.1.0 RC builds are also built without it even though the SDK should be available (e.g. `llvm-pdbutil diadump <pdb>` fails).

The fix is to use [`if(DEFINED ENV{<name>})`](https://cmake.org/cmake/help/latest/command/if.html#defined).

>From 9bff8fae9d798760155b42801c91c50db0ccf5cb Mon Sep 17 00:00:00 2001
From: Nerixyz <nerixdev at outlook.de>
Date: Mon, 24 Aug 2026 21:42:26 +0200
Subject: [PATCH] [cmake] Fix DIA SDK detection from VSINSTALLDIR

---
 llvm/cmake/modules/FindDIASDK.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/FindDIASDK.cmake b/llvm/cmake/modules/FindDIASDK.cmake
index f3133d29de3b2..6b38260beba89 100644
--- a/llvm/cmake/modules/FindDIASDK.cmake
+++ b/llvm/cmake/modules/FindDIASDK.cmake
@@ -21,7 +21,7 @@ endif()
 if(LLVM_WINSYSROOT)
   set(MSVC_DIA_SDK_DIR "${LLVM_WINSYSROOT}/DIA SDK" CACHE PATH
       "Path to the DIA SDK")
-elseif($ENV{VSINSTALLDIR})
+elseif(DEFINED ENV{VSINSTALLDIR})
   set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK" CACHE PATH
       "Path to the DIA SDK")
 elseif(NOT DEFINED MSVC_DIA_SDK_DIR)



More information about the llvm-commits mailing list