DavidA
(David Aldrich)
December 17, 2020, 12:12pm
1
I want to add gcc compiler option -Og for Debug builds only.
I have tried:
add_compile_options("$<$<CONFIG:DEBUG>:-Og>")
but that does not seem to work.
I believe target_compile_options is preferred. How would I use that to only affect debug builds?
Angew
(Petr Kmoch)
December 17, 2020, 12:14pm
2
Normally, the configuration name is Debug
, not DEBUG
, so you probably want this:
add_compile_options("$<$<CONFIG:Debug>:-Og>")
hsattler
(Hendrik Sattler)
December 17, 2020, 3:44pm
4
That contradicts the documentation that explicitly states that this comparison is case-insensitive!
DavidA
(David Aldrich)
December 17, 2020, 3:53pm
5
Then I think I must have made some other error. Anyway, it’s working now. Thank you both for your comments. There seem to be several ways of doing some things in CMake and it’s not always easy to know which to use.