<div dir="ltr">On Wed, Jul 17, 2013 at 2:34 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: baldrick<br>
Date: Wed Jul 17 04:34:51 2013<br>
New Revision: 186499<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=186499&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=186499&view=rev</a><br>
Log:<br>
Tweak the cmake interaction between CMAKE_BUILD_TYPE and LLVM_ENABLE_ASSERTIONS.<br>
The issue is that CMAKE_BUILD_TYPE=RelWithDebInfo LLVM_ENABLE_ASSERTIONS=ON was<br>
not building with assertions enabled.  (I was unable to find what in the LLVM<br>
source tree was adding -DNDEBUG to the build line in this case, so decided that<br>
it must be cmake itself that was adding it - this may depend on the cmake<br>
version).  The fix treats any mode that is not Debug as being the same as<br>
Release for this purpose (previously it was being assumed that cmake would only<br>
add -DNDEBUG for Release and not for RelWithDebInfo or MinSizeRel).  If other<br>
versions of cmake don't add -DNDEBUG for RelWithDebInfo then that's OK: with<br>
this change you just get a useless but harmless -UNDEBUG or -DNDEBUG.<br></blockquote><div><br></div><div>I believe this change broke my build setup. Previously a default cmake setup (with no CMAKE_BUILD_TYPE set) would build with no debug, no optimization, and assertions enabled (a pretty good default setup for development). Now we get no assertions in that setup. Was that deliberate?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Modified:<br>
    llvm/trunk/CMakeLists.txt<br>
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br>
<br>
Modified: llvm/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=186499&r1=186498&r2=186499&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=186499&r1=186498&r2=186499&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/CMakeLists.txt (original)<br>
+++ llvm/trunk/CMakeLists.txt Wed Jul 17 04:34:51 2013<br>
@@ -153,7 +153,7 @@ endif()<br>
 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)<br>
 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)<br>
<br>
-if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )<br>
+if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )<br>
   option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)<br>
 else()<br>
   option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)<br>
<br>
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=186499&r1=186498&r2=186499&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=186499&r1=186498&r2=186499&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)<br>
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Jul 17 04:34:51 2013<br>
@@ -17,9 +17,9 @@ if( LLVM_ENABLE_ASSERTIONS )<br>
   if( NOT MSVC )<br>
     add_definitions( -D_DEBUG )<br>
   endif()<br>
-  # On Release builds cmake automatically defines NDEBUG, so we<br>
+  # On non-Debug builds cmake automatically defines NDEBUG, so we<br>
   # explicitly undefine it:<br>
-  if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )<br>
+  if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )<br>
     add_definitions( -UNDEBUG )<br>
     # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.<br>
     string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>