Skip to content

Commit 39b3767

Browse files
committed
Add debug symbols to Release builds
By default, CMake Release builds are built without debug symbols. The idea is that you use RelWithDebInfo if you want them. However, RelWithDebInfo generates less optimized code, only inlining __inline code. More specifically, RelWithDebInfo builds use the /Ob1 option, and Release builds use /Ob2 [1,2]. In the end, we want to use Release for production code, but we also need debug symbols for post-mortem analysis. [1] conan-io/conan-center-index#1982 (comment) [2] https://gitlab.kitware.com/cmake/cmake/-/blob/d7741457861816d50114801abc84d1d78afdc754/Modules/Platform/Windows-MSVC.cmake#L486-490
1 parent 4c36544 commit 39b3767

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ else()
100100
endif()
101101

102102

103+
# Always build Release with debug symbols as well
104+
if(MSVC)
105+
add_compile_options("$<$<CONFIG:Release>:/Zi>")
106+
add_link_options("$<$<CONFIG:Release>:/DEBUG>")
107+
else()
108+
add_compile_options("$<$<CONFIG:Release>:-g>")
109+
endif()
110+
111+
103112
add_subdirectory(lass)
104113
if(TARGET Lass::lass_python)
105114
add_subdirectory(pylass)

0 commit comments

Comments
 (0)