From 326d15a3294e3b43de534130a4b655ddb454fbfb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 27 May 2014 16:03:51 -0400 Subject: cmake: Tolerate missing HELPSTRING on compiler change Teach cmake::HandleDeleteCacheVariables to tolerate a missing HELPSTRING (NULL pointer) when saving cache entries. In the absence of other bugs this should not be possible, but avoid the crash just in case. --- Source/cmake.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index abbabe7..4f14d73 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1231,7 +1231,10 @@ int cmake::HandleDeleteCacheVariables(const char* var) if(ci.Find(save.key.c_str())) { save.type = ci.GetType(); - save.help = ci.GetProperty("HELPSTRING"); + if(const char* help = ci.GetProperty("HELPSTRING")) + { + save.help = help; + } } saved.push_back(save); } -- cgit v0.12 From 1cd375272997cb58f0c51647cf199e4fd4eef678 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 27 May 2014 16:09:43 -0400 Subject: cmCacheManager: Avoid cache entry self-assignment Since commit bef93dc5 (Couple of changes: cache variables now have a map of properties, 2002-09-11) the cmCacheManager::AddCacheDefinition method accesses its map entry by reference. However, the commit left the original entry assignment at the end of the method. With Apple Clang 5.1 and libc++ this self-assignment destroys the cache entry property map. Drop the self assignment. Also drop the condition around the call to UnwatchUnusedCli since it was a self-comparison that must always have been true. --- Source/cmCacheManager.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 9e0064e..cc9fa57 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -750,11 +750,7 @@ void cmCacheManager::AddCacheEntry(const char* key, } e.SetProperty("HELPSTRING", helpString? helpString : "(This variable does not exist and should not be used)"); - if (this->Cache[key].Value == e.Value) - { - this->CMakeInstance->UnwatchUnusedCli(key); - } - this->Cache[key] = e; + this->CMakeInstance->UnwatchUnusedCli(key); } bool cmCacheManager::CacheIterator::IsAtEnd() const -- cgit v0.12