Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake option for colored gcc >= 4.9 output #378

Merged
merged 3 commits into from Jun 14, 2016

Conversation

@jakobj
Copy link
Contributor

jakobj commented May 31, 2016

This PR adds and option for cmake that enables colored output of errors and warnings. works fine with gcc >= 4.9. Is is maybe necessary to prevent this from being set when using an incompatible compiler? If so, whats the best way to do this? I propose @tammoippen and @apeyser as reviewers.

# add colored output from gcc
if ( with-color )
if ( with-color STREQUAL "ON" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto" )

This comment has been minimized.

Copy link
@tammoippen

tammoippen Jun 1, 2016

Contributor

This is a GCC specific option, that is only fully supported for GCC >= 4.9. Older versions might choke:

g++-4.8 -fdiagnostics-color=auto -Wall -pedantic -c ...
g++-4.8: error: unrecognized command line option '-fdiagnostics-color=auto'

I would recommend to not have this as a user option, but always enable it, if possible (colors are cool and useful during coding), e.g. like this:

if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
  if ( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto" )
  endif ()
endif ()

And also do not forget to add the option for the C compiler (the checks are similar):

set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto" )
cmake now checks the compiler id and version and enables colored output
of warnings and errors if the compiler allows is (gcc >= 4.9). added flag also to cflags.
@jakobj
Copy link
Contributor Author

jakobj commented Jun 3, 2016

included @tammoippen's suggestions. thanks!

@tammoippen
Copy link
Contributor

tammoippen commented Jun 9, 2016

👍 from my side.

@heplesser
Copy link
Contributor

heplesser commented Jun 10, 2016

@jakobj Would you merge the latest changes from master, so that Travis can test properly, now that #391 is merged?

@heplesser
Copy link
Contributor

heplesser commented Jun 14, 2016

👍 and merging!

@heplesser heplesser merged commit a541cc3 into nest:master Jun 14, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jakobj jakobj deleted the jakobj:colored_gcc_output branch Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.