mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-08 23:44:00 +03: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:
1 parent
723a83d8cd
commit
aa5711490f
1 file changed
+8
@@ -24,6 +24,14 @@
|
||||
namespace {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user