Libmv: Add an option to disable schur specializations build-time
[blender.git] / extern / libmv / third_party / ceres / SConscript
index 2573a9742ad6f093ff0876f9db8304f9539eb021..44869c88d0bb436f931195eb150073da5783ea42 100644 (file)
@@ -13,52 +13,44 @@ src = []
 defs = []
 
 src += env.Glob('internal/ceres/*.cc')
-src += env.Glob('internal/ceres/generated/schur_eliminator_d_d_d.cc')
-src += env.Glob('internal/ceres/generated/partitioned_matrix_view_d_d_d.cc')
-#src += env.Glob('internal/ceres/generated/*.cc')
+if env['WITH_BF_LIBMV_SCHUR_SPECIALIZATIONS']:
+    src += env.Glob('internal/ceres/generated/*.cc')
+else:
+    src += env.Glob('internal/ceres/generated/schur_eliminator_d_d_d.cc')
+    src += env.Glob('internal/ceres/generated/partitioned_matrix_view_d_d_d.cc')
+    defs.append('CERES_RESTRICT_SCHUR_SPECIALIZATION')
 
 defs.append('CERES_HAVE_PTHREAD')
 defs.append('CERES_NO_SUITESPARSE')
 defs.append('CERES_NO_CXSPARSE')
 defs.append('CERES_NO_LAPACK')
-defs.append('CERES_RESTRICT_SCHUR_SPECIALIZATION')
 defs.append('CERES_HAVE_RWLOCK')
 
 if env['WITH_BF_OPENMP']:
     defs.append('CERES_USE_OPENMP')
 
-conf = Configure(env)
-if conf.CheckCXXHeader("unordered_map"):
-    # Even so we've found unordered_map header file it doesn't
-    # mean unordered_map and unordered_set will be declared in
-    # std namespace.
-    #
-    # Namely, MSVC 2008 have unordered_map header which declares
-    # unordered_map class in std::tr1 namespace. In order to support
-    # this, we do extra check to see which exactly namespace is
-    # to be used.
-
-    if conf.CheckType('std::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
-        defs.append('CERES_STD_UNORDERED_MAP')
-        print("-- Found unordered_map/set in std namespace.")
-    elif conf.CheckType('std::tr1::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
-        defs.append('CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE')
-        print("-- Found unordered_map/set in std::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')
-    print("-- Found unordered_map/set in std::tr1 namespace.")
+if env['WITH_UNORDERED_MAP_SUPPORT']:
+    if env['UNORDERED_MAP_HEADER'] == 'unordered_map':
+        if env['UNORDERED_MAP_NAMESPACE'] == 'std':
+            defs.append('CERES_STD_UNORDERED_MAP')
+        elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1':
+            defs.append('CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE')
+    elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1':
+        defs.append('CERES_TR1_UNORDERED_MAP')
 else:
-    print("-- Unable to find <unordered_map> or <tr1/unordered_map>. ")
     print("-- Replacing unordered_map/set with map/set (warning: slower!)")
     defs.append('CERES_NO_UNORDERED_MAP')
 
-env = conf.Finish()
+if not env['WITH_SHARED_PTR_SUPPORT']:
+    print("-- Unable to find shared_ptr which is required for compilation.")
+    exit(1)
+
+if env['SHARED_PTR_HEADER'] == 'tr1/memory':
+    defs.append('CERES_TR1_MEMORY_HEADER')
+if env['SHARED_PTR_NAMESPACE'] == 'std::tr1':
+    defs.append('CERES_TR1_SHARED_PTR')
 
-incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags'
+incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags ./config'
 
 # work around broken hashtable in 10.5 SDK
 if env['OURPLATFORM'] == 'darwin' and env['WITH_BF_BOOST']: