#ifdef DEBUG with CMake independent from platform April 14, 2023 by Tarik CMake adds -DNDEBUG to the CMAKE_C_FLAGS_{RELEASE, MINSIZEREL} by default. So, you can use #ifndef NDEBUG.