From 960e68a976b69124092a76a7a4b0b6cb99ad569e Mon Sep 17 00:00:00 2001 From: Moses Turner Date: Tue, 22 Jun 2021 12:46:55 -0500 Subject: [PATCH] cmake: option for forcing coloured compiler output --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dede9668..74a893632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. ###