diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2023-10-19 14:55:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-10-23 13:41:29 (GMT) |
commit | 74b5fae52d24e6fcfacee33441ae9fae2efbfaf7 (patch) | |
tree | 2906c15f6b4336acf4ea75b4949f5866ee7dadf3 | |
parent | dec211da56e19d07503b4a4e8002dc76359dc588 (diff) | |
download | CMake-74b5fae52d24e6fcfacee33441ae9fae2efbfaf7.zip CMake-74b5fae52d24e6fcfacee33441ae9fae2efbfaf7.tar.gz CMake-74b5fae52d24e6fcfacee33441ae9fae2efbfaf7.tar.bz2 |
Clang: Use -fno-ansi-escape-codes for color diagnostics on Windows
-fno-ansi-escape-codes is used only on Windows by Clang.
Without the flag color diagnostics are displayed only if clang.exe
is executed directly. Build tools like ninja and mingw32-make
will not display colored diagnostics.
Using -fno-ansi-escape-codes will make the build tools pass
the colored diagnostics to the calling application e.g IDE.
Fixes: #24235
-rw-r--r-- | Modules/Compiler/Clang.cmake | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index e5683c2..4c033ca 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -117,8 +117,14 @@ else() # '-fcolor-diagnostics' introduced since Clang 2.6 if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2.6) - set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS "-fcolor-diagnostics") - set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF "-fno-color-diagnostics") + # -fansi-escape-codes mentioned at https://releases.llvm.org/3.7.0/tools/clang/docs/UsersManual.html + if (CMAKE_HOST_WIN32 AND CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 3.7) + set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS -fansi-escape-codes -fcolor-diagnostics) + set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF -fno-ansi-escape-codes -fno-color-diagnostics) + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS -fcolor-diagnostics) + set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF -fno-color-diagnostics) + endif() endif() endmacro() endif() |