mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
set: Explicitly unset empty environment variables on Windows
KWSys's SystemTools::PutEnv implementation, on Windows, has long interpreted `A=` as unset. This differs from the behavior on other platforms. Code the distinction explicitly in `set(ENV{VAR})`. Issue: #27285
This commit is contained in:
@@ -24,6 +24,14 @@
|
|||||||
namespace {
|
namespace {
|
||||||
void setENV(std::string const& var, cm::string_view val)
|
void setENV(std::string const& var, cm::string_view val)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (val.empty()) {
|
||||||
|
// FIXME(#27285): On Windows, PutEnv previously treated empty as unset.
|
||||||
|
// KWSys was fixed, but we need to retain the behavior for compatibility.
|
||||||
|
cmSystemTools::UnPutEnv(var);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
cmSystemTools::PutEnv(cmStrCat(var, '=', val));
|
cmSystemTools::PutEnv(cmStrCat(var, '=', val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user