How to override optimization level flag in modern CMake

Viewed 1315

What's the recommended way of overriding optimization level flags (-O2, -O3 etc. and the MSVC-counterparts with /)?

target_compile_options(mytarget PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:/Od>")

This results in the compiler output:

cl : Command line warning D9025 : overriding '/O2' with '/Od'

I am happy to use the latest CMake, 3.13.2.

0 Answers
Related