Skip to content

Commit

Permalink
Add debug symbols to Release builds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bdegreve committed Nov 8, 2023
1 parent 4c36544 commit 39b3767
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ else()
endif()


# Always build Release with debug symbols as well
if(MSVC)
add_compile_options("$<$<CONFIG:Release>:/Zi>")
add_link_options("$<$<CONFIG:Release>:/DEBUG>")
else()
add_compile_options("$<$<CONFIG:Release>:-g>")
endif()


add_subdirectory(lass)
if(TARGET Lass::lass_python)
add_subdirectory(pylass)
Expand Down

0 comments on commit 39b3767

Please sign in to comment.