Move CERES_HASH_NAMESPACE macros to collections_port.h
Now that we have a clearer understanding of the naming rules
there is no need for these macro definitions to be done in
the cmake file.
This cleans up the compilation command line.
Change-Id: Idc8fc7a7c9376e021dc4790af66e599105351917
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7519f48..41db59a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -411,14 +411,10 @@
CHECK_INCLUDE_FILE_CXX(unordered_map UNORDERED_MAP_IN_STD_NAMESPACE)
If (UNORDERED_MAP_IN_STD_NAMESPACE)
ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP)
- ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"")
- ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"")
ELSE (UNORDERED_MAP_IN_STD_NAMESPACE)
CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" UNORDERED_MAP_IN_TR1_NAMESPACE)
IF (UNORDERED_MAP_IN_TR1_NAMESPACE)
ADD_DEFINITIONS(-DCERES_TR1_UNORDERED_MAP)
- ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"")
- ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"")
ELSE (UNORDERED_MAP_IN_TR1_NAMESPACE)
MESSAGE("-- Unable to find <unordered_map> or <tr1/unordered_map>. ")
MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)")
diff --git a/internal/ceres/collections_port.h b/internal/ceres/collections_port.h
index ae71e54..8f345d4 100644
--- a/internal/ceres/collections_port.h
+++ b/internal/ceres/collections_port.h
@@ -41,13 +41,20 @@
#if defined(CERES_TR1_UNORDERED_MAP)
# include <tr1/unordered_map>
# include <tr1/unordered_set>
+# define CERES_HASH_NAMESPACE_START namespace std { namespace tr1 {
+# define CERES_HASH_NAMESPACE_END } }
#endif
#if defined(CERES_STD_UNORDERED_MAP)
# include <unordered_map>
# include <unordered_set>
+# define CERES_HASH_NAMESPACE_START namespace std {
+# define CERES_HASH_NAMESPACE_END }
#endif
+#if !defined(CERES_NO_UNORDERED_MAP) && !defined(CERES_TR1_UNORDERED_MAP) && !defined(CERES_STD_UNORDERED_MAP)
+#error One of: CERES_NO_UNORDERED_MAP, CERES_TR1_UNORDERED_MAP, CERES_STD_UNORDERED_MAP must be defined!
+#endif
#include <utility>
#include "ceres/integral_types.h"
@@ -55,7 +62,7 @@
// Some systems don't have access to unordered_map/unordered_set. In
// that case, substitute the hash map/set with normal map/set. The
-// price to pay is slightly slower speed for some operations.
+// price to pay is slower speed for some operations.
#if defined(CERES_NO_UNORDERED_MAP)
namespace ceres {