On Wed, Oct 28, 2015 at 11:20 AM, Robert Dailey <rcdailey.li...@gmail.com> wrote: > On Wed, Oct 28, 2015 at 11:19 AM, Robert Dailey > <rcdailey.li...@gmail.com> wrote: >> On Wed, Oct 28, 2015 at 9:03 AM, Miller Henry <millerhe...@johndeere.com> >> wrote: >>> >>> 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 >> >> Unfortunately your solution doesn't seem to work. I get the following output: >> >> [1/1] Re-running CMake... >> -- Performing Test COMPILER_SUPPORTS_fcolor-diagnostics >> -- Performing Test COMPILER_SUPPORTS_fcolor-diagnostics - Failed >> >> GCC 4.9 supports this I thought? > > I found the issue, the flag is diagnostics-color, not color-diagnostics.
Actually, even after getting this working, I still get no color 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