[PATCH] D73830: Only pass -UNDEBUG when compiling C/C++

Evan Wilde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 1 02:43:55 PST 2020


etcwilde created this revision.
etcwilde added reviewers: compnerd, beanz, chandlerc.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73830

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -57,7 +57,7 @@
   # On non-Debug builds cmake automatically defines NDEBUG, so we
   # explicitly undefine it:
   if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
-    add_definitions( -UNDEBUG )
+    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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73830.241871.patch
Type: text/x-patch
Size: 625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200201/bba3ef12/attachment.bin>


More information about the llvm-commits mailing list