summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmDefinitions.h10
-rw-r--r--Source/cmState.cxx4
-rw-r--r--Source/cmStateSnapshot.cxx12
-rw-r--r--Source/cmStateSnapshot.h4
4 files changed, 13 insertions, 17 deletions
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index b6a08bc..4d8810a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -32,16 +32,6 @@ public:
static bool HasKey(const std::string& key, StackIter begin, StackIter end);
- /** Set (or unset if null) a value associated with a key. */
- void Set(const std::string& key, const char* value)
- {
- if (value) {
- this->Set(key, cm::string_view(value));
- } else {
- this->Unset(key);
- }
- }
-
/** Set a value associated with a key. */
void Set(const std::string& key, cm::string_view value);
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 0b12a65..6f9c935 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -308,8 +308,8 @@ cmStateSnapshot cmState::Reset()
pos->Parent = this->VarTree.Root();
pos->Root = this->VarTree.Root();
- pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
- pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
+ pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir);
+ pos->Vars->Set("CMAKE_BINARY_DIR", binDir);
}
this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "",
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 63bec71..110ec56 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -222,14 +222,14 @@ bool cmStateSnapshot::IsInitialized(std::string const& name) const
}
void cmStateSnapshot::SetDefinition(std::string const& name,
- std::string const& value)
+ cm::string_view value)
{
- this->Position->Vars->Set(name, value.c_str());
+ this->Position->Vars->Set(name, value);
}
void cmStateSnapshot::RemoveDefinition(std::string const& name)
{
- this->Position->Vars->Set(name, nullptr);
+ this->Position->Vars->Unset(name);
}
std::vector<std::string> cmStateSnapshot::UnusedKeys() const
@@ -264,7 +264,11 @@ bool cmStateSnapshot::RaiseScope(std::string const& var, const char* varDef)
cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root);
// Now update the definition in the parent scope.
- this->Position->Parent->Set(var, varDef);
+ if (varDef) {
+ this->Position->Parent->Set(var, varDef);
+ } else {
+ this->Position->Parent->Unset(var);
+ }
return true;
}
diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h
index c315f48..da39127 100644
--- a/Source/cmStateSnapshot.h
+++ b/Source/cmStateSnapshot.h
@@ -9,6 +9,8 @@
#include <string>
#include <vector>
+#include "cm_string_view.hxx"
+
#include "cmLinkedTree.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
@@ -24,7 +26,7 @@ public:
std::string const* GetDefinition(std::string const& name) const;
bool IsInitialized(std::string const& name) const;
- void SetDefinition(std::string const& name, std::string const& value);
+ void SetDefinition(std::string const& name, cm::string_view value);
void RemoveDefinition(std::string const& name);
std::vector<std::string> UnusedKeys() const;
std::vector<std::string> ClosureKeys() const;