CMake: Renamed LLVM_ENABLE_ASSERTS to
authorOscar Fuentes <ofv@wanadoo.es>
Thu, 4 Jun 2009 09:26:16 +0000 (09:26 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Thu, 4 Jun 2009 09:26:16 +0000 (09:26 +0000)
LLVM_ENABLE_ASSERTIONS. Fine-tuned the logic that controls the
definition of NDEBUG and _DEBUG macros.

Thanks to Jay Foad for this suggestions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72864 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
docs/CMake.html

index ba63484d8c0a2561c01471dc47d082cbae7edcc3..a846eaeb2a4695f3d29fac57714c21a414bbcbb9 100644 (file)
@@ -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" )
index b329ca46d62e626d4665cb0fdaf868612497e350..ac3b57a84893cc1ebb591eba253f84ab9b0d230c 100644 (file)
   <dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt>
   <dd>Build with threads support, if available. Defaults to ON.</dd>
 
-  <dt><b>LLVM_ENABLE_ASSERTS</b>:BOOL</dt>
-  <dd>Enables code asserts. Defaults to ON if and only if
+  <dt><b>LLVM_ENABLE_ASSERTIONS</b>:BOOL</dt>
+  <dd>Enables code assertions. Defaults to ON if and only if
     CMAKE_BUILD_TYPE is <i>Release</i>.</dd>
 
   <dt><b>LLVM_ENABLE_PIC</b>:BOOL</dt>