cmake: option for forcing coloured compiler output

This commit is contained in:
Moses Turner 2021-06-22 12:46:55 -05:00 committed by Jakob Bornecrantz
parent 140e4a04b5
commit 960e68a976

View file

@ -322,6 +322,17 @@ if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
message(STATUS "Inter-procedural optimization enabled")
endif()
# Make sure we have pretty colours
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if ("${FORCE_COLORED_OUTPUT}")
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 ()
###
# Decend into madness.
###