diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2020-02-02 10:49:03 -0800 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2020-02-02 13:19:23 -0800 |
commit | 9b84dabc5f36f7e027c62b5c00ea97e21cfcacdd (patch) | |
tree | 82da310aaa28321304d3c390d52600e496be833e | |
parent | 34cd354ea967a6aecee4133fe43e4879355c6dbe (diff) | |
download | llvm-9b84dabc5f36f7e027c62b5c00ea97e21cfcacdd.zip llvm-9b84dabc5f36f7e027c62b5c00ea97e21cfcacdd.tar.gz llvm-9b84dabc5f36f7e027c62b5c00ea97e21cfcacdd.tar.bz2 |
build: only pass -UNDEBUG when compiling C/C++
This patch limits adding -UNDEBUG to C and C++ files so that projects
can include files compiled with compilers that don't recognize this
argument (Swift e.g.).
add_definitions does not expand generators, hence the change from
add_definitions to add_compile_options.
Patch by Evan Wilde!
-rw-r--r-- | llvm/cmake/modules/HandleLLVMOptions.cmake | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index d519a7e..0942bb9 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -57,7 +57,10 @@ if( LLVM_ENABLE_ASSERTIONS ) # On non-Debug builds cmake automatically defines NDEBUG, so we # explicitly undefine it: if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) - add_definitions( -UNDEBUG ) + # NOTE: use `add_compile_options` rather than `add_definitions` since + # `add_definitions` does not support generator expressions. + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-UNDEBUG>) + # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines. foreach (flags_var_to_scrub CMAKE_CXX_FLAGS_RELEASE |