The previous method for including the DIA SDK caused an absolute
path to be included in LLVMDebugInfoPDB's INTERFACE_LINK_LIBRARIES
when the LLVMExports.cmake file was generated.
This is problematic, as the path was machine-specific,
and therefore may not exist, even if the DIA SDK is available.

Index: llvm-project/llvm/lib/DebugInfo/PDB/CMakeLists.txt
===================================================================
--- llvm-project.orig/llvm/lib/DebugInfo/PDB/CMakeLists.txt	2023-10-31 15:14:12.511846472 -0500
+++ llvm-project/llvm/lib/DebugInfo/PDB/CMakeLists.txt	2023-10-31 15:33:18.887437203 -0500
@@ -4,17 +4,7 @@
 endmacro()
 
 if(LLVM_ENABLE_DIA_SDK)
-  include_directories(SYSTEM ${MSVC_DIA_SDK_DIR}/include)
-  set(LIBPDB_LINK_FOLDERS "${MSVC_DIA_SDK_DIR}\\lib")
-
-  if ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64")
-    set(LIBPDB_LINK_FOLDERS "${LIBPDB_LINK_FOLDERS}\\arm64")
-  elseif ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm")
-    set(LIBPDB_LINK_FOLDERS "${LIBPDB_LINK_FOLDERS}\\arm")
-  elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
-    set(LIBPDB_LINK_FOLDERS "${LIBPDB_LINK_FOLDERS}\\amd64")
-  endif()
-  file(TO_CMAKE_PATH "${LIBPDB_LINK_FOLDERS}\\diaguids.lib" LIBPDB_ADDITIONAL_LIBRARIES)
+  include(AddDIA)
 
   add_pdb_impl_folder(DIA
     DIA/DIADataStream.cpp
@@ -153,4 +143,7 @@
   DebugInfoMSF
   )
 
-target_link_libraries(LLVMDebugInfoPDB INTERFACE "${LIBPDB_ADDITIONAL_LIBRARIES}")
+if(LLVM_ENABLE_DIA_SDK)
+  target_link_libraries(LLVMDebugInfoPDB INTERFACE MSVC_diaguids)
+endif()
+
Index: llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in
===================================================================
--- llvm-project.orig/llvm/cmake/modules/LLVMConfig.cmake.in	2023-10-31 15:15:37.491076023 -0500
+++ llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in	2023-10-31 15:33:18.887757077 -0500
@@ -145,6 +145,10 @@
 
 set(LLVM_HAVE_LIBXAR "@LLVM_HAVE_LIBXAR@")
 
+if(LLVM_ENABLE_DIA_SDK)
+  include("${LLVM_CMAKE_DIR}/AddDIA.cmake")
+endif()
+
 if(NOT TARGET LLVMSupport)
   @LLVM_CONFIG_INCLUDE_EXPORTS@
   @llvm_config_include_buildtree_only_exports@
Index: llvm-project/llvm/cmake/modules/AddDIA.cmake
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ llvm-project/llvm/cmake/modules/AddDIA.cmake	2023-10-31 15:33:18.888018159 -0500
@@ -0,0 +1,23 @@
+# Allows LLVMDebugInfoPDB to import the DIA SDK as a library target.
+
+if(NOT MSVC_DIA_SDK_DIR)
+    set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
+endif()
+
+set(MSVC_DIA_SDK_LINK_DIR "${MSVC_DIA_SDK_DIR}\\lib")
+
+if ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64")
+  set(MSVC_DIA_SDK_LINK_DIR "${MSVC_DIA_SDK_LINK_DIR}\\arm64")
+elseif ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm")
+  set(MSVC_DIA_SDK_LINK_DIR "${MSVC_DIA_SDK_LINK_DIR}\\arm")
+elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
+  set(MSVC_DIA_SDK_LINK_DIR "${MSVC_DIA_SDK_LINK_DIR}\\amd64")
+endif()
+
+include_directories("${MSVC_DIA_SDK_DIR}\\include")
+
+add_library(MSVC_diaguids STATIC IMPORTED)
+set_target_properties(MSVC_diaguids PROPERTIES
+    IMPORTED_LOCATION "${MSVC_DIA_SDK_LINK_DIR}\\diaguids.lib"
+)
+
