Files

98 lines
2.9 KiB
CMake
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
cmake_minimum_required(VERSION 3.18)
project(sega_mount)
set(CMAKE_CXX_STANDARD 20)
# ===== 公共编译设置 =====
if (WIN32)
add_compile_options(/utf-8)
add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00 NTDDI_VERSION=0x0A000000)
endif ()
# ===== FetchContent: ImGui (Win32 + DirectX11 后端) =====
include(FetchContent)
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.92.9b
GIT_SHALLOW TRUE
CONFIGURE_COMMAND "" # ImGui 无 CMakeLists.txt,跳过自动配置
BUILD_COMMAND ""
)
FetchContent_MakeAvailable(imgui)
# 手动构建 ImGui 静态库(ImGui 仓库不含 CMakeLists.txt)
add_library(imgui STATIC
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_win32.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_dx11.cpp
)
target_include_directories(imgui PUBLIC
${imgui_SOURCE_DIR}
${imgui_SOURCE_DIR}/backends
)
if (WIN32)
target_link_libraries(imgui PUBLIC d3d11 d3dcompiler dxgi)
endif ()
# ===== 公共源文件 =====
set(SEGA_CORE_SOURCES
src/config.cpp
src/driver_service.cpp
src/fscrypt.cpp
src/icf_parser.cpp
src/icf_mount.cpp
src/vhd_mount.cpp
src/utils/aes.cpp
src/utils/bcrypt_util.cpp
src/utils/crc32.cpp
src/utils/files.cpp
src/utils/log.cpp
src/utils/strings.cpp
src/utils/resource.cpp
)
set(SEGA_WIN_LIBS bcrypt virtdisk)
# ===== 统一目标: sega_mount (GUI + CLI 合一) =====
# 无参数启动 GUI;带参数(-m/-u)走 CLI 模式
add_executable(sega_mount
src/main.cpp
src/gui/theme.cpp
src/gui/imgui_spectrum.cpp
src/gui/dx11_backend.cpp
src/gui/gui_utils.cpp
src/gui/ui.cpp
res/resource.rc
${SEGA_CORE_SOURCES}
)
target_include_directories(sega_mount PRIVATE src res)
if (WIN32)
target_link_libraries(sega_mount PRIVATE ${SEGA_WIN_LIBS} imgui comdlg32)
# WinMain 入口需要 Windows 子系统(无参数时不弹控制台窗口)
# manifest 请求管理员权限(UAC 提权)
set_target_properties(sega_mount PROPERTIES LINK_FLAGS
"/SUBSYSTEM:WINDOWS /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"")
endif ()
set_target_properties(sega_mount PROPERTIES OUTPUT_NAME sega_mount)
# ===== 单元测试: 挂载/卸载 OPT 容器 =====
add_executable(test_mount_opt
tests/test_mount_opt.cpp
src/driver_service.cpp
src/fscrypt.cpp
src/utils/aes.cpp
src/utils/bcrypt_util.cpp
src/utils/files.cpp
src/utils/log.cpp
src/utils/strings.cpp
src/utils/resource.cpp
)
target_include_directories(test_mount_opt PRIVATE src)
if (WIN32)
target_link_libraries(test_mount_opt PRIVATE bcrypt)
endif ()