Does CMAKE_BUILD_TYPE=Release imply -DNDEBUG?

后端 未结 1 1421
面向向阳花
面向向阳花 2021-01-01 09:49

Does CMAKE_BUILD_TYPE=Release implicitly imply -DNDEBUG?

If not: isn\'t it reasonable to expect that this implication takes place?

I want to

相关标签:
1条回答
  • 2021-01-01 10:08

    Yes, it is set by CMake. Grepping through the CMake code reveals, that for a host of compilers it is set. Probably they set it only for these compilers, which accepts this flag. Here one of the lines concerning GCC:

    Modules/Compiler/GNU.cmake:  set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
    

    But be aware that many projects overwrite release/debug flags without preserving the initial setting and also overwriting user's definitions.

    0 讨论(0)
提交回复
热议问题