CMake Advice?

Dear LLVM developers,

I’m building LLVM with Visual Studio on Windows. My desired configuration is to have NDEBUG defined for a Release build and not defined for a Debug build (within a single solution). LLVM_ENABLE_ASSERTIONS seems to define NDEBUG for both configurations, which results in my project breaking in Release mode if assertions were enabled or Debug mode if they were disabled.

Is there another flag I should tweak? Essentially I’d like the CMake default behavior with regard to NDEBUG in a multi-configuration solution to be left alone.

Many thanks,

Vesa Norilo

If you don’t pass LLVM_ENABLE_ASSERTIONS at all, CMake should implicitly add -DNDEBUG to release only. You can verify this by inspecting the CMakeCache.txt file and looking at the CMAKE_CXX_FLAGS_* variables. In mine I see:

//Flags used by the compiler during all build types.

//Flags used by the compiler during debug builds.

//Flags used by the compiler during release builds for minimum
// size.

//Flags used by the compiler during release builds.

//Flags used by the compiler during release builds with debug info.