mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-26 11:14:46 +00:00
This handles the case where `COLOR` is set to some ANSI-like color
sequence in the ambient environment. These sequences tend to include `;`
which terminates the command and tries to use the next component
(typically an integer, possibly with a trailing `m`) with errors like:
/bin/sh: line 1: 2: command not found
/bin/sh: line 1: 255: command not found
/bin/sh: line 1: 221: command not found
/bin/sh: line 1: 255m: command not found
Also add a test that sets `COLOR` in the environment which affects the
generated Makefiles behavior.
See: https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277
21 lines
686 B
CMake
21 lines
686 B
CMake
include(RunCMake)
|
|
|
|
unset(ENV{CMAKE_COLOR_DIAGNOSTICS})
|
|
|
|
function(run_Diag case)
|
|
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Diag${case}-build")
|
|
run_cmake_with_options(Diag${case} ${ARGN})
|
|
set(RunCMake_TEST_NO_CLEAN 1)
|
|
run_cmake_command(Diag${case}-build ${CMAKE_COMMAND} --build . --config Debug)
|
|
endfunction()
|
|
|
|
run_Diag(On -DCMAKE_COLOR_DIAGNOSTICS=ON)
|
|
run_Diag(Off -DCMAKE_COLOR_DIAGNOSTICS=OFF)
|
|
run_Diag(Default)
|
|
|
|
# Test with `COLOR` in the ambient environment set to an ANSI-like color
|
|
# sequence. `$(COLOR)` is used in the Makefiles generator to control whether or
|
|
# not to do such color sequences itself.
|
|
set(ENV{COLOR} "[38;2;255;221;255m")
|
|
run_Diag(ColorInEnv)
|