From 11fc7cd74d76f8a3604ba7ccf734e31569d58561 Mon Sep 17 00:00:00 2001 From: Kieran Kihn <114803508+kierankihn@users.noreply.github.com> Date: Thu, 11 Dec 2025 12:32:19 +0800 Subject: [PATCH] chore: restructure build targets and add runtime DLL copy logic - Split `uno-client` and `uno-server` as separate executables. - Adjusted `uno-game-lib` linking and updated runtime output directory. - Enabled post-build DLL copying for Windows compatibility. --- CMakeLists.txt | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aff4b4..3f47651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,14 @@ cmake_minimum_required(VERSION 4.0) project(uno-game) set(CMAKE_CXX_STANDARD 26) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) find_package(nlohmann_json REQUIRED) find_package(asio REQUIRED) find_package(argparse REQUIRED) find_package(Slint REQUIRED) +# Uno Game Library add_library(uno-game-lib src/game/Card.cpp src/game/CardTile.cpp @@ -18,20 +20,21 @@ add_library(uno-game-lib src/network/MessageSerializer.cpp src/network/NetworkServer.cpp src/network/NetworkClient.cpp - src/client/UnoClient.cpp - src/server/UnoServer.cpp src/network/Session.cpp - src/client/PlayerAction.cpp - src/ui/GameUI.cpp ) target_link_libraries(uno-game-lib PUBLIC nlohmann_json::nlohmann_json) target_link_libraries(uno-game-lib PUBLIC asio::asio) target_link_libraries(uno-game-lib PUBLIC Slint::Slint) +target_link_libraries(uno-game-lib PRIVATE argparse::argparse) slint_target_sources(uno-game-lib ui/MainWindow.slint) +# Uno Client add_executable(uno-client src/client/main.cpp + src/client/PlayerAction.cpp + src/client/UnoClient.cpp + src/ui/GameUI.cpp assets/uno.rc ) target_link_libraries(uno-client PRIVATE uno-game-lib) @@ -40,11 +43,24 @@ if (WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") set_target_properties(uno-client PROPERTIES WIN32_EXECUTABLE ON) endif () + +# Uno Server add_executable(uno-server src/server/main.cpp + src/server/UnoServer.cpp assets/uno.rc ) target_link_libraries(uno-server PRIVATE uno-game-lib) -target_link_libraries(uno-server PRIVATE argparse::argparse) -add_subdirectory(test) \ No newline at end of file +# Google Test +add_subdirectory(test) + +# 复制动态库 +foreach (target uno-client uno-server) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMAND_EXPAND_LISTS + ) +endforeach () \ No newline at end of file