From b496ea27957133f0294aae89b0906660c055382b Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 25 Jul 2017 10:45:07 +0100 Subject: [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 . --- cmake/find_llvm.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) -- cgit 1.4.1