about summary refs log tree commit diff homepage
path: root/cmake
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2017-07-25 10:45:07 +0100
committerDan Liew <daniel.liew@imperial.ac.uk>2017-07-25 10:45:07 +0100
commitb496ea27957133f0294aae89b0906660c055382b (patch)
treedcbfe1f26f722abdc5e763a50d9dbd9d516af22c /cmake
parentc06cc05adc7eac45ff16d7e488576d479811d7a8 (diff)
downloadklee-b496ea27957133f0294aae89b0906660c055382b.tar.gz
[CMake] Fix bug where we would inherit LLVM's `-DNDEBUG` define
when LLVM was built without assertions. This prevented
`ENABLE_KLEE_ASSERTS` from working correctly.

Reported by @MartinNowack .
Diffstat (limited to 'cmake')
-rw-r--r--cmake/find_llvm.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/find_llvm.cmake b/cmake/find_llvm.cmake
index 770fca84..49ca51d4 100644
--- a/cmake/find_llvm.cmake
+++ b/cmake/find_llvm.cmake
@@ -227,3 +227,16 @@ else()
     set(${OUTPUT_VAR} ${targets_to_return} PARENT_SCOPE)
   endfunction()
 endif()
+
+# Filter out `-DNEBUG` from LLVM_DEFINITIONS.  The caller can use
+# `LLVM_ENABLE_ASSERTIONS` to decide how to set their defines.
+set(_new_llvm_definitions "")
+foreach (llvm_define ${LLVM_DEFINITIONS})
+  if ("${llvm_define}" STREQUAL "-DNDEBUG")
+    # Skip
+  else()
+    list(APPEND _new_llvm_definitions "${llvm_define}")
+  endif()
+endforeach()
+set(LLVM_DEFINITIONS "${_new_llvm_definitions}")
+unset(_new_llvm_definitions)