Skip to content

Commit

Permalink
libc++ fixes: don't rely on tr1
Browse files Browse the repository at this point in the history
libc++ doesn't ship tr1, but ships unordered_map as it is part of c++11.

Since this is the only tr1 header used in openmw, add a check for c++11
unordered_map and fallback to tr1 unordered_map if it's not found.
  • Loading branch information
eroen committed May 26, 2013
1 parent 2850032 commit 886bc7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ if (UNIX AND NOT APPLE)
find_package (Threads)
endif()

include (CheckIncludeFileCXX)
check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP)
if (HAVE_UNORDERED_MAP)
add_definitions(-DHAVE_UNORDERED_MAP)
endif ()


set(BOOST_COMPONENTS system filesystem program_options thread date_time wave)

Expand Down
8 changes: 7 additions & 1 deletion components/files/configurationmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#ifdef _WIN32
#include <boost/tr1/tr1/unordered_map>
#elif defined HAVE_UNORDERED_MAP
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
Expand Down Expand Up @@ -48,7 +50,11 @@ struct ConfigurationManager
typedef Files::FixedPath<> FixedPathType;

typedef const boost::filesystem::path& (FixedPathType::*path_type_f)() const;
typedef std::tr1::unordered_map<std::string, path_type_f> TokensMappingContainer;
#if defined HAVE_UNORDERED_MAP
typedef std::unordered_map<std::string, path_type_f> TokensMappingContainer;
#else
typedef std::tr1::unordered_map<std::string, path_type_f> TokensMappingContainer;
#endif

void loadConfig(const boost::filesystem::path& path,
boost::program_options::variables_map& variables,
Expand Down

0 comments on commit 886bc7e

Please sign in to comment.