diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-25 12:21:30 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-25 12:25:00 +0400 |
commit | bbfcb0b1e44636b73b8c46f1cb800fa53dda5277 (patch) | |
tree | b24ce4191d24a44ae420870b0c2a3667d118f6ca /extern/libmv/third_party/ceres/SConscript | |
parent | 6452d9f02f07fb3aaa7c6601228ef96015a54996 (diff) |
Build file macro for testing unordered_map C++ container support.
Using unordered_map and unordered_set C++ container types currently
requires careful testing or usage of boost, due to the various confusing
C++ version differences in include paths and namespaces.
Libmv defines tests for these cases in cmake and scons, such that ceres
can use any available implementation, or fall back too std::map/std::set
if none can be found.
This patch generalizes this buildfile code by providing a Blender macro.
* cmake: defines both the variables used by libmv at them moment as well
as 2 variables UNORDERED_MAP_INCLUDE_PREFIX and UNORDERED_MAP_NAMESPACE,
which can later be used in other C++ parts for convenience.
* scons: adds a tool script returning the include prefix and namespace.
Libmv checks these to define the appropriate definitions for ceres.
Differential Revision: https://developer.blender.org/D425
Diffstat (limited to 'extern/libmv/third_party/ceres/SConscript')
-rw-r--r-- | extern/libmv/third_party/ceres/SConscript | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/extern/libmv/third_party/ceres/SConscript b/extern/libmv/third_party/ceres/SConscript index 2573a9742ad..406e1593ded 100644 --- a/extern/libmv/third_party/ceres/SConscript +++ b/extern/libmv/third_party/ceres/SConscript @@ -7,6 +7,8 @@ import sys import os +from unordered_map import test_unordered_map + Import('env') src = [] @@ -27,35 +29,26 @@ 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. +def define_unordered_map(conf): + found, namespace, include_prefix = test_unordered_map(conf) + if found: + if not include_prefix: + if namespace == 'std': + defs.append('CERES_STD_UNORDERED_MAP') + return True + elif namespace == 'std::tr1': + defs.append('CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE') + return True + else: + if namespace == 'std::tr1': + defs.append('CERES_TR1_UNORDERED_MAP') + return True + return False - 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.") -else: - print("-- Unable to find <unordered_map> or <tr1/unordered_map>. ") +conf = Configure(env) +if not define_unordered_map(conf): print("-- Replacing unordered_map/set with map/set (warning: slower!)") defs.append('CERES_NO_UNORDERED_MAP') - env = conf.Finish() incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags' |