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

CMake: Force GCC/Clang color diagnostics for Ninja (#1596) #1597

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ if(APPLE)
endif()
endif()

# Forces GCC/Clang compilers to enable color diagnostics if using Ninja.
if(CMAKE_GENERATOR STREQUAL "Ninja")
maxrdz marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_COLOR_DIAGNOSTICS ON)

# CMake versions 3.24 and below do not support this option, so we have
# to invoke the color diagnostics flags manually.
if(CMAKE_VERSION VERSION_LESS "3.24.0")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
endif()

# Figure out the version
set(_s "[\\t ]*") # CMake doesn't support \s*
file(STRINGS "setup.cfg" _version REGEX "^version${_s}=${_s}")
Expand Down