diff options
author | Duncan Sands <baldrick@free.fr> | 2013-07-17 09:34:51 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2013-07-17 09:34:51 +0000 |
commit | a009d53c4d97e4b9ffe17cb2f6442a40e7407ac8 (patch) | |
tree | b3031c6ddd9a75493d66adecdb1d55633ed46f4e | |
parent | 77c95b6b95d14202efb6f4c40a2a2280c3d93ae2 (diff) | |
download | external_llvm-a009d53c4d97e4b9ffe17cb2f6442a40e7407ac8.zip external_llvm-a009d53c4d97e4b9ffe17cb2f6442a40e7407ac8.tar.gz external_llvm-a009d53c4d97e4b9ffe17cb2f6442a40e7407ac8.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186499 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/modules/HandleLLVMOptions.cmake | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 895e2f7..631f20e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ endif() option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) -if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) +if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) else() option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 2939fa2..bc6dd0c 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -17,9 +17,9 @@ if( LLVM_ENABLE_ASSERTIONS ) if( NOT MSVC ) add_definitions( -D_DEBUG ) endif() - # On Release builds cmake automatically defines NDEBUG, so we + # On non-Debug builds cmake automatically defines NDEBUG, so we # explicitly undefine it: - if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) + if( 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($| )" " " |