[clang] [Clang][CMake][MSVC] Install PDBs alongside executables (PR #126961)

Miguel A. Arroyo via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 12 11:46:13 PST 2025


https://github.com/mayanez created https://github.com/llvm/llvm-project/pull/126961

Fixes the changes introduced in https://github.com/llvm/llvm-project/pull/126675 and subsequently reverted by https://github.com/llvm/llvm-project/pull/126934 .

Originally, I mistakenly put the `install` in the wrong location (should have been in the `add_clang_tool` macro) which slipped through testing. I've verified locally using the same CMake configure options. 


For reference:
* **CMake Configure**
```
 cmake -B build -S llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;lld;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PDB=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl
```
* **Error**
```
TARGET_PDB_FILE is allowed only for targets with linker created artifacts.
```

>From f316b100c21d3eea3d60945deef10c93ac4097e3 Mon Sep 17 00:00:00 2001
From: Miguel Arroyo <Miguel.Arroyo at rockstargames.com>
Date: Wed, 12 Feb 2025 11:35:10 -0800
Subject: [PATCH] [Clang][CMake][MSVC] Install PDBs alongside executables

---
 clang/cmake/modules/AddClang.cmake | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index cdc8bd5cd503b..4059fc3e986c7 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -186,6 +186,10 @@ macro(add_clang_tool name)
         RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
         COMPONENT ${name})
 
+      if (LLVM_ENABLE_PDB)
+        install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL)
+      endif()
+
       if(NOT LLVM_ENABLE_IDE)
         add_llvm_install_targets(install-${name}
                                  DEPENDS ${name}



More information about the cfe-commits mailing list