https://github.com/Kitware/CMake
Revision e8213404cec972ba43b16ec1b49b62f43c9f48b8 authored by Brad King on 11 September 2018, 19:50:14 UTC, committed by Brad King on 11 September 2018, 19:52:43 UTC
In commit v3.9.0-rc1~55^2 (Improve Doxygen support, 2017-04-10)
use of the `IN_LIST` condition was added, but this is only supported
when policy CMP0057 is set to NEW.  Add a policy scope around the
module and enable the policy within it.  Otherwise it works only
in projects that happen to enable the policy.

Fixes: #18361
1 parent f478fa6
Raw File
Tip revision: e8213404cec972ba43b16ec1b49b62f43c9f48b8 authored by Brad King on 11 September 2018, 19:50:14 UTC
FindDoxygen: Ensure policy settings allow use of IN_LIST
Tip revision: e821340
cmCLocaleEnvironmentScope.cxx
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#include "cmCLocaleEnvironmentScope.h"

#include "cmSystemTools.h"

#include <sstream>
#include <utility>

cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
{
  this->SetEnv("LANGUAGE", "");
  this->SetEnv("LC_MESSAGES", "C");

  std::string lcAll = this->GetEnv("LC_ALL");

  if (!lcAll.empty()) {
    this->SetEnv("LC_ALL", "");
    this->SetEnv("LC_CTYPE", lcAll);
  }
}

std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
{
  std::string value;
  cmSystemTools::GetEnv(key, value);
  return value;
}

void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
                                       std::string const& value)
{
  std::string oldValue = this->GetEnv(key);

  this->EnvironmentBackup.insert(std::make_pair(key, oldValue));

  if (value.empty()) {
    cmSystemTools::UnsetEnv(key.c_str());
  } else {
    std::ostringstream tmp;
    tmp << key << "=" << value;
    cmSystemTools::PutEnv(tmp.str());
  }
}

cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
{
  for (auto const& envb : this->EnvironmentBackup) {
    std::ostringstream tmp;
    tmp << envb.first << "=" << envb.second;
    cmSystemTools::PutEnv(tmp.str());
  }
}
back to top