diff --git a/3rdParty/unordered_dense/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch b/3rdParty/unordered_dense/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch new file mode 100644 index 000000000..e84a3368d --- /dev/null +++ b/3rdParty/unordered_dense/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch @@ -0,0 +1,33 @@ +From 78eb7bc8a64099235daa3a8cb249a5ce35a4db07 Mon Sep 17 00:00:00 2001 +From: Gleb Mazovetskiy +Date: Sun, 4 Aug 2024 12:32:50 +0100 +Subject: [PATCH] Disable PMR support for mingw-std-threads compat + +--- + include/ankerl/unordered_dense.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/ankerl/unordered_dense.h b/include/ankerl/unordered_dense.h +index 2aaacd6..e6fee6e 100644 +--- a/include/ankerl/unordered_dense.h ++++ b/include/ankerl/unordered_dense.h +@@ -98,6 +98,8 @@ + # include // for abort + # endif + ++// DevilutionX disables PMR support because it does not play well with mingw-std-threads. ++#if false + # if defined(__has_include) + # if __has_include() + # define ANKERL_UNORDERED_DENSE_PMR std::pmr // NOLINT(cppcoreguidelines-macro-usage) +@@ -107,6 +109,7 @@ + # include // for polymorphic_allocator + # endif + # endif ++#endif + + # if defined(_MSC_VER) && defined(_M_X64) + # include +-- +2.43.0 + diff --git a/3rdParty/unordered_dense/CMakeLists.txt b/3rdParty/unordered_dense/CMakeLists.txt new file mode 100644 index 000000000..bd609327b --- /dev/null +++ b/3rdParty/unordered_dense/CMakeLists.txt @@ -0,0 +1,21 @@ +include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(FetchContent) + +find_package(Patch REQUIRED) + +set(unordered_dense_URL "https://github.com/martinus/unordered_dense/archive/refs/tags/v4.4.0.tar.gz") +set(unordered_dense_HASH "f33c294a010540434b272754f937decf") + +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + FetchContent_Declare(unordered_dense + URL ${unordered_dense_URL} + URL_HASH MD5=${unordered_dense_HASH} + ) +else() + FetchContent_Declare(unordered_dense + URL ${unordered_dense_URL} + URL_HASH MD5=${unordered_dense_HASH} + PATCH_COMMAND "${Patch_EXECUTABLE}" -p1 -N < "${CMAKE_CURRENT_LIST_DIR}/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch" || true + ) +endif() +FetchContent_MakeAvailableExcludeFromAll(unordered_dense) diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake index 99af8005d..0957c7196 100644 --- a/CMake/Dependencies.cmake +++ b/CMake/Dependencies.cmake @@ -225,6 +225,22 @@ add_subdirectory(3rdParty/tl) add_subdirectory(3rdParty/hoehrmann_utf8) +if(NOT DEFINED DEVILUTIONX_SYSTEM_UNORDERED_DENSE) + find_package(unordered_dense CONFIG QUIET) + if (unordered_dense_FOUND) + message("-- Found unordered_dense") + else() + message("-- Suitable unordered_dense package not found, will use unordered_dense from source") + set(DEVILUTIONX_SYSTEM_UNORDERED_DENSE OFF) + endif() + dependency_options("unordered_dense" DEVILUTIONX_SYSTEM_UNORDERED_DENSE ON DEVILUTIONX_STATIC_UNORDERED_DENSE) +endif() +if(DEVILUTIONX_SYSTEM_UNORDERED_DENSE) + find_package(unordered_dense CONFIG REQUIRED) +else() + add_subdirectory(3rdParty/unordered_dense) +endif() + if(SUPPORTS_MPQ OR NOT NONET) add_subdirectory(3rdParty/PKWare) endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 058d30e93..945cc35b7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -396,6 +396,7 @@ target_link_libraries(libdevilutionx PUBLIC libsmackerdec simpleini::simpleini tl + unordered_dense::unordered_dense libdevilutionx_codec libdevilutionx_format_int libdevilutionx_file_util diff --git a/tools/make_src_dist.py b/tools/make_src_dist.py index 48206f213..4b40b943f 100755 --- a/tools/make_src_dist.py +++ b/tools/make_src_dist.py @@ -36,7 +36,7 @@ import sys # 1. Uncommon in package managers (sdl_audiolib and simpleini). # 2. Require devilutionx forks (all others). _DEPS = ['asio', 'libmpq', 'libsmackerdec', - 'libzt', 'sdl_audiolib', 'simpleini'] + 'libzt', 'sdl_audiolib', 'simpleini', 'unordered_dense'] _ALWAYS_VENDORED_DEPS = ['asio', 'libmpq', 'libsmackerdec', 'libzt'] # These dependencies are not vendored by default.