How to override optimization level flag in modern

2019-06-14 11:56发布

问题:

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.

标签: cmake