1
0
mirror of synced 2024-09-23 19:18:24 +02:00

build: Use custom jthread implementation if standard one is not available

This commit is contained in:
WerWolv 2023-11-02 20:21:38 +01:00
parent eefdbe7ef1
commit 407ec1ceb6
11 changed files with 37 additions and 10 deletions

9
.gitmodules vendored
View File

@ -18,13 +18,18 @@
path = lib/external/capstone
url = https://github.com/capstone-engine/capstone
ignore = dirty
[submodule "lib/external/jthread/jthread"]
path = lib/external/jthread/jthread
url = https://github.com/josuttis/jthread
ignore = dirty
[submodule "lib/external/libromfs"]
path = lib/external/libromfs
url = https://github.com/WerWolv/libromfs
ignore = dirty
[submodule "lib/external/pattern_language"]
path = lib/external/pattern_language
url = https://github.com/WerWolv/PatternLanguage
[submodule "lib/external/libwolv"]
path = lib/external/libwolv
url = https://github.com/WerWolv/libwolv
url = https://github.com/WerWolv/libwolv

View File

@ -382,7 +382,7 @@ function(detectBadClone)
file (GLOB EXTERNAL_DIRS "lib/external/*")
foreach (EXTERNAL_DIR ${EXTERNAL_DIRS})
file(GLOB RESULT "${EXTERNAL_DIR}/*")
file(GLOB_RECURSE RESULT "${EXTERNAL_DIR}/*")
list(LENGTH RESULT ENTRY_COUNT)
if(ENTRY_COUNT LESS_EQUAL 1)
message(FATAL_ERROR "External dependency ${EXTERNAL_DIR} is empty!\nMake sure to correctly clone ImHex using the --recurse-submodules git option or initialize the submodules manually.")
@ -570,6 +570,18 @@ macro(addBundledLibraries)
pkg_check_modules(miniaudio REQUIRED IMPORTED_TARGET miniaudio)
endif()
if (NOT USE_SYSTEM_JTHREAD)
add_subdirectory(${EXTERN_LIBS_FOLDER}/jthread EXCLUDE_FROM_ALL)
set(JTHREAD_LIBRARIES jthread)
else()
find_path(JOSUTTIS_JTHREAD_INCLUDE_DIRS "condition_variable_any2.hpp")
include_directories(${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
add_library(jthread INTERFACE)
target_include_directories(jthread INTERFACE ${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
set(JTHREAD_LIBRARIES jthread)
endif()
if (NOT USE_SYSTEM_CAPSTONE)
set(CAPSTONE_BUILD_STATIC_RUNTIME OFF CACHE BOOL "Disable shared library building")
set(CAPSTONE_BUILD_SHARED OFF CACHE BOOL "Disable shared library building")

1
dist/web/Dockerfile vendored
View File

@ -36,7 +36,6 @@ mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
/vcpkg/vcpkg install --triplet=wasm32-emscripten libmagic
/vcpkg/vcpkg install --triplet=wasm32-emscripten freetype
/vcpkg/vcpkg install --triplet=wasm32-emscripten josuttis-jthread
/vcpkg/vcpkg install --triplet=wasm32-emscripten mbedtls
EOF

6
lib/external/jthread/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.16)
project(jthread)
add_library(jthread INTERFACE)
target_include_directories(jthread INTERFACE includes)

View File

@ -0,0 +1,7 @@
#pragma once
#if __has_include(<jthread>)
#include <jthread>
#else
#include "../jthread/source/jthread.hpp"
#endif

1
lib/external/jthread/jthread vendored Submodule

@ -0,0 +1 @@
Subproject commit 0fa8d394254886c555d6faccd0a3de819b7d47f8

View File

@ -95,7 +95,7 @@ elseif (APPLE)
endif ()
target_link_libraries(libimhex PRIVATE ${FMT_LIBRARIES})
target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} plcli libpl libpl-gen ${MINIAUDIO_LIBRARIES} libwolv-utils libwolv-io libwolv-hash libwolv-net libwolv-containers)
target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} plcli libpl libpl-gen ${MINIAUDIO_LIBRARIES} ${JTHREAD_LIBRARIES} libwolv-utils libwolv-io libwolv-hash libwolv-net libwolv-containers)
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)

View File

@ -17,9 +17,7 @@
#include <utility>
#include <vector>
#if defined(OS_WEB)
#include <jthread.hpp>
#endif
#include <nlohmann/json.hpp>

View File

@ -12,9 +12,7 @@
#include <list>
#include <condition_variable>
#if defined(OS_WEB)
#include <jthread.hpp>
#endif
namespace hex {

View File

@ -8,9 +8,9 @@
#include <filesystem>
#include <thread>
#include <jthread.hpp>
#if defined(OS_WEB)
#include <jthread.hpp>
#include <emscripten.h>
#endif

View File

@ -6,6 +6,7 @@
#include <mutex>
#include <thread>
#include <jthread.hpp>
#include <vector>
namespace hex::plugin::windows {