Загрузка данных


cmake_minimum_required(VERSION 3.22)

project(DreamcoreLoader VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# ==================== FIX FOR MINGW CROSS-COMPILATION ====================
if(MINGW)
    # Fix dependency file issues with MinGW on Linux
    set(CMAKE_GENERATOR "Unix Makefiles" CACHE STRING "CMake Generator" FORCE)

    # Ensure proper Windows entry point
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--entry=wWinMainCRTStartup")
endif()
# ==================== END FIX ====================

if(MSVC)
    add_compile_options(/W4 /permissive- /EHsc)
    add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX WIN32_LEAN_AND_MEAN)
elseif(MINGW)
    add_compile_options(-Wall -Wextra -Wno-unused-parameter)
    add_compile_definitions(UNICODE _UNICODE NOMINMAX WIN32_LEAN_AND_MEAN)
    # Ensure Windows 10+ target
    add_compile_definitions(_WIN32_WINNT=0x0A00)
endif()

option(DREAMCORE_CONSOLE_LOGS "Enable console logging" OFF)
option(DREAMCORE_NIGHTLY "Mark as nightly build" OFF)
set(DREAMCORE_SERVER_URL "https://127.0.0.1" CACHE STRING "Production API Server URL")

if(DREAMCORE_SERVER_URL)
    add_compile_definitions(DREAMCORE_CUSTOM_URL=L"${DREAMCORE_SERVER_URL}")
endif()

if(DREAMCORE_CONSOLE_LOGS)
    add_compile_definitions(DREAMCORE_ENABLE_CONSOLE)
endif()

if(DREAMCORE_NIGHTLY)
    add_compile_definitions(DREAMCORE_BUILD_NIGHTLY)
endif()

set(IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")

# Use pre-copied flat ImGui files from build directory
# (They're copied there by setup_dreamcore_full_stack.sh to avoid subdirectory issues)
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui.cpp")
    set(IMGUI_SOURCES
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui.cpp"
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui_draw.cpp"
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui_tables.cpp"
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui_widgets.cpp"
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui_impl_dx11.cpp"
        "${CMAKE_CURRENT_BINARY_DIR}/imgui_src/imgui_impl_win32.cpp"
    )
    message(STATUS "[ImGui] Using flat sources from ${CMAKE_CURRENT_BINARY_DIR}/imgui_src")
else()
    # Fallback: use original sources if flat copies don't exist
    set(IMGUI_SOURCES
        "${IMGUI_DIR}/imgui.cpp"
        "${IMGUI_DIR}/imgui_draw.cpp"
        "${IMGUI_DIR}/imgui_tables.cpp"
        "${IMGUI_DIR}/imgui_widgets.cpp"
        "${IMGUI_DIR}/backends/imgui_impl_dx11.cpp"
        "${IMGUI_DIR}/backends/imgui_impl_win32.cpp"
    )
    message(STATUS "[ImGui] Using original sources from ${IMGUI_DIR}")
endif()

add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui PUBLIC
    ${IMGUI_DIR}
    ${IMGUI_DIR}/backends
)
target_link_libraries(imgui PUBLIC d3d11 dxgi d3dcompiler)

set(LOADER_SUBSYSTEM WIN32)
if(DREAMCORE_CONSOLE_LOGS)
    set(LOADER_SUBSYSTEM "")
endif()

add_executable(DreamcoreLoader ${LOADER_SUBSYSTEM}
    src/main.cpp
    src/app/application.cpp
    src/app/common/animation_utils.cpp
    src/app/common/blur_utils.cpp
    src/app/common/draw_utils.cpp
    src/app/dashboard/dashboard_context.cpp
    src/app/dashboard/dashboard_state.cpp
    src/app/dashboard/footer_bar.cpp
    src/app/dashboard/header_bar.cpp
    src/app/dashboard/home_panel.cpp
    src/app/dashboard/launch_overlay.cpp
    src/app/dashboard/resize_grip.cpp
    src/app/dashboard/shell_widgets.cpp
    src/app/license/license_format.cpp
    src/app/license/license_screen.cpp
    src/app/settings/controls/settings_controls.cpp
    src/app/settings/controls/settings_widgets.cpp
    src/app/settings/settings_pages.cpp
    src/app/settings/settings_shell.cpp
    src/audio/keyboard_click_sound.cpp
    src/integration/debug_log.cpp
    src/integration/driver_bridge.cpp
    src/integration/driver_service.cpp
    src/integration/remote_runtime.cpp
    src/integration/runtime_paths.cpp
    src/integration/signature_verification.cpp
    src/integration/session_watch_service.cpp
    src/platform/win32_dx11_host.cpp
    src/ui/theme.cpp
    src/ui/widgets.cpp
)

