-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=”-O3 -g”

CMAKE BUILD TYPES AND HOW TO SPECIFY COMPILERS AND COMPILER FLAGS

CMake has a CMAKE_BUILD_TYPE option for predefined build types. The build type affects optimization and whether the result of the build is debuggable. Those used by MySQL are RelWithDebInfo or Debug.
RelWithDebInfo (optimizations are on, debug info is generated) is used in MySQL by default.
Debug (optimizations are off, debug info is generated) is used if the WITH_DEBUG option is set.

CMAKE_BUILD_TYPE is not set when custom compile flags are used

To define which C and C++ compilers to use, you can define the CC and CXX environment variables. For example:

To specify your own C and C++ compiler flags, for flags that do not affect optimization, use the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS CMake options:

When providing your own compiler flags, you might want to specify CMAKE_BUILD_TYPE as well.
For example, to create a 32-bit release build on a 64-bit Linux machine, do this:

If you set flags that affect optimization (-Onumber), you must set the CMAKE_C_FLAGS_build_type and/or CMAKE_CXX_FLAGS_build_type options, where build_type  corresponds to the CMAKE_BUILD_TYPE value.

To specify a different optimization for the default build type (RelWithDebInfo) set the CMAKE_C_FLAGS_RELWITHDEBINFO and CMAKE_CXX_FLAGS_RELWITHDEBINFO options.
For example, to compile on Linux with -O3 and with debug symbols, do this: