# A quirk for debug symbols on Windows

**URL:** <https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241>\
**Category:** Code\
**Created:** [October 22, 2023, 4:19pm UTC](https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241 "2023-10-22T16:19:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![windymindy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/windymindy/32/3934_2.png) [@windymindy](https://discourse.cmake.org/u/windymindy)\
**Post date:** [October 22, 2023, 4:19pm UTC](https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241/1 "2023-10-22T16:19:16Z")

</div>

Hey.  
So I made this module.  
[https://github.com/windymindy/examples\_cmake/blob/default/main/cmake/fix\_debug\_symbols.cmake](https://github.com/windymindy/examples_cmake/blob/default/main/cmake/fix_debug_symbols.cmake)  
It enumerates all targets in the current directory,  
for static libraries it sets some variables so that the debug symbols are put to the build directory  
(which does not happen by default, they just end up in some subddirectory) and  
for shared or static librares and for executables the module installs them with the target.

I really wanted to install the symbols automatically, but only for targets that are being installed.  
I went with a quick quirk that checks if the contents of the cmake\_install.cmake contains the target name.  
I want to clean this up now.  
[https://github.com/windymindy/examples\_cmake/blob/default/main/cmake/fix\_debug\_symbols.cmake#L104](https://github.com/windymindy/examples_cmake/blob/default/main/cmake/fix_debug_symbols.cmake#L104)

Would someone be so kind to tell:  
Is cmake\_file\_api the best option to find out what is being installed by the project?  
What is the idiomatic way to expand the set of artifacts of the target in general?

Thank you.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [October 22, 2023, 7:09pm UTC](https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241/2 "2023-10-22T19:09:18Z")

</div>

Would [the `PDB_OUTPUT_DIRECTORY` target property](https://cmake.org/cmake/help/latest/prop_tgt/PDB_OUTPUT_DIRECTORY.html) help here?

---

<div class="post-metadata">

**Author:** ![windymindy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/windymindy/32/3934_2.png) [@windymindy](https://discourse.cmake.org/u/windymindy)\
**Post date:** [October 23, 2023, 12:58pm UTC](https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241/3 "2023-10-23T12:58:28Z")

</div>

help with which part?  
Fixing the output location for static libraries is straightforward with  
COMPILE\_PDB\_NAME or COMPILE\_PDB\_OUTPUT\_DIRECTORY.  
That works fine in the link.  
[https://github.com/windymindy/examples\_cmake/blob/default/main/cmake/fix\_debug\_symbols.cmake#L100](https://github.com/windymindy/examples_cmake/blob/default/main/cmake/fix_debug_symbols.cmake#L100)

How would it help with finding out if a target installed or not? So to add symbols to the installation.  
I really do not want to call a separate macro or function for that.  
Want it to be seamless and automatic.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [October 23, 2023, 6:55pm UTC](https://discourse.cmake.org/t/a-quirk-for-debug-symbols-on-windows/9241/4 "2023-10-23T18:55:01Z")

</div>

Oh, I see. I don’t think there’s a way to query `install()` commands that have been made, sorry. It can be [a new feature request](https://gitlab.kitware.com/cmake/cmake/-/issues), but it’d likely have to ultimately be a contribution to expose them in some way.
