[Cmake-commits] CMake branch, next, updated. v3.7.0-rc2-683-g4df5915

Brad King brad.king at kitware.com
Mon Oct 24 10:00:01 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  4df5915b50c57b3f028cb3fb7555c42384bd34e8 (commit)
       via  1a74e719068c97518d6f9521c86862a17166f32e (commit)
      from  50c3bb901aad305cb7bfa1971d0ee1aeac226389 (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=4df5915b50c57b3f028cb3fb7555c42384bd34e8
commit 4df5915b50c57b3f028cb3fb7555c42384bd34e8
Merge: 50c3bb9 1a74e71
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 24 10:00:00 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Oct 24 10:00:00 2016 -0400

    Merge topic 'cm_unordered_map' into next
    
    1a74e719 Introduce CM_UNORDERED_MAP


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a74e719068c97518d6f9521c86862a17166f32e
commit 1a74e719068c97518d6f9521c86862a17166f32e
Author:     Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Fri Oct 21 23:52:51 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 24 09:58:52 2016 -0400

    Introduce CM_UNORDERED_MAP
    
    Avoid duplicating switch among std::unordered_map, cmsys::hash_map, and
    std::map.

diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 569b3a2..8dfb9ea 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -6,20 +6,11 @@
 #include <cmConfigure.h>
 
 #include "cmLinkedTree.h"
+#include "cm_unordered_map.hxx"
 
 #include <string>
 #include <vector>
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include "cmsys/hash_map.hxx"
-#endif
-#else
-#include <map>
-#endif
-
 /** \class cmDefinitions
  * \brief Store a scope of variable definitions for CMake language.
  *
@@ -85,15 +76,7 @@ private:
   };
   static Def NoDef;
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-  typedef std::unordered_map<std::string, Def> MapType;
-#else
-  typedef cmsys::hash_map<std::string, Def> MapType;
-#endif
-#else
-  typedef std::map<std::string, Def> MapType;
-#endif
+  typedef CM_UNORDERED_MAP<std::string, Def> MapType;
   MapType Map;
 
   static Def const& GetInternal(const std::string& key, StackIter begin,
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index a6c9cd0..55d8c2a 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -7,14 +7,7 @@
 #include <time.h>
 #include <utility>
 
-// Use a hash table to avoid duplicate file time checks from disk.
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <cmsys/hash_map.hxx>
-#endif
-#endif
+#include "cm_unordered_map.hxx"
 
 // Use a platform-specific API to get file times efficiently.
 #if !defined(_WIN32) || defined(__CYGWIN__)
@@ -35,27 +28,9 @@ public:
   bool FileTimesDiffer(const char* f1, const char* f2);
 
 private:
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-  // Use a hash table to efficiently map from file name to modification time.
-  class HashString
-  {
-  public:
-    size_t operator()(const std::string& s) const { return h(s.c_str()); }
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-    std::hash<const char*> h;
-#else
-    cmsys::hash<const char*> h;
-#endif
-  };
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-  typedef std::unordered_map<std::string,
-#else
-  typedef cmsys::hash_map<std::string,
-#endif
-                             cmFileTimeComparison_Type, HashString>
+  typedef CM_UNORDERED_MAP<std::string, cmFileTimeComparison_Type>
     FileStatsMap;
   FileStatsMap Files;
-#endif
 
   // Internal methods to lookup and compare modification times.
   inline bool Stat(const char* fname, cmFileTimeComparison_Type* st);
@@ -68,7 +43,6 @@ private:
 bool cmFileTimeComparisonInternal::Stat(const char* fname,
                                         cmFileTimeComparison_Type* st)
 {
-#if defined(CMAKE_BUILD_WITH_CMAKE)
   // Use the stored time if available.
   cmFileTimeComparisonInternal::FileStatsMap::iterator fit =
     this->Files.find(fname);
@@ -76,7 +50,6 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
     *st = fit->second;
     return true;
   }
-#endif
 
 #if !defined(_WIN32) || defined(__CYGWIN__)
   // POSIX version.  Use the stat function.
@@ -97,11 +70,8 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
   *st = fdata.ftLastWriteTime;
 #endif
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
   // Store the time for future use.
   this->Files[fname] = *st;
-#endif
-
   return true;
 }
 
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index d8d47a1..4bf4bd1 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -12,6 +12,7 @@
 #include "cmTarget.h"
 #include "cmTargetDepend.h"
 #include "cm_codecvt.hxx"
+#include "cm_unordered_map.hxx"
 
 #include <iosfwd>
 #include <map>
@@ -22,11 +23,6 @@
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cmFileLockPool.h"
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <cmsys/hash_map.hxx>
-#endif
 #endif
 
 class cmCustomCommandLines;
@@ -468,22 +464,9 @@ protected:
   const char* GetPredefinedTargetsFolder();
 
 private:
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-  typedef std::unordered_map<std::string, cmTarget*> TargetMap;
-  typedef std::unordered_map<std::string, cmGeneratorTarget*>
-    GeneratorTargetMap;
-  typedef std::unordered_map<std::string, cmMakefile*> MakefileMap;
-#else
-  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
-  typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
-  typedef cmsys::hash_map<std::string, cmMakefile*> MakefileMap;
-#endif
-#else
-  typedef std::map<std::string, cmTarget*> TargetMap;
-  typedef std::map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
-  typedef std::map<std::string, cmMakefile*> MakefileMap;
-#endif
+  typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap;
+  typedef CM_UNORDERED_MAP<std::string, cmGeneratorTarget*> GeneratorTargetMap;
+  typedef CM_UNORDERED_MAP<std::string, cmMakefile*> MakefileMap;
   // Map efficiently from target name to cmTarget instance.
   // Do not use this structure for looping over all targets.
   // It contains both normal and globally visible imported targets.
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index b61e81b..3067f2c 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -12,6 +12,7 @@
 #include "cmStateSnapshot.h"
 #include "cmTarget.h"
 #include "cmTargetLinkLibraryType.h"
+#include "cm_unordered_map.hxx"
 #include "cmake.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -27,14 +28,6 @@
 #include <string>
 #include <vector>
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <cmsys/hash_map.hxx>
-#endif
-#endif
-
 class cmCommand;
 class cmCompiledGeneratorExpression;
 class cmCustomCommandLines;
@@ -783,15 +776,6 @@ protected:
 
   // libraries, classes, and executables
   mutable cmTargets Targets;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-  typedef std::unordered_map<std::string, cmTarget*> TargetMap;
-#else
-  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
-#endif
-#else
-  typedef std::map<std::string, cmTarget*> TargetMap;
-#endif
   std::map<std::string, std::string> AliasTargets;
   std::vector<cmSourceFile*> SourceFiles;
 
@@ -863,6 +847,7 @@ private:
   friend class cmParseFileScope;
 
   std::vector<cmTarget*> ImportedTargetsOwned;
+  typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap;
   TargetMap ImportedTargets;
 
   // Internal policy stack management.
@@ -899,16 +884,8 @@ private:
    */
   cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const;
 
-// A map for fast output to input look up.
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-  typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap;
-#else
-  typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap;
-#endif
-#else
-  typedef std::map<std::string, cmSourceFile*> OutputToSourceMap;
-#endif
+  // A map for fast output to input look up.
+  typedef CM_UNORDERED_MAP<std::string, cmSourceFile*> OutputToSourceMap;
   OutputToSourceMap OutputToSource;
 
   void UpdateOutputToSourceMap(std::vector<std::string> const& outputs,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 929e204..1f035a1 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -12,6 +12,7 @@
 #include "cmPropertyMap.h"
 #include "cmStateTypes.h"
 #include "cmTargetLinkLibraryType.h"
+#include "cm_unordered_map.hxx"
 
 #include <iosfwd>
 #include <map>
@@ -20,14 +21,6 @@
 #include <utility>
 #include <vector>
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <cmsys/hash_map.hxx>
-#endif
-#endif
-
 class cmMakefile;
 class cmSourceFile;
 class cmGlobalGenerator;
@@ -324,15 +317,7 @@ private:
   cmListFileBacktrace Backtrace;
 };
 
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-typedef std::unordered_map<std::string, cmTarget> cmTargets;
-#else
-typedef cmsys::hash_map<std::string, cmTarget> cmTargets;
-#endif
-#else
-typedef std::map<std::string, cmTarget> cmTargets;
-#endif
+typedef CM_UNORDERED_MAP<std::string, cmTarget> cmTargets;
 
 class cmTargetSet : public std::set<std::string>
 {
diff --git a/Source/cm_unordered_map.hxx b/Source/cm_unordered_map.hxx
new file mode 100644
index 0000000..dc8ca35
--- /dev/null
+++ b/Source/cm_unordered_map.hxx
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#ifndef CM_UNORDERED_MAP_HXX
+#define CM_UNORDERED_MAP_HXX
+
+#include <cmConfigure.h>
+
+#if defined(CMake_HAVE_CXX_UNORDERED_MAP)
+
+#include <unordered_map>
+#define CM_UNORDERED_MAP std::unordered_map
+
+#elif defined(CMAKE_BUILD_WITH_CMAKE)
+
+#include <cmsys/hash_map.hxx>
+#define CM_UNORDERED_MAP cmsys::hash_map
+
+#else
+
+#include <map>
+#define CM_UNORDERED_MAP std::map
+
+#endif
+
+#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 388984f..44b76ef 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -27,6 +27,7 @@
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cmGraphVizWriter.h"
 #include "cmVariableWatch.h"
+#include "cm_unordered_map.hxx"
 
 #include <cm_jsoncpp_writer.h>
 #endif
@@ -122,11 +123,7 @@ class cmCommand;
 namespace {
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-typedef std::unordered_map<std::string, Json::Value> JsonValueMapType;
-#else
-typedef cmsys::hash_map<std::string, Json::Value> JsonValueMapType;
-#endif
+typedef CM_UNORDERED_MAP<std::string, Json::Value> JsonValueMapType;
 #endif
 
 } // namespace

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list