[Cmake-commits] CMake branch, next, updated. v3.6.0-895-gcc5a78a
Brad King
brad.king at kitware.com
Mon Jul 18 09:59:24 EDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via cc5a78ab201574ac6557f2973f279fbe0dc93397 (commit)
via b1f87a50b3aee129d420b8d789ebec55068e4ec5 (commit)
from 75164f2a170ebf250e3012c2a764902f5c78bb32 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc5a78ab201574ac6557f2973f279fbe0dc93397
commit cc5a78ab201574ac6557f2973f279fbe0dc93397
Merge: 75164f2 b1f87a5
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Jul 18 09:59:22 2016 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jul 18 09:59:22 2016 -0400
Merge topic 'use-better-KWSys-GetEnv' into next
b1f87a50 Use better KWSys SystemTools::GetEnv and HasEnv signatures
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b1f87a50b3aee129d420b8d789ebec55068e4ec5
commit b1f87a50b3aee129d420b8d789ebec55068e4ec5
Author: Dāvis Mosāns <davispuh at gmail.com>
AuthorDate: Fri Jul 8 00:54:05 2016 +0300
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Jul 18 09:51:01 2016 -0400
Use better KWSys SystemTools::GetEnv and HasEnv signatures
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index df8bb0f..76609e1 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -1074,11 +1074,11 @@ const char* cmCPackGenerator::GetInstallPath()
return this->InstallPath.c_str();
}
#if defined(_WIN32) && !defined(__CYGWIN__)
- const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles");
- const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive");
- if (prgfiles) {
+ std::string prgfiles;
+ std::string sysDrive;
+ if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) {
this->InstallPath = prgfiles;
- } else if (sysDrive) {
+ } else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) {
this->InstallPath = sysDrive;
this->InstallPath += "/Program Files";
} else {
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 7102533..3f37f2a 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -727,10 +727,8 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
// if it doesn't exist or is empty, assume the
// binary directory is used.
std::string coverageXMLFile;
- const char* covDir = cmSystemTools::GetEnv("COBERTURADIR");
- if (covDir && strlen(covDir) != 0) {
- coverageXMLFile = std::string(covDir);
- } else {
+ if (!cmSystemTools::GetEnv("COBERTURADIR", coverageXMLFile) ||
+ coverageXMLFile.empty()) {
coverageXMLFile = this->CTest->GetBinaryDir();
}
// build the find file string with the directory from above
@@ -791,7 +789,8 @@ struct cmCTestCoverageHandlerLocale
{
cmCTestCoverageHandlerLocale()
{
- if (const char* l = cmSystemTools::GetEnv("LC_ALL")) {
+ std::string l;
+ if (cmSystemTools::GetEnv("LC_ALL", l)) {
lc_all = l;
}
if (lc_all != "C") {
@@ -2121,8 +2120,8 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
int cmCTestCoverageHandler::HandleBullseyeCoverage(
cmCTestCoverageHandlerContainer* cont)
{
- const char* covfile = cmSystemTools::GetEnv("COVFILE");
- if (!covfile || strlen(covfile) == 0) {
+ std::string covfile;
+ if (!cmSystemTools::GetEnv("COVFILE", covfile) || covfile.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" COVFILE environment variable not found, not running "
" bullseye\n",
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 6b8e5b5..b335e32 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -219,16 +219,18 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
void cmCTestCurl::SetProxyType()
{
- if (cmSystemTools::GetEnv("HTTP_PROXY")) {
- this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
- if (cmSystemTools::GetEnv("HTTP_PROXY_PORT")) {
+ this->HTTPProxy = "";
+ // this is the default
+ this->HTTPProxyType = CURLPROXY_HTTP;
+ this->HTTPProxyAuth = "";
+ if (cmSystemTools::GetEnv("HTTP_PROXY", this->HTTPProxy)) {
+ std::string port;
+ if (cmSystemTools::GetEnv("HTTP_PROXY_PORT", port)) {
this->HTTPProxy += ":";
- this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
+ this->HTTPProxy += port;
}
- if (cmSystemTools::GetEnv("HTTP_PROXY_TYPE")) {
- // this is the default
- this->HTTPProxyType = CURLPROXY_HTTP;
- std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE");
+ std::string type;
+ if (cmSystemTools::GetEnv("HTTP_PROXY_TYPE", type)) {
// HTTP/SOCKS4/SOCKS5
if (type == "HTTP") {
this->HTTPProxyType = CURLPROXY_HTTP;
@@ -238,12 +240,11 @@ void cmCTestCurl::SetProxyType()
this->HTTPProxyType = CURLPROXY_SOCKS5;
}
}
- if (cmSystemTools::GetEnv("HTTP_PROXY_USER")) {
- this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER");
- }
- if (cmSystemTools::GetEnv("HTTP_PROXY_PASSWD")) {
+ cmSystemTools::GetEnv("HTTP_PROXY_USER", this->HTTPProxyAuth);
+ std::string passwd;
+ if (cmSystemTools::GetEnv("HTTP_PROXY_PASSWD", passwd)) {
this->HTTPProxyAuth += ":";
- this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD");
+ this->HTTPProxyAuth += passwd;
}
}
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index ae97d32..a4e0b95 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -261,12 +261,14 @@ void cmCTestMultiProcessHandler::StartNextTests()
allTestsFailedTestLoadCheck = true;
// Check for a fake load average value used in testing.
- if (const char* fake_load_value =
- cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING")) {
+ std::string fake_load_value;
+ if (cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING",
+ fake_load_value)) {
usedFakeLoadForTesting = true;
- if (!cmSystemTools::StringToULong(fake_load_value, &systemLoad)) {
+ if (!cmSystemTools::StringToULong(fake_load_value.c_str(),
+ &systemLoad)) {
cmSystemTools::Error("Failed to parse fake load value: ",
- fake_load_value);
+ fake_load_value.c_str());
}
}
// If it's not set, look up the true load average.
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index fb143a2..9830867 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -36,8 +36,8 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
const char* variable = args[0].c_str();
// Parse remaining arguments.
- const char* configuration = CM_NULLPTR;
- const char* project_name = CM_NULLPTR;
+ std::string configuration;
+ std::string project_name;
std::string target;
enum Doing
{
@@ -56,10 +56,10 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
doing = DoingTarget;
} else if (doing == DoingConfiguration) {
doing = DoingNone;
- configuration = args[i].c_str();
+ configuration = args[i];
} else if (doing == DoingProjectName) {
doing = DoingNone;
- project_name = args[i].c_str();
+ project_name = args[i];
} else if (doing == DoingTarget) {
doing = DoingNone;
target = args[i];
@@ -76,14 +76,14 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
// so we put this code here to end up with the same default configuration
// as the original 2-arg build_command signature:
//
- if (!configuration || !*configuration) {
- configuration = getenv("CMAKE_CONFIG_TYPE");
+ if (configuration.empty()) {
+ cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configuration);
}
- if (!configuration || !*configuration) {
+ if (configuration.empty()) {
configuration = "Release";
}
- if (project_name && *project_name) {
+ if (!project_name.empty()) {
this->Makefile->IssueMessage(
cmake::AUTHOR_WARNING,
"Ignoring PROJECT_NAME option because it has no effect.");
@@ -91,7 +91,8 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
std::string makecommand =
this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
+ target, configuration.c_str(), "",
+ this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->AddDefinition(variable, makecommand.c_str());
@@ -108,10 +109,10 @@ bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
const char* define = args[0].c_str();
const char* cacheValue = this->Makefile->GetDefinition(define);
- std::string configType = "Release";
- const char* cfg = getenv("CMAKE_CONFIG_TYPE");
- if (cfg && *cfg) {
- configType = cfg;
+ std::string configType;
+ if (!cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configType) ||
+ configType.empty()) {
+ configType = "Release";
}
std::string makecommand =
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
index a19dbae..e4c74ec 100644
--- a/Source/cmCLocaleEnvironmentScope.cxx
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -31,8 +31,9 @@ cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
{
- const char* value = cmSystemTools::GetEnv(key);
- return value ? value : std::string();
+ std::string value;
+ cmSystemTools::GetEnv(key, value);
+ return value;
}
void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 3bb997a..0101049 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -298,9 +298,10 @@ cmCTest::cmCTest()
this->ComputedCompressMemCheckOutput = false;
this->RepeatTests = 1; // default to run each test once
this->RepeatUntilFail = false;
- if (const char* outOnFail =
- cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) {
- this->OutputTestOutputOnTestFailure = !cmSystemTools::IsOff(outOnFail);
+ std::string outOnFail;
+ if (cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE", outOnFail)) {
+ this->OutputTestOutputOnTestFailure =
+ !cmSystemTools::IsOff(outOnFail.c_str());
}
this->InitStreams();
@@ -2091,8 +2092,9 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// handle CTEST_PARALLEL_LEVEL environment variable
if (!this->ParallelLevelSetInCli) {
- if (const char* parallel = cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL")) {
- int plevel = atoi(parallel);
+ std::string parallel;
+ if (cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL", parallel)) {
+ int plevel = atoi(parallel.c_str());
this->SetParallelLevel(plevel);
}
}
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 294117c..42fb105 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -71,12 +71,12 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
return this->EmptyVariable;
}
if (strcmp(key, "ENV") == 0) {
- char* ptr = getenv(var);
- if (ptr) {
+ std::string str;
+ if (cmSystemTools::GetEnv(var, str)) {
if (this->EscapeQuotes) {
- return this->AddString(cmSystemTools::EscapeQuotes(ptr));
+ return this->AddString(cmSystemTools::EscapeQuotes(str.c_str()));
} else {
- return ptr;
+ return this->AddString(str);
}
}
return this->EmptyVariable;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 67b2571..e02221c 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -486,7 +486,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
argP1->GetValue().operator[](argP1len - 1) == '}') {
std::string env = argP1->GetValue().substr(4, argP1len - 5);
- bdef = cmSystemTools::GetEnv(env.c_str()) ? true : false;
+ bdef = cmSystemTools::HasEnv(env.c_str());
} else {
bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
}
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 3cb575e..fc62492 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -327,11 +327,10 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
fname += "/cmake/packages/";
fname += package;
#else
- const char* home = cmSystemTools::GetEnv("HOME");
- if (!home) {
+ std::string fname;
+ if (!cmSystemTools::GetEnv("HOME", fname)) {
return;
}
- std::string fname = home;
cmSystemTools::ConvertToUnixSlashes(fname);
fname += "/.cmake/packages/";
fname += package;
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 16cb082..93c55cc 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -208,7 +208,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
// get the variables from the environment and from the cache and then
// figure out which one to use:
- const char* envVarValue = getenv(envVar);
+ std::string envVarValue;
+ const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue);
std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
cacheEntryName += envVar;
@@ -217,17 +218,17 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
// now we have both, decide which one to use
std::string valueToUse;
- if (envVarValue == CM_NULLPTR && cacheValue == CM_NULLPTR) {
+ if (!envVarSet && cacheValue == CM_NULLPTR) {
// nothing known, do nothing
valueToUse = "";
- } else if (envVarValue != CM_NULLPTR && cacheValue == CM_NULLPTR) {
+ } else if (envVarSet && cacheValue == CM_NULLPTR) {
// The variable is in the env, but not in the cache. Use it and put it
// in the cache
valueToUse = envVarValue;
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmState::STRING, true);
mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
- } else if (envVarValue == CM_NULLPTR && cacheValue != CM_NULLPTR) {
+ } else if (!envVarSet && cacheValue != CM_NULLPTR) {
// It is already in the cache, but not in the env, so use it from the cache
valueToUse = cacheValue;
} else {
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 5a1238b..835b118 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -1609,8 +1609,10 @@ struct cmFileInstaller : public cmFileCopier
// Installation does not use source permissions by default.
this->UseSourcePermissions = false;
// Check whether to copy files always or only if they have changed.
- this->Always =
- cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS"));
+ std::string install_always;
+ if (cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS", install_always)) {
+ this->Always = cmSystemTools::IsOn(install_always.c_str());
+ }
// Get the current manifest.
this->Manifest =
this->Makefile->GetSafeDefinition("CMAKE_INSTALL_MANIFEST_FILES");
@@ -1869,9 +1871,8 @@ bool cmFileInstaller::HandleInstallDestination()
return false;
}
- const char* destdir = cmSystemTools::GetEnv("DESTDIR");
- if (destdir && *destdir) {
- std::string sdestdir = destdir;
+ std::string sdestdir;
+ if (cmSystemTools::GetEnv("DESTDIR", sdestdir) && !sdestdir.empty()) {
cmSystemTools::ConvertToUnixSlashes(sdestdir);
char ch1 = destination[0];
char ch2 = destination[1];
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index d5fd75d..260079b 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1077,8 +1077,8 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
this->LabeledPaths[PathLabel::UserRegistry]);
}
#else
- if (const char* home = cmSystemTools::GetEnv("HOME")) {
- std::string dir = home;
+ std::string dir;
+ if (cmSystemTools::GetEnv("HOME", dir)) {
dir += "/.cmake/packages/";
dir += this->Name;
this->LoadPackageRegistryDir(dir,
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 262909f..0a83b3a 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -122,9 +122,9 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(
// does not use the environment it is run in, and this allows
// for running commands and using dll's that the IDE environment
// does not know about.
- const char* extraPath = cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH");
- if (extraPath) {
- mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath,
+ std::string extraPath;
+ if (cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH", extraPath)) {
+ mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath.c_str(),
"Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
cmState::STATIC);
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0d550dd..ab7de57 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2572,6 +2572,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
std::string const& lookup = result.substr(var.loc);
const char* value = CM_NULLPTR;
std::string varresult;
+ std::string svalue;
static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
switch (var.domain) {
case NORMAL:
@@ -2584,7 +2585,9 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
}
break;
case ENVIRONMENT:
- value = cmSystemTools::GetEnv(lookup.c_str());
+ if (cmSystemTools::GetEnv(lookup, svalue)) {
+ value = svalue.c_str();
+ }
break;
case CACHE:
value = state->GetCacheEntryValue(lookup);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 1d3e608..855a243 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -741,5 +741,5 @@ bool cmNinjaTargetGenerator::ForceResponseFile()
{
static std::string const forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
return (this->GetMakefile()->IsDefinitionSet(forceRspFile) ||
- cmSystemTools::GetEnv(forceRspFile) != CM_NULLPTR);
+ cmSystemTools::HasEnv(forceRspFile));
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 4b40c08..b821fda 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -88,7 +88,7 @@ static std::string extractSubDir(const std::string& absPath,
}
cmQtAutoGenerators::cmQtAutoGenerators()
- : Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != CM_NULLPTR)
+ : Verbose(cmsys::SystemTools::HasEnv("VERBOSE"))
, ColorOutput(true)
, RunMocFailed(false)
, RunUicFailed(false)
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 1484368..8fb6aa0 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -31,13 +31,14 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
putEnvArg += "=";
// what is the current value if any
- const char* currValue = getenv(varName);
+ std::string currValue;
+ const bool currValueSet = cmSystemTools::GetEnv(varName, currValue);
delete[] varName;
// will it be set to something, then set it
if (args.size() > 1 && !args[1].empty()) {
// but only if it is different from current value
- if (!currValue || strcmp(currValue, args[1].c_str())) {
+ if (!currValueSet || currValue != args[1]) {
putEnvArg += args[1];
cmSystemTools::PutEnv(putEnvArg);
}
@@ -45,7 +46,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
}
// if it will be cleared, then clear it if it isn't already clear
- if (currValue) {
+ if (currValueSet) {
cmSystemTools::PutEnv(putEnvArg);
}
return true;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index f2fe134..0470508 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -1286,8 +1286,9 @@ void cmState::Snapshot::SetDefaultDefinitions()
this->SetDefinition("CMAKE_HOST_UNIX", "1");
#endif
#if defined(__CYGWIN__)
- if (cmSystemTools::IsOn(
- cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) {
+ std::string legacy;
+ if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) &&
+ cmSystemTools::IsOn(legacy.c_str())) {
this->SetDefinition("WIN32", "1");
this->SetDefinition("CMAKE_HOST_WIN32", "1");
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 2d463f3..9740ef7 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2069,9 +2069,9 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message,
// However, we can test for some situations when the answer is most
// likely no.
int assumeTTY = cmsysTerminal_Color_AssumeTTY;
- if (cmSystemTools::GetEnv("DART_TEST_FROM_DART") ||
- cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") ||
- cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE")) {
+ if (cmSystemTools::HasEnv("DART_TEST_FROM_DART") ||
+ cmSystemTools::HasEnv("DASHBOARD_TEST_FROM_CTEST") ||
+ cmSystemTools::HasEnv("CTEST_INTERACTIVE_DEBUG_MODE")) {
// Avoid printing color escapes during dashboard builds.
assumeTTY = 0;
}
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index c3c1d17..61b74db 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -93,10 +93,9 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
#else
// From Linux timegm() manpage.
- std::string tz_old = "TZ=";
- if (const char* tz = cmSystemTools::GetEnv("TZ")) {
- tz_old += tz;
- }
+ std::string tz_old = "";
+ cmSystemTools::GetEnv("TZ", tz_old);
+ tz_old = "TZ=" + tz_old;
// The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
// It seems that "TZ=" does NOT work, at least under Windows
diff --git a/Source/cmUtils.hxx b/Source/cmUtils.hxx
new file mode 100644
index 0000000..b7a79cc
--- /dev/null
+++ b/Source/cmUtils.hxx
@@ -0,0 +1,26 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2016 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmUtils_hxx
+#define cmUtils_hxx
+
+#include <cmsys/SystemTools.hxx>
+
+// Use the make system's VERBOSE environment variable to enable
+// verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE
+// (which is set by the Eclipse and KDevelop generators).
+inline bool isCMakeVerbose()
+{
+ return (cmSystemTools::HasEnv("VERBOSE") &&
+ !cmSystemTools::HasEnv("CMAKE_NO_VERBOSE"));
+}
+
+#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index fceec16..cdc1284 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -22,6 +22,7 @@
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmTest.h"
+#include "cmUtils.hxx"
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmGraphVizWriter.h"
@@ -957,16 +958,10 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator* gg)
cmSystemTools::SetForceUnixPaths(this->GlobalGenerator->GetForceUnixPaths());
// Save the environment variables CXX and CC
- const char* cxx = getenv("CXX");
- const char* cc = getenv("CC");
- if (cxx) {
- this->CXXEnvironment = cxx;
- } else {
+ if (!cmSystemTools::GetEnv("CXX", this->CXXEnvironment)) {
this->CXXEnvironment = "";
}
- if (cc) {
- this->CCEnvironment = cc;
- } else {
+ if (!cmSystemTools::GetEnv("CC", this->CCEnvironment)) {
this->CCEnvironment = "";
}
}
@@ -1431,7 +1426,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
// should fail (if "-i" is an option). We cannot simply test
// whether "-i" is given and remove it because some make programs
// encode the MAKEFLAGS variable in a strange way.
- if (getenv("MAKEFLAGS")) {
+ if (cmSystemTools::HasEnv("MAKEFLAGS")) {
cmSystemTools::PutEnv("MAKEFLAGS=");
}
@@ -1706,12 +1701,8 @@ void cmake::UpdateConversionPathTable()
int cmake::CheckBuildSystem()
{
- // We do not need to rerun CMake. Check dependency integrity. Use
- // the make system's VERBOSE environment variable to enable verbose
- // output. This can be skipped by setting CMAKE_NO_VERBOSE (which is set
- // by the Eclipse and KDevelop generators).
- bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != CM_NULLPTR) &&
- (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == CM_NULLPTR));
+ // We do not need to rerun CMake. Check dependency integrity.
+ const bool verbose = isCMakeVerbose();
// This method will check the integrity of the build system if the
// option was given on the command line. It reads the given file to
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index feb330c..9d0337a 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -16,6 +16,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmQtAutoGenerators.h"
+#include "cmUtils.hxx"
#include "cmVersion.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -673,12 +674,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Internal CMake dependency scanning support.
else if (args[1] == "cmake_depends" && args.size() >= 6) {
- // Use the make system's VERBOSE environment variable to enable
- // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE
- // (which is set by the Eclipse and KDevelop generators).
- bool verbose =
- ((cmSystemTools::GetEnv("VERBOSE") != CM_NULLPTR) &&
- (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == CM_NULLPTR));
+ const bool verbose = isCMakeVerbose();
// Create a cmake object instance to process dependencies.
cmake cm;
@@ -876,9 +872,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// 1/10th of a second after the untar. If CMAKE_UNTAR_DELAY
// is set in the env, its value will be used instead of 100.
int delay = 100;
- const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY");
- if (delayVar) {
- delay = atoi(delayVar);
+ std::string delayVar;
+ if (cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY", delayVar)) {
+ delay = atoi(delayVar.c_str());
}
if (delay) {
cmSystemTools::Delay(delay);
@@ -1230,7 +1226,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
if (args.size() < 2) {
return -1;
}
- bool verbose = cmSystemTools::GetEnv("VERBOSE") != CM_NULLPTR;
+ const bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::vector<std::string> expandedArgs;
for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
++i) {
-----------------------------------------------------------------------
Summary of changes:
Source/CPack/cmCPackGenerator.cxx | 8 ++++----
Source/CTest/cmCTestCoverageHandler.cxx | 13 ++++++-------
Source/CTest/cmCTestCurl.cxx | 27 ++++++++++++++-------------
Source/CTest/cmCTestMultiProcessHandler.cxx | 10 ++++++----
Source/cmBuildCommand.cxx | 27 ++++++++++++++-------------
Source/cmCLocaleEnvironmentScope.cxx | 5 +++--
Source/cmCTest.cxx | 12 +++++++-----
Source/cmCommandArgumentParserHelper.cxx | 8 ++++----
Source/cmConditionEvaluator.cxx | 2 +-
Source/cmExportCommand.cxx | 5 ++---
Source/cmExtraEclipseCDT4Generator.cxx | 9 +++++----
Source/cmFileCommand.cxx | 11 ++++++-----
Source/cmFindPackageCommand.cxx | 4 ++--
Source/cmGlobalVisualStudio7Generator.cxx | 6 +++---
Source/cmMakefile.cxx | 5 ++++-
Source/cmNinjaTargetGenerator.cxx | 2 +-
Source/cmQtAutoGenerators.cxx | 2 +-
Source/cmSetCommand.cxx | 7 ++++---
Source/cmState.cxx | 5 +++--
Source/cmSystemTools.cxx | 6 +++---
Source/cmTimestamp.cxx | 7 +++----
Tests/QtAutogen/abc.h => Source/cmUtils.hxx | 24 +++++++++++-------------
Source/cmake.cxx | 21 ++++++---------------
Source/cmcmd.cxx | 16 ++++++----------
24 files changed, 119 insertions(+), 123 deletions(-)
copy Tests/QtAutogen/abc.h => Source/cmUtils.hxx (52%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list