How to enable assert in CMake Release mode?

前端 未结 3 1159
我在风中等你
我在风中等你 2020-12-11 00:55

CMake is being used to compile some C++ files. There are assert calls in the code. These calls are disabled in Release mode of CMake. It defines NDEBUG

3条回答
  •  無奈伤痛
    2020-12-11 01:43

    See this answer in the CMake FAQ, i.e.:

    Fix it manually by changing the definition of the cache variables CMAKE_C_FLAGS_RELEASE and CMAKE_CXX_FLAGS_RELEASE. This has to be done every time you set up a new build directory.

    To fix it permanently, create a custom CMake rules file in your source folder with the desired settings for the release flags (omit the option /D NDEBUG). Then in your outermost CMakeLists.txt point the variable CMAKE_USER_MAKE_RULES_OVERRIDE to the custom CMake rules file.

提交回复
热议问题