From c3bd5a6a2cb0f08d125655967a2f52bdd551ae6b Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Fri, 21 May 2021 07:43:10 -0400 Subject: cmake-gui: Unset empty CC,CXX on global generator change On subsequent runs of configure from cmake-gui the global generator is swapped. So on runs other than the first it was setting CC and CXX to empty when they were otherwise undefined. Instead, restore them if non-empty and unset them if empty when changing the global generator and a previous generator exists. Fixes: #21449 --- Source/cmake.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 315bd20..840a9d9 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 -- cgit v0.12