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.
CMAKE_CXX_FLAGS:STRING=

//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g

//Flags used by the compiler during release builds for minimum
// size.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG

//Flags used by the compiler during release builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG

//Flags used by the compiler during release builds with debug info.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG

-Chris