Documentation Home
MySQL Internals Manual Debug-Only Options

Sometimes, it is handy to add an option that is active only in Debug builds. When doing this, keep in mind that tests like IF(WITH_DEBUG) or IF(CMAKE_BUILD_TYPE MATCHES "Debug") do not work as expected:

  • First, although WITH_DEBUG is an alias for CMAKE_BUILD_TYPE=Debug, the converse is not true.

  • Second, checking for CMAKE_BUILD_TYPE will not work everywhere. More precisely, it will not work with multi-configuration CMake generators (that is, neither on Windows with Visual Studio nor on Mac OS X with Xcode).

So, when adding debug-only options, consider extending CMAKE_C_FLAGS_DEBUG and CMAKE_CXX_FLAGS_DEBUG. For example:

# Works always

Do not do it like this:

 # Does NOT work with CMAKE_BUILD_TYPE=Debug, Visual Studio or Xcode