Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable assert in CMake Release mode?

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 in Release mode, I guess.

If I'm interested in having assert in Release mode of CMake, how do I enable it?

like image 576
Ashwin Nanjappa Avatar asked Mar 03 '14 06:03

Ashwin Nanjappa


1 Answers

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.

like image 140
sakra Avatar answered Oct 12 '22 01:10

sakra