diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 315bd20efa..840a9d959c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1751,17 +1751,20 @@ void cmake::SetGlobalGenerator(std::unique_ptr gg) } if (this->GlobalGenerator) { // restore the original environment variables CXX and CC - // Restore CC std::string env = "CC="; if (!this->CCEnvironment.empty()) { env += this->CCEnvironment; + cmSystemTools::PutEnv(env); + } else { + cmSystemTools::UnPutEnv(env); } - cmSystemTools::PutEnv(env); env = "CXX="; if (!this->CXXEnvironment.empty()) { env += this->CXXEnvironment; + cmSystemTools::PutEnv(env); + } else { + cmSystemTools::UnPutEnv(env); } - cmSystemTools::PutEnv(env); } // set the new