From e26fab71d6ce1400d3d99c39961e78b41059b980 Mon Sep 17 00:00:00 2001 From: Reilly Brogan Date: Mon, 8 Jun 2026 00:33:49 -0500 Subject: [PATCH] Add DUSK_PACKAGE_INSTALL (#1966) Signed-off-by: Reilly Brogan --- CMakeLists.txt | 21 +++++++++++++++++---- src/dusk/imgui/ImGuiEngine.cpp | 4 ++++ src/m_Do/m_Do_main.cpp | 3 +++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f36987ad96..e52e841ec5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,7 @@ option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON) option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF) +option(DUSK_PACKAGE_INSTALL "Install Dusklight with a Linux-native file structure" OFF) option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") @@ -256,7 +257,6 @@ elseif (MSVC) add_compile_options($<$:/utf-8>) endif () - include(FetchContent) # Declare all dependencies first so CMake can download them in parallel @@ -425,6 +425,11 @@ if(ANDROID) list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1) endif () +if (DUSK_PACKAGE_INSTALL) + include(GNUInstallDirs) + list(APPEND GAME_COMPILE_DEFS DUSK_ASSET_DIR="${CMAKE_INSTALL_FULL_DATADIR}/dusklight/") +endif () + if (DUSK_GFX_DEBUG_GROUPS) list(APPEND GAME_COMPILE_DEFS DUSK_GFX_DEBUG_GROUPS=1) target_compile_definitions(aurora_gx PRIVATE AURORA_GFX_DEBUG_GROUPS) @@ -648,12 +653,20 @@ set(EXTRA_TARGETS "") if (TARGET crashpad_handler) list(APPEND EXTRA_TARGETS crashpad_handler) endif () -install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) +if (DUSK_PACKAGE_INSTALL) + install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR}) +else() + install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) +endif() aurora_install_runtime_dlls(dusklight ${CMAKE_INSTALL_PREFIX}) if (NOT APPLE) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) + if (DUSK_PACKAGE_INSTALL) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dusklight) + else() + install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif() endif () -if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) +if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo AND NOT DUSK_PACKAGE_INSTALL) set(DEBUG_FILES_LIST "") foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS) get_target_output_name(${target} output_name) diff --git a/src/dusk/imgui/ImGuiEngine.cpp b/src/dusk/imgui/ImGuiEngine.cpp index 4b6a7fb531..b2ea1f8e1a 100644 --- a/src/dusk/imgui/ImGuiEngine.cpp +++ b/src/dusk/imgui/ImGuiEngine.cpp @@ -20,7 +20,11 @@ namespace dusk { namespace { std::string GetAssetPath(const char* assetName) { +#ifdef DUSK_ASSET_DIR + const char* basePath = DUSK_ASSET_DIR; +#else const char* basePath = SDL_GetBasePath(); +#endif if (basePath != nullptr && basePath[0] != '\0') { return std::string(basePath) + "res/" + assetName; } diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 7cb9830cd5..12d2202e36 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -577,6 +577,9 @@ int game_main(int argc, char* argv[]) { config.appName = dusk::AppName; config.userPath = reinterpret_cast(userPathString.c_str()); config.cachePath = reinterpret_cast(cachePathString.c_str()); +#ifdef DUSK_ASSET_DIR + config.resourcesPath = DUSK_ASSET_DIR; +#endif config.vsync = dusk::getSettings().video.enableVsync; config.startFullscreen = dusk::getSettings().video.enableFullscreen; config.windowPosX = -1;