[CMake] Colored diagnostic output for GCC 4.9 through Ninja
Miller Henry
MillerHenry at JohnDeere.com
Wed Oct 28 10:03:32 EDT 2015
I do something like this, which works for clang and should work for gcc 4.9 though I haven't tested it. I haven't wrote the right way to do this which is to check if the terminal supports color before passing the flag in. I don't know what will happen on our e.g. CI system which doesn't support color.
macro(AddCXXFlagIfSupported flag test)
CHECK_CXX_COMPILER_FLAG(${flag} ${test})
if( ${${test}} )
message("adding ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
endif()
endmacro()
if("Ninja" STREQUAL ${CMAKE_GENERATOR})
AddCXXFlagIfSupported(-fcolor-diagnostics COMPILER_SUPPORTS_fcolor-diagnostics)
endif()
P.s. AddCXXFlagIfSupported ought to be in the default cmake distribution along with a lot or similar things
-----Original Message-----
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Robert Dailey
Sent: Wednesday, October 28, 2015 8:43 AM
To: CMake
Subject: [CMake] Colored diagnostic output for GCC 4.9 through Ninja
I'm using CMake + Ninja against GCC 4.9 in the Android NDK. I'm on Windows, invoking 'ninja' through CMD.exe.
I do not see colored output for diagnostics (errors, warnings, etc) GCC gives. Is there something in CMake I need to configure to enable colored output?
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
More information about the CMake
mailing list