diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index ba63484d8c0a..a846eaeb2a46 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -58,13 +58,22 @@ endif( MSVC ) option(LLVM_ENABLE_THREADS "Use threads if available." ON) if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) - option(LLVM_ENABLE_ASSERTS "Enable asserts" OFF) + option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) else() - option(LLVM_ENABLE_ASSERTS "Enable asserts" ON) + option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() -if( LLVM_ENABLE_ASSERTS ) - add_definitions( -D_DEBUG -UNDEBUG ) +if( LLVM_ENABLE_ASSERTIONS ) + add_definitions( -D_DEBUG ) + # On Release builds cmake automatically defines NDEBUG, so we + # explicitly undefine it: + if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) + add_definitions( -UNDEBUG ) + endif() +else() + if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) + add_definitions( -DNDEBUG ) + endif() endif() if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) diff --git a/llvm/docs/CMake.html b/llvm/docs/CMake.html index b329ca46d62e..ac3b57a84893 100644 --- a/llvm/docs/CMake.html +++ b/llvm/docs/CMake.html @@ -248,8 +248,8 @@
LLVM_ENABLE_THREADS:BOOL
Build with threads support, if available. Defaults to ON.
-
LLVM_ENABLE_ASSERTS:BOOL
-
Enables code asserts. Defaults to ON if and only if +
LLVM_ENABLE_ASSERTIONS:BOOL
+
Enables code assertions. Defaults to ON if and only if CMAKE_BUILD_TYPE is Release.
LLVM_ENABLE_PIC:BOOL