diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2020-09-20 10:50:44 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2020-09-20 10:51:21 +0200 |
commit | 0459cbaf3eaf2b123a07d125623db0fc82baa6aa (patch) | |
tree | ce05f87f7b7fe4d9605f92e1f0a6e4e11f3bc4d4 | |
parent | fb4f389731cf5a26a0a13e4d31bbbb61724989e7 (diff) | |
download | tde-cmake-0459cbaf3eaf2b123a07d125623db0fc82baa6aa.tar.gz tde-cmake-0459cbaf3eaf2b123a07d125623db0fc82baa6aa.zip |
Add a global option to force colored output from compiler.
Taken from https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | modules/TDEMacros.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 471a206..80cd4c5 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -41,6 +41,19 @@ if( NOT TDE_CMAKE_ROOT ) CACHE FILEPATH "TDE CMake templates" ) endif() + + + option( FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE ) + if( ${FORCE_COLORED_OUTPUT} ) + if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + if( NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9" ) + add_compile_options (-fdiagnostics-color=always) + endif() + elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + add_compile_options (-fcolor-diagnostics) + endif() + endif() + endif() |