<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>IMHO we should make an unspecified CMAKE_BUILD_TYPE just default to Debug+Asserts (this would also increase consistency with the Makefile build).</div><div><br></div>I ran into a similar issue yesterday, I was wondering why an assert wouldn’t trigger. Looking at the disassembly I realized that the code for the assert was actually not there even though I was building with CMAKE_BUILD_TYPE=Debug. How could that happen?<div><br></div><div>Turns out when I did the initial configure of my build directory I forgot to set CMAKE_BUILD_TYPE, so once I realized I couldn’t debug my binary I did a CMAKE_BUILD_TYPE=Debug. After that debugging works fine again, however asserts are still turned off!<br><div><br></div><div>Regards,</div><div><br></div><div>Tilmann</div><div><br><div><div>On Sep 20, 2013, at 4:49 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">On Wed, Jul 17, 2013 at 2:34 AM, Duncan Sands<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span><span class="Apple-converted-space"> </span>wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: baldrick<br>Date: Wed Jul 17 04:34:51 2013<br>New Revision: 186499<br><br>URL:<span class="Apple-converted-space"> </span><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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Modified:<br>   <span class="Apple-converted-space"> </span>llvm/trunk/CMakeLists.txt<br>   <span class="Apple-converted-space"> </span>llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br><br>Modified: llvm/trunk/CMakeLists.txt<br>URL:<span class="Apple-converted-space"> </span><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:<span class="Apple-converted-space"> </span><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>_______________________________________________<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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></div></body></html>