Made collections port compatible with MSVC2008
[blender.git] / extern / libmv / third_party / ceres / bundle.sh
index 10c70ec51f72488805626c34c21b7db2e5ab0aa4..906c5d3dd48a1ef9d996adfa2e70e32bb463af78 100755 (executable)
@@ -175,9 +175,33 @@ if(WITH_OPENMP)
 endif()
 
 include(CheckIncludeFileCXX)
-CHECK_INCLUDE_FILE_CXX(unordered_map UNORDERED_MAP_IN_STD_NAMESPACE)
-if(UNORDERED_MAP_IN_STD_NAMESPACE)
-       ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP)
+CHECK_INCLUDE_FILE_CXX(unordered_map HAVE_STD_UNORDERED_MAP_HEADER)
+if(HAVE_STD_UNORDERED_MAP_HEADER)
+       INCLUDE (CheckCXXSourceCompiles)
+       CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
+                                 int main() {
+                                   std::unordered_map<int, int> map;
+                                   return 0;
+                                 }"
+                                 HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
+       if(HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
+               ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP)
+       else()
+               CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
+                                         int main() {
+                                           std::tr1::unordered_map<int, int> map;
+                                           return 0;
+                                         }"
+                                         HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
+               if(HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
+                       ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
+               else()
+                       MESSAGE("-- Found <unordered_map> but can not find neither std::unordered_map "
+                               "nor std::tr1::unordered_map.")
+                       MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)")
+                       ADD_DEFINITIONS(-DCERES_NO_UNORDERED_MAP)
+               endif()
+       endif()
 else()
        CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" UNORDERED_MAP_IN_TR1_NAMESPACE)
        if(UNORDERED_MAP_IN_TR1_NAMESPACE)
@@ -224,7 +248,14 @@ if env['WITH_BF_OPENMP']:
 
 conf = Configure(env)
 if conf.CheckCXXHeader("unordered_map"):
-    defs.append('CERES_STD_UNORDERED_MAP')
+    if conf.CheckType('std::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
+        defs.append('CERES_STD_UNORDERED_MAP')
+    elif conf.CheckType('std::tr1::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
+        defs.append('CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE')
+    else:
+        print("-- Found <unordered_map> but can not find neither std::unordered_map nor std::tr1::unordered_map.")
+        print("-- Replacing unordered_map/set with map/set (warning: slower!)")
+        defs.append('CERES_NO_UNORDERED_MAP')
 elif conf.CheckCXXHeader("tr1/unordered_map"):
     defs.append('CERES_TR1_UNORDERED_MAP')
 else:
@@ -232,6 +263,8 @@ else:
     print("-- Replacing unordered_map/set with map/set (warning: slower!)")
     defs.append('CERES_NO_UNORDERED_MAP')
 
+env = conf.Finish()
+
 incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags'
 
 # work around broken hashtable in 10.5 SDK