diff --git a/cmake/sdk/CMakeLists.txt b/cmake/sdk/CMakeLists.txt index 2f6b5b2b3..8db61b4d2 100644 --- a/cmake/sdk/CMakeLists.txt +++ b/cmake/sdk/CMakeLists.txt @@ -20,6 +20,8 @@ add_subdirectory(lib/third_party/imgui) add_subdirectory_if_exists(lib/third_party/fmt) add_subdirectory_if_exists(lib/third_party/nlohmann_json) +set(FMT_LIBRARIES fmt::fmt-header-only) + add_subdirectory(lib/external/libwolv) set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF) diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 6da4b1d07..91e90d6ed 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -35,7 +35,6 @@ set(LIBIMHEX_SOURCES source/helpers/patches.cpp source/helpers/encoding_file.cpp source/helpers/logger.cpp - source/helpers/stacktrace.cpp source/helpers/tar.cpp source/helpers/debugging.cpp @@ -64,8 +63,6 @@ if (APPLE) set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} source/helpers/utils_macos.m) endif () -add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") - if (IMHEX_EXTERNAL_PLUGIN_BUILD) add_library(libimhex IMPORTED SHARED GLOBAL) set(LIBIMHEX_LIBRARY_TYPE INTERFACE) @@ -79,6 +76,7 @@ else() set(LIBIMHEX_LIBRARY_TYPE PUBLIC) endif() +target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON) enableUnityBuild(libimhex) setupCompilerFlags(libimhex) @@ -108,7 +106,7 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD) target_link_libraries(libimhex PRIVATE microtar libpl plcli libpl-gen libwolv ${FMT_LIBRARIES} ${NFD_LIBRARIES} magic dl ${IMGUI_LIBRARIES} ${NLOHMANN_JSON_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} ${JTHREAD_LIBRARIES}) endif() -target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} ${IMGUI_LIBRARIES} LLVMDemangle) +target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} ${IMGUI_LIBRARIES}) set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE) diff --git a/lib/libimhex/include/hex/helpers/logger.hpp b/lib/libimhex/include/hex/helpers/logger.hpp index 0338bb9f6..50b4e9531 100644 --- a/lib/libimhex/include/hex/helpers/logger.hpp +++ b/lib/libimhex/include/hex/helpers/logger.hpp @@ -32,16 +32,16 @@ namespace hex::log { [[maybe_unused]] void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level, const char *projectName); [[maybe_unused]] void print(const fmt::text_style &ts, const std::string &level, const std::string &fmt, auto && ... args) { - std::scoped_lock lock(impl::g_loggerMutex); + std::scoped_lock lock(g_loggerMutex); - auto dest = impl::getDestination(); + auto dest = getDestination(); printPrefix(dest, ts, level, IMHEX_PROJECT_NAME); auto message = fmt::format(fmt::runtime(fmt), args...); fmt::print(dest, "{}\n", message); fflush(dest); - impl::getLogEntries().push_back({ IMHEX_PROJECT_NAME, level, std::move(message) }); + getLogEntries().push_back({ IMHEX_PROJECT_NAME, level, std::move(message) }); } } diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp index 1356a01d0..7cbeb12de 100644 --- a/lib/libimhex/source/helpers/logger.cpp +++ b/lib/libimhex/source/helpers/logger.cpp @@ -67,7 +67,7 @@ namespace hex::log::impl { fmt::print(dest, "[{0:%H:%M:%S}] ", now); - if (impl::isRedirected()) + if (isRedirected()) fmt::print(dest, "{0} ", level); else fmt::print(dest, ts, "{0} ", level); diff --git a/lib/third_party/HashLibPlus b/lib/third_party/HashLibPlus index a5195f258..44ad86189 160000 --- a/lib/third_party/HashLibPlus +++ b/lib/third_party/HashLibPlus @@ -1 +1 @@ -Subproject commit a5195f258444c0e9727755f5632d38e0061dee82 +Subproject commit 44ad8618900bf118f6534e923cff6da028c0e2cf diff --git a/main/gui/CMakeLists.txt b/main/gui/CMakeLists.txt index 77a120384..f2e9385fb 100644 --- a/main/gui/CMakeLists.txt +++ b/main/gui/CMakeLists.txt @@ -3,6 +3,7 @@ project(main) add_executable(main ${APPLICATION_TYPE} source/main.cpp source/crash_handlers.cpp + source/stacktrace.cpp source/window/window.cpp source/window/win_window.cpp @@ -16,6 +17,7 @@ add_executable(main ${APPLICATION_TYPE} source/messaging/win.cpp source/messaging/web.cpp + source/init/splash_window.cpp source/init/tasks.cpp @@ -50,9 +52,9 @@ set_target_properties(main PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../.. POSITION_INDEPENDENT_CODE ON) -add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") +target_compile_definitions(main PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") -target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv libpl plcli libpl-gen ${FMT_LIBRARIES}) +target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv libpl plcli libpl-gen ${FMT_LIBRARIES} LLVMDemangle) if (WIN32) target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib) else () diff --git a/lib/libimhex/include/hex/helpers/stacktrace.hpp b/main/gui/include/stacktrace.hpp similarity index 100% rename from lib/libimhex/include/hex/helpers/stacktrace.hpp rename to main/gui/include/stacktrace.hpp diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index fdda088ab..2ddf766cb 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -6,7 +6,6 @@ #include #include -#include #include @@ -14,6 +13,7 @@ #include +#include #include #include @@ -153,7 +153,9 @@ namespace hex::crash { // Setup functions to handle signals, uncaught exception, or similar stuff that will crash ImHex void setupCrashHandlers() { - // Register signal handlers + stacktrace::initialize(); + + // Register signal handlers { #define HANDLE_SIGNAL(name) \ std::signal(name, [](int signalNumber) { \ diff --git a/main/gui/source/main.cpp b/main/gui/source/main.cpp index 26548cb70..0c569565e 100644 --- a/main/gui/source/main.cpp +++ b/main/gui/source/main.cpp @@ -247,7 +247,7 @@ namespace { */ int main(int argc, char **argv) { Window::initNative(); - hex::crash::setupCrashHandlers(); + crash::setupCrashHandlers(); if (argc > 1) { handleCommandLineInterface(argc, argv); diff --git a/lib/libimhex/source/helpers/stacktrace.cpp b/main/gui/source/stacktrace.cpp similarity index 99% rename from lib/libimhex/source/helpers/stacktrace.cpp rename to main/gui/source/stacktrace.cpp index cf21f7122..84e340217 100644 --- a/lib/libimhex/source/helpers/stacktrace.cpp +++ b/main/gui/source/stacktrace.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index ee195da27..f80236f8b 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -46,8 +45,6 @@ namespace hex { using namespace std::literals::chrono_literals; Window::Window() { - stacktrace::initialize(); - constexpr static auto openEmergencyPopup = [](const std::string &title){ TaskManager::doLater([title] { for (const auto &provider : ImHexApi::Provider::getProviders()) diff --git a/main/updater/CMakeLists.txt b/main/updater/CMakeLists.txt index f3f77029a..a4caf2f5a 100644 --- a/main/updater/CMakeLists.txt +++ b/main/updater/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(updater source/main.cpp ) -add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") +target_compile_definitions(updater PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") target_link_libraries(updater PRIVATE libimhex wolv::io ${FMT_LIBRARIES}) add_dependencies(main updater) diff --git a/plugins/builtin/CMakeLists.txt b/plugins/builtin/CMakeLists.txt index 3f4887e27..d6bdcf95b 100644 --- a/plugins/builtin/CMakeLists.txt +++ b/plugins/builtin/CMakeLists.txt @@ -118,6 +118,7 @@ add_imhex_plugin( ui ${JTHREAD_LIBRARIES} plcli + LLVMDemangle ) if (WIN32) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f764f061a..95539e91c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,9 @@ project(unit_tests) -add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") - add_custom_target(unit_tests DEPENDS helpers algorithms) + add_subdirectory(common) +target_compile_definitions(tests_common PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") add_subdirectory(helpers) add_subdirectory(algorithms)