diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ec0fdb777f..47af08a1d2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3238,6 +3238,14 @@ int cmMakefile::TryCompile(std::string const& srcdir, return 1; } + // unset the NINJA_STATUS environment variable while running try compile. + // since we parse the output, we need to ensure there aren't any unexpected + // characters that will cause issues, such as ANSI color escape codes. + cm::optional maybeNinjaStatus; + if (this->GetGlobalGenerator()->IsNinja()) { + maybeNinjaStatus.emplace("NINJA_STATUS="); + } + // make sure the same generator is used // use this program as the cmake to be run, it should not // be run that way but the cmake object requires a valid path