From ecf89d5e14aa995b4f314066426e50ca15ed4e15 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 5 Jul 2020 15:59:54 +0200 Subject: [PATCH] Add option to always produce colored output --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index af20343..63eb6bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,15 @@ endif() set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "CMake Configuration Types" FORCE) +option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE) +if(${FORCE_COLORED_OUTPUT}) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + add_compile_options(-fdiagnostics-color=always) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + add_compile_options(-fcolor-diagnostics) + endif() +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)