[Cmake-commits] CMake branch, next, updated. v3.2.2-2939-gad7afbe

Stephen Kelly steveire at gmail.com
Mon May 18 18:07:24 EDT 2015


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  ad7afbeca3d8140568f671ec488105a4ff07feb2 (commit)
       via  d7923b82ade9f84d0fc4c6d44b9719f2f7c0e9af (commit)
      from  52db3de85d7df7a71d3348363a64a0c0406c1c14 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad7afbeca3d8140568f671ec488105a4ff07feb2
commit ad7afbeca3d8140568f671ec488105a4ff07feb2
Merge: 52db3de d7923b8
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon May 18 18:07:23 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon May 18 18:07:23 2015 -0400

    Merge topic 'use-std-unordered_map' into next
    
    d7923b82 Use std::unordered_map instead of hash_map where available.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7923b82ade9f84d0fc4c6d44b9719f2f7c0e9af
commit d7923b82ade9f84d0fc4c6d44b9719f2f7c0e9af
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat May 16 06:57:53 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 19 00:07:02 2015 +0200

    Use std::unordered_map instead of hash_map where available.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19d83f1..5a75666 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
     set(CMAKE_CXX_STANDARD 11)
   endif()
 endif()
+include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx11_unordered_map.cmake)
 
 # option to set the internal encoding of CMake to UTF-8
 option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally." ON)
diff --git a/Source/Checks/cm_cxx11_unordered_map.cmake b/Source/Checks/cm_cxx11_unordered_map.cmake
new file mode 100644
index 0000000..80fe391
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cmake
@@ -0,0 +1,25 @@
+
+if(CMAKE_CXX_STANDARD AND NOT DEFINED CMake_HAVE_CXX11_UNORDERED_MAP)
+  message(STATUS "Checking if compiler supports C++11 unordered_map")
+  try_compile(CMake_HAVE_CXX11_UNORDERED_MAP
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${CMAKE_CURRENT_LIST_DIR}/cm_cxx11_unordered_map.cpp
+    CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
+    OUTPUT_VARIABLE OUTPUT
+    )
+  if(CMake_HAVE_CXX11_UNORDERED_MAP)
+    message(STATUS "Checking if compiler supports C++11 unordered_map - yes")
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "Determining if compiler supports C++11 unordered_map passed with the following output:\n"
+      "${OUTPUT}\n"
+      "\n"
+      )
+  else()
+    message(STATUS "Checking if compiler supports C++11 unordered_map - no")
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+      "Determining if compiler supports C++11 unordered_map failed with the following output:\n"
+      "${OUTPUT}\n"
+      "\n"
+      )
+  endif()
+endif()
diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp
new file mode 100644
index 0000000..beeb31b
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cpp
@@ -0,0 +1,6 @@
+#include <unordered_map>
+int main() {
+  std::unordered_map<int, int> map;
+  map[0] = 0;
+  return 0;
+}
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index c0a1aa9..62128a7 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -14,4 +14,5 @@
 #cmakedefine CMAKE_USE_ELF_PARSER
 #cmakedefine CMAKE_USE_MACH_PARSER
 #cmakedefine CMAKE_ENCODING_UTF8
+#cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP
 #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index b244793..245a0bd 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -14,8 +14,12 @@
 
 #include "cmStandardIncludes.h"
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
 #include "cmsys/hash_map.hxx"
 #endif
+#endif
 
 #include <list>
 
@@ -65,9 +69,12 @@ private:
   };
   static Def NoDef;
 
-  // Local definitions, set or unset.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_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
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 5727470..13e2a66 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -13,8 +13,12 @@
 
 // Use a hash table to avoid duplicate file time checks from disk.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
 # include <cmsys/hash_map.hxx>
 #endif
+#endif
 
 #include <cmsys/Encoding.hxx>
 
@@ -47,9 +51,17 @@ private:
       {
       return h(s.c_str());
       }
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+    std::hash<const char*> h;
+#else
     cmsys::hash<const char*> h;
+#endif
     };
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+  typedef std::unordered_map<std::string,
+#else
   typedef cmsys::hash_map<std::string,
+#endif
                           cmFileTimeComparison_Type, HashString> FileStatsMap;
   FileStatsMap Files;
 #endif
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 3b2a41f..c4c98ea 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -24,7 +24,11 @@
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 # include "cmFileLockPool.h"
-# include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#  include <unordered_map>
+# else
+#  include <cmsys/hash_map.hxx>
+# endif
 #endif
 
 class cmake;
@@ -429,7 +433,11 @@ protected:
 
   // All targets in the entire project.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_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
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index e0eef6f..8271cc2 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -31,7 +31,11 @@
 #include <cmsys/auto_ptr.hxx>
 #include <cmsys/RegularExpression.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#  include <unordered_map>
+# else
+#  include <cmsys/hash_map.hxx>
+# endif
 #endif
 
 #include <stack>
@@ -868,7 +872,11 @@ protected:
   // libraries, classes, and executables
   mutable cmTargets Targets;
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_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
@@ -1041,7 +1049,11 @@ private:
 
   // A map for fast output to input look up.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_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
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a032414..f43c87c 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -19,7 +19,11 @@
 
 #include <cmsys/auto_ptr.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#  include <unordered_map>
+# else
+#  include <cmsys/hash_map.hxx>
+# endif
 #endif
 
 #define CM_FOR_EACH_TARGET_POLICY(F) \
@@ -849,7 +853,11 @@ private:
 };
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-typedef cmsys::hash_map<std::string,cmTarget> cmTargets;
+#ifdef CMake_HAVE_CXX11_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

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list