diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index f3e3d1f182..9fe39514e9 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -67,6 +67,8 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # executables. This may lead to issues when their stderr output (which # contains the relevant compiler internals) becomes interweaved. string(REGEX REPLACE "(^| )-pipe( |$)" " " ${v} "${${v}}") + # Suppress any formatting of warnings and/or errors + string(REGEX REPLACE "(-f|/)diagnostics(-|:)color(=[a-z]+)?" "" ${v} "${${v}}") endforeach() # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/CheckCompilerLinkerId.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/CheckCompilerLinkerId.cmake new file mode 100644 index 0000000000..a6a56ca96c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/CheckCompilerLinkerId.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +if(NOT CMAKE_C_COMPILER_LINKER OR NOT CMAKE_C_COMPILER_LINKER_ID) + message(FATAL_ERROR "Failed to determine Linker.") +endif() diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake index d50d403f1e..df03f15845 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake @@ -39,3 +39,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows|AIX|SunOS)$|BSD" ) endif() endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES Clang) + run_cmake_with_options(CheckCompilerLinkerId "-DCMAKE_C_FLAGS=-fdiagnostics-color=always") +endif()