target_include_directories(DreamcoreLoader PRIVATE
    src
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# Optional: DreamDriver include if it exists
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../DreamDriver/include")
    target_include_directories(DreamcoreLoader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../DreamDriver/include)
endif()
if(MSVC)
    target_link_libraries(DreamcoreLoader PRIVATE imgui advapi32 bcrypt crypt32 d3d11 dxgi d3dcompiler ole32 urlmon windowscodecs winhttp winmm wintrust)
else()
    # MinGW linking
    target_link_libraries(DreamcoreLoader PRIVATE imgui 
        advapi32 bcrypt crypt32 d3d11 dxgi d3dcompiler 
        ole32 urlmon windowscodecs winhttp winmm wintrust
        uuid # Required for MinGW GUIDs
        dwmapi # Often used in window hosts
    )
    # Ensure static linking for MinGW runtime to avoid missing DLLs on target Windows machine
    target_link_options(DreamcoreLoader PRIVATE -static-libgcc -static-libstdc++ -static -lpthread)
endif()

set_target_properties(DreamcoreLoader PROPERTIES
    OUTPUT_NAME "DreamcoreLoader"
)

if(MSVC AND DREAMCORE_CONSOLE_LOGS)
    # When building as console app (no WIN32 flag), but keeping wWinMain entry point, 
    # we need to tell the linker to use wWinMainCRTStartup.
    set_target_properties(DreamcoreLoader PROPERTIES LINK_FLAGS "/ENTRY:wWinMainCRTStartup")
endif()

# ---------------------------------------------------------------------------
# Pre-Builder Target
# ---------------------------------------------------------------------------

add_executable(DreamcorePreBuilder ${LOADER_SUBSYSTEM}
    src/prebuilder_main.cpp
    src/app/prebuilder_application.cpp
    src/app/common/animation_utils.cpp
    src/app/common/blur_utils.cpp
    src/app/common/draw_utils.cpp
    src/app/dashboard/dashboard_state.cpp
    src/app/license/license_format.cpp
    src/app/license/license_screen.cpp
    src/integration/debug_log.cpp
    src/integration/remote_runtime.cpp
    src/integration/runtime_paths.cpp
    src/integration/signature_verification.cpp
    src/platform/win32_dx11_host.cpp
    src/ui/theme.cpp
    src/ui/widgets.cpp
)

target_compile_definitions(DreamcorePreBuilder PRIVATE DREAMCORE_PREBUILDER)

target_include_directories(DreamcorePreBuilder PRIVATE
    src
    ${CMAKE_CURRENT_SOURCE_DIR}
)

if(MSVC)
    target_link_libraries(DreamcorePreBuilder PRIVATE imgui advapi32 bcrypt crypt32 d3d11 dxgi d3dcompiler ole32 urlmon windowscodecs winhttp winmm wintrust)
else()
    target_link_libraries(DreamcorePreBuilder PRIVATE imgui 
        advapi32 bcrypt crypt32 d3d11 dxgi d3dcompiler 
        ole32 urlmon windowscodecs winhttp winmm wintrust
        uuid dwmapi
    )
    target_link_options(DreamcorePreBuilder PRIVATE -static-libgcc -static-libstdc++ -static -lpthread)
endif()

set_target_properties(DreamcorePreBuilder PROPERTIES
    OUTPUT_NAME "DreamcorePreBuilder"
)

if(DREAMCORE_CONSOLE_LOGS)
    set_target_properties(DreamcorePreBuilder PROPERTIES LINK_FLAGS "/ENTRY:wWinMainCRTStartup")
endif()