[llvm] r186499 - Tweak the cmake interaction between CMAKE_BUILD_TYPE and LLVM_ENABLE_ASSERTIONS.
Duncan Sands
baldrick at free.fr
Fri Sep 20 12:44:59 PDT 2013
Hi Richard,
On 20/09/13 04:49, Richard Smith wrote:
> On Wed, Jul 17, 2013 at 2:34 AM, Duncan Sands <baldrick at free.fr
> <mailto:baldrick at free.fr>> wrote:
>
> Author: baldrick
> Date: Wed Jul 17 04:34:51 2013
> New Revision: 186499
>
> URL: http://llvm.org/viewvc/llvm-project?rev=186499&view=rev
> Log:
> Tweak the cmake interaction between CMAKE_BUILD_TYPE and LLVM_ENABLE_ASSERTIONS.
> The issue is that CMAKE_BUILD_TYPE=RelWithDebInfo LLVM_ENABLE_ASSERTIONS=ON was
> not building with assertions enabled. (I was unable to find what in the LLVM
> source tree was adding -DNDEBUG to the build line in this case, so decided that
> it must be cmake itself that was adding it - this may depend on the cmake
> version). The fix treats any mode that is not Debug as being the same as
> Release for this purpose (previously it was being assumed that cmake would only
> add -DNDEBUG for Release and not for RelWithDebInfo or MinSizeRel). If other
> versions of cmake don't add -DNDEBUG for RelWithDebInfo then that's OK: with
> this change you just get a useless but harmless -UNDEBUG or -DNDEBUG.
>
>
> 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?
no, it was a mistake. How about the following? It's not very pretty, but
should do the job.
Ciao, Duncan.
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 190974)
+++ CMakeLists.txt (working copy)
@@ -182,10 +182,10 @@
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
-if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
- option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
-else()
+if( CMAKE_BUILD_TYPE STREQUAL "" OR uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
+else()
+ option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
endif()
option(LLVM_USE_INTEL_JITEVENTS
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake (revision 190974)
+++ cmake/modules/HandleLLVMOptions.cmake (working copy)
@@ -19,7 +19,7 @@
endif()
# On non-Debug builds cmake automatically defines NDEBUG, so we
# explicitly undefine it:
- if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
+ if( NOT CMAKE_BUILD_TYPE STREQUAL "" AND NOT uppercase_CMAKE_BUILD_TYPE
STREQUAL "DEBUG" )
add_definitions( -UNDEBUG )
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
More information about the llvm-commits
mailing list