[PATCH] Add colored diagnostics when building LLVM with cmake + ninja + clang

Reid Kleckner rnk at google.com
Wed May 29 12:48:09 PDT 2013


LGTM!

I'd been meaning to toss that into CMAKE_CXX_FLAGS locally, but I never
actually got around to it.  Might as well do it globally so everyone
benefits.

--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -266,3 +266,10 @@ endif()
 add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
 add_llvm_definitions( -D__STDC_FORMAT_MACROS )
 add_llvm_definitions( -D__STDC_LIMIT_MACROS )
+# clang doesn't print colored diagnostics when invoked from Ninja
+if(UNIX)
+  if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_GENERATOR STREQUAL
"Ninja")

if (UNIX AND ...) ?  Looks like it needs wrapping too.

+    append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+  endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_GENERATOR
STREQUAL "Ninja")

Most endif's in this file don't duplicate the condition, so I'd drop it.

+endif(UNIX)



On Tue, May 28, 2013 at 5:17 AM, Arnaud A. de Grandmaison <
arnaud.adegm at gmail.com> wrote:

> When invoked from Ninja, clang does not detect that it can use colors : see
> https://github.com/martine/ninja/issues/174
>
> This patch forces colored diagnostics when building LLVM with cmake +
> ninja +
> clang on UNIX (in CMake parlance) platforms only as I have not been able to
> test it on Windows.
>
> I am wondering though if it could not break interactive tools relying on
> the
> compilation database, like Emacs or Vim, if they are not able to parse the
> color sequences. This does not seem to break clang_complete,and most tools
> are
> probably filtering the compilation command line anyway.
>
> Thoughts ? OK to apply ?
>
> Cheers,
> --
> Arnaud A. de Grandmaison
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130529/55838cc9/attachment.html>


More information about the llvm-commits mailing list