summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-07 20:07:48 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-09-07 20:08:02 (GMT)
commit917d98699e8dd13de89e2993b0b630cf64f17706 (patch)
tree1ad51b87b52747e90ec15698eb613a0afe2a75f8 /Source/cmMakefile.cxx
parent424d86be5b332d2f5b85dfd2ba2900430f7e02c3 (diff)
parent437d0c16c72a45da8c81919f953859f5af71b19b (diff)
downloadCMake-917d98699e8dd13de89e2993b0b630cf64f17706.zip
CMake-917d98699e8dd13de89e2993b0b630cf64f17706.tar.gz
CMake-917d98699e8dd13de89e2993b0b630cf64f17706.tar.bz2
Merge topic 'definitions-get'
437d0c16c7 cmStateSnapshot::GetDefinition(): Return std::string const* Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2356
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 11019d7..5498ad2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2368,8 +2368,10 @@ std::string cmMakefile::GetRequiredDefinition(const std::string& name) const
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
- const char* def = this->StateSnapshot.GetDefinition(name);
- if (!def) {
+ const char* def;
+ if (const std::string* d = this->StateSnapshot.GetDefinition(name)) {
+ def = d->c_str();
+ } else {
def = this->GetState()->GetInitializedCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -2385,8 +2387,10 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
const char* cmMakefile::GetDefinition(const std::string& name) const
{
- const char* def = this->StateSnapshot.GetDefinition(name);
- if (!def) {
+ const char* def;
+ if (const std::string* d = this->StateSnapshot.GetDefinition(name)) {
+ def = d->c_str();
+ } else {
def = this->GetState()->GetInitializedCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -2402,8 +2406,9 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
// A callback was executed and may have caused re-allocation of the
// variable storage. Look it up again for now.
// FIXME: Refactor variable storage to avoid this problem.
- def = this->StateSnapshot.GetDefinition(name);
- if (!def) {
+ if (const std::string* d = this->StateSnapshot.GetDefinition(name)) {
+ def = d->c_str();
+ } else {
def = this->GetState()->GetInitializedCacheValue(name);
}
}