[Cmake-commits] CMake branch, next, updated. v3.2.2-2785-gb19b7dd

Stephen Kelly steveire at gmail.com
Sat May 16 00:58:19 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  b19b7dde4e693b485bdcffd4d58d1efa177b9e3c (commit)
       via  0964c7ad069e048da08a1d9ad1dd32a90846f11c (commit)
       via  921d74d8559daf6fbef7d78e582029f6acb04f6e (commit)
      from  d1f245a66d532a8719dae261a54543f2ee05c81b (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=b19b7dde4e693b485bdcffd4d58d1efa177b9e3c
commit b19b7dde4e693b485bdcffd4d58d1efa177b9e3c
Merge: d1f245a 0964c7a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat May 16 00:58:17 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat May 16 00:58:17 2015 -0400

    Merge topic 'use-std-unordered_map' into next
    
    0964c7ad Use std::unordered_map instead of hash_map where available.
    921d74d8 AutoGen: Don't iterate over a container while populating it.


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

    Use std::unordered_map instead of hash_map where available.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19d83f1..2c3dba4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,7 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
   else()
     set(CMAKE_CXX_STANDARD 11)
   endif()
+  include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx11_unordered_map.cmake)
 endif()
 
 # option to set the internal encoding of CMake to UTF-8
diff --git a/Source/Checks/cm_cxx11_unordered_map.cmake b/Source/Checks/cm_cxx11_unordered_map.cmake
new file mode 100644
index 0000000..3e6ce88
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cmake
@@ -0,0 +1,23 @@
+
+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()
diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp
new file mode 100644
index 0000000..ce86243
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cpp
@@ -0,0 +1,2 @@
+#include <unordered_map>
+int main() { 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

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=921d74d8559daf6fbef7d78e582029f6acb04f6e
commit 921d74d8559daf6fbef7d78e582029f6acb04f6e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat May 16 06:52:30 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat May 16 06:54:31 2015 +0200

    AutoGen: Don't iterate over a container while populating it.
    
    The InitializeAutogenTarget creates new targets and adds them to the
    Targets container on the makefile.  In this method, we have a reference
    to that container and we are iterating over it.  That happens to work
    with hash_map, but it fails with undefined behavior when using the
    std::unordered_map from libstdc++-4.9 (and likely others).

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 1c9c475..82023e4 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1373,10 +1373,18 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
     {
     cmTargets& targets =
       this->LocalGenerators[i]->GetMakefile()->GetTargets();
+    std::vector<std::string> targetNames;
+    targetNames.reserve(targets.size());
     for(cmTargets::iterator ti = targets.begin();
         ti != targets.end(); ++ti)
       {
-      cmTarget& target = ti->second;
+      targetNames.push_back(ti->second.GetName());
+      }
+    for(std::vector<std::string>::iterator ti = targetNames.begin();
+        ti != targetNames.end(); ++ti)
+      {
+      cmTarget& target = *this->LocalGenerators[i]
+                              ->GetMakefile()->FindTarget(*ti, true);
       if(target.GetType() == cmTarget::EXECUTABLE ||
          target.GetType() == cmTarget::STATIC_LIBRARY ||
          target.GetType() == cmTarget::SHARED_LIBRARY ||

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

Summary of changes:
 CMakeLists.txt                                     |    1 +
 Source/Checks/cm_cxx11_unordered_map.cmake         |   23 ++++++++++++++++++++
 ...cxx14_cstdio.cpp => cm_cxx11_unordered_map.cpp} |    2 +-
 Source/cmConfigure.cmake.h.in                      |    1 +
 Source/cmDefinitions.h                             |    9 +++++++-
 Source/cmFileTimeComparison.cxx                    |   12 ++++++++++
 Source/cmGlobalGenerator.cxx                       |   10 ++++++++-
 Source/cmGlobalGenerator.h                         |   10 ++++++++-
 Source/cmMakefile.h                                |   14 +++++++++++-
 Source/cmTarget.h                                  |   12 ++++++++--
 10 files changed, 87 insertions(+), 7 deletions(-)
 create mode 100644 Source/Checks/cm_cxx11_unordered_map.cmake
 copy Source/Checks/{cm_cxx14_cstdio.cpp => cm_cxx11_unordered_map.cpp} (50%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list