From 4d2423ff81c8192bb81b090ccaac37e96e00968a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Thor=C3=A9n?= Date: Tue, 2 Jan 2024 01:52:57 +0100 Subject: [PATCH] Add 'ENABLE_COLORIZED_COMPILER_OUTPUT' CMake option for Clang/GNU. This makes it so that compiler output is colorized for better readability. I am not sure if this has performance implications w.r.t console print speed --- hence default is set to 'off'. --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32e78e58d..3e47dff13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,16 @@ option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON) option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON) option(ENABLE_STATIC_AI_LIBS "Add AI code into VCMI lib directly" ${staticAI}) +option(ENABLE_COLORIZED_COMPILER_OUTPUT "Colorize compilation output (Clang/GNU)." OFF) + +if(${ENABLE_COLORIZED_COMPILER_OUTPUT}) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options(-fcolor-diagnostics) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options(-fdiagnostics-color=always) + endif() +endif() + # Used for Snap packages and also useful for debugging if(NOT APPLE_IOS AND NOT ANDROID) option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)