remove_definitions("NDEBUG") doesn't seem to remove the macro from the build.

I’m in a CMake hierarchy where at its root, someone has put in


So, I’m trying to remove it without affecting the other projects. I figured putting remove_definitions("NDEBUG") into my CMakeLists.txt file would do it, but on running cmake . at the root of the repo, it doesn’t change my build of the VS project.

Temporarily removing the add_compile_definitions from the root CMakeLists.txt file does remove this definition from my project but also prolly adds it back to all of the other projects which is not what I want, for fear of breaking soemthing.

Does anyone know why this would be?

There is a difference in syntax between the newer command add_compile_definitions() and the older, pretty much legacy commands add_definitions() and remove_definitions(). The latter ones require the -D (or /D) prefix when referring to macros.

So the correct code to remove the flag is:

1 Like

OH THANK YOU! That was driving me crazy! This really should be put in the documentation!