From a65764dd5ba668242dfc19204fb5eefc1d3ac6db Mon Sep 17 00:00:00 2001 From: taynpg Date: Sat, 5 Jul 2025 23:26:12 +0800 Subject: [PATCH] build: change to xmake mgr. --- .gitignore | 4 +- .vscode/settings.json | 41 ++---------- 3rd/SingleApplication-3.5.2/xmake.lua | 31 +++++++++ CMakeLists.txt | 81 ----------------------- ClientCore/CMakeLists.txt | 31 --------- ClientCore/xmake.lua | 12 ++++ Console/CMakeLists.txt | 22 ------- Console/main.cpp | 4 +- Console/xmake.lua | 15 +++++ Gui/CMakeLists.txt | 93 --------------------------- Gui/frelayGUI.cpp | 2 +- Gui/main.cpp | 4 +- Gui/xmake.lua | 28 ++++++++ Protocol/CMakeLists.txt | 22 ------- Protocol/xmake.lua | 9 +++ Server/CMakeLists.txt | 22 ------- Server/xmake.lua | 15 +++++ Struct/CMakeLists.txt | 27 -------- Struct/xmake.lua | 8 +++ Test/CMakeLists.txt | 24 ------- Test/xmake.lua | 18 ++++++ Util/CMakeLists.txt | 17 ----- Util/xmake.lua | 9 +++ crashelper/CMakeLists.txt | 38 ----------- crashelper/xmake.lua | 7 ++ version.h.in | 17 +++-- xmake.lua | 43 +++++++++++++ 27 files changed, 220 insertions(+), 424 deletions(-) create mode 100644 3rd/SingleApplication-3.5.2/xmake.lua delete mode 100644 CMakeLists.txt delete mode 100644 ClientCore/CMakeLists.txt create mode 100644 ClientCore/xmake.lua delete mode 100644 Console/CMakeLists.txt create mode 100644 Console/xmake.lua delete mode 100644 Gui/CMakeLists.txt create mode 100644 Gui/xmake.lua delete mode 100644 Protocol/CMakeLists.txt create mode 100644 Protocol/xmake.lua delete mode 100644 Server/CMakeLists.txt create mode 100644 Server/xmake.lua delete mode 100644 Struct/CMakeLists.txt create mode 100644 Struct/xmake.lua delete mode 100644 Test/CMakeLists.txt create mode 100644 Test/xmake.lua delete mode 100644 Util/CMakeLists.txt create mode 100644 Util/xmake.lua delete mode 100644 crashelper/CMakeLists.txt create mode 100644 crashelper/xmake.lua create mode 100644 xmake.lua diff --git a/.gitignore b/.gitignore index bea2ad5..7cc0bdf 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,6 @@ cmake-* .idea .vs .cache -xpbuild \ No newline at end of file +xpbuild +.xmake +compile_commands.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index e3aa522..f064982 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,41 +3,14 @@ "editor.fontSize": 14, // "editor.fontFamily": "'Source Code Pro', 'Source Code Pro', 'Source Code Pro'", "terminal.integrated.fontFamily": "Source Code Pro", - "cmake.configureOnOpen": true, - "cmake.debugConfig": { - "console": "integratedTerminal", - "setupCommands": [ - { - "description": "-gdb-set charset utf-8", - "text": "-gdb-set charset UTF-8" - }, - { - "description": "Enable gdb pretty-printing", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "visualizerFile": "${workspaceRoot}/.vscode/qt5.natvis", - "args": ["127.0.0.1", "9009"] - }, - "cmake.configureArgs": [ - "-Wno-dev" - ], - "cmake.environment": { - "QT_LIB_ROOT": "/home/yun/Qt5.14.2/5.14.2/gcc_64", - "PATH": "${env:PATH};/home/yun/Qt5.14.2/5.14.2/gcc_64/bin" - }, - "cmake.configureSettings": { - "CMAKE_PREFIX_PATH": "${env:QT_LIB_ROOT}", - "QT_DEFAULT_MAJOR_VERSION": "5", - "COMPILE_GUI": "ON" - }, - "cmake.options.statusBarVisibility": "visible", - "cmake.generator": "Ninja", - "C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json", - "C_Cpp.default.cppStandard": "c++17", - "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", + "cmake.configureOnOpen": false, + "C_Cpp.default.compileCommands": "${workspaceRoot}/.vscode/compile_commands.json", + "C_Cpp.default.cppStandard": "c++11", "editor.inlayHints.enabled": "off", + "xmake.additionalConfigArguments": [ + "--qt=C:/Qt/6.8.3", + "--gui=y" + ], "editor.unicodeHighlight.allowedLocales": { "ja": true, "zh-hant": true, diff --git a/3rd/SingleApplication-3.5.2/xmake.lua b/3rd/SingleApplication-3.5.2/xmake.lua new file mode 100644 index 0000000..9dfd90f --- /dev/null +++ b/3rd/SingleApplication-3.5.2/xmake.lua @@ -0,0 +1,31 @@ +add_rules("mode.debug", "mode.release") + +target("SingleApplication") + add_rules("qt.static") + if has_config("single5") then + add_defines("QT_DEFAULT_MAJOR_VERSION=5") + else + add_defines("QT_DEFAULT_MAJOR_VERSION=6") + end + -- QApplication/QGuiApplication/QCoreApplication + add_defines("QAPPLICATION_CLASS=QApplication") + add_defines("QT_NO_CAST_TO_ASCII") + add_defines("QT_NO_CAST_FROM_ASCII") + add_defines("QT_NO_URL_CAST_FROM_STRING") + add_defines("QT_NO_CAST_FROM_BYTEARRAY") + add_defines("QT_USE_QSTRINGBUILDER") + add_defines("QT_NO_NARROWING_CONVERSIONS_IN_CONNECT") + add_defines("QT_NO_KEYWORDS") + add_defines("QT_NO_FOREACH") + add_includedirs(".", {public = true}) + add_files("*.h") + add_files("*.cpp") + add_frameworks("QtCore") + add_frameworks("QtGui") + add_frameworks("QtWidgets") + add_frameworks("QtNetwork") + +option("single5") + set_default(false) + set_showmenu(true) + set_description("SingleApplication Build with Qt5.") \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index cb12a1f..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(frelay VERSION 0.2.1 LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(PROJECT_URL "https://github.com/taynpg/frelay") - -if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION) -set(QT_DEFAULT_MAJOR_VERSION 6) -endif() - -set(QAPPLICATION_CLASS QApplication) - -if (MSVC) -add_compile_options(/utf-8) -endif() - -if(DEFINED CMAKE_PREFIX_PATH) -message(STATUS "CMAKE_PREFIX_PATH => ${CMAKE_PREFIX_PATH}.") -endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") -message(STATUS "frelay use MINGW compiler.") -set(COMPILER_USE_MINGW ON) -add_definitions(-DCOMPILER_USE_MINGW) -endif() - -if(WIN32) -if(DEFINED XP_PLATFORM_SUPPORT) -message(STATUS "Support Windows XP platform => ${XP_PLATFORM_SUPPORT}.") -add_definitions(-D_WIN32_WINNT=0x0501) -else() -add_definitions(-D_WIN32_WINNT=0x0601) -endif() -endif() - -set(CMAKE_DEBUG_POSTFIX "d") -include_directories(${CMAKE_SOURCE_DIR}/Gui/Control) -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/) -include_directories(${PROJECT_BINARY_DIR}) - -add_definitions(-DFMT_HEADER_ONLY) -include_directories(3rd) - -if(NOT DEFINED COMPILER_USE_MINGW) -add_subdirectory(crashelper) -endif() - -add_subdirectory(Protocol) -add_subdirectory(Server) -add_subdirectory(ClientCore) - -add_subdirectory(Util) -if(DEFINED COMPILE_GUI) -message(STATUS "Support Gui Part => ${COMPILE_GUI}.") -add_subdirectory(3rd/SingleApplication-3.5.2) -add_subdirectory(Gui) -endif() - -add_subdirectory(Console) -add_subdirectory(Struct) -add_subdirectory(Test) - -execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_GIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE -) -configure_file(version.h.in fversion.h) -message(STATUS "${CMAKE_SYSTEM_NAME} build dir:${PROJECT_BINARY_DIR}") -message(STATUS "VERSION_GIT_BRANCH: ${VERSION_GIT_BRANCH}") -message(STATUS "VERSION_GIT_HASH: ${VERSION_GIT_HASH}") diff --git a/ClientCore/CMakeLists.txt b/ClientCore/CMakeLists.txt deleted file mode 100644 index d206641..0000000 --- a/ClientCore/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(ClientCore LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) - -set(SOURCES -ClientCore.cpp -ClientCore.h -RemoteFile.h -RemoteFile.cpp -FileTrans.h -FileTrans.cpp -) - -add_library(ClientCore STATIC ${SOURCES}) -target_link_libraries(ClientCore PRIVATE Protocol - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::Network - Struct - Util -) -target_include_directories(ClientCore PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/ClientCore/xmake.lua b/ClientCore/xmake.lua new file mode 100644 index 0000000..1e568a9 --- /dev/null +++ b/ClientCore/xmake.lua @@ -0,0 +1,12 @@ +add_rules("mode.debug", "mode.release") + +target("ClientCore") + add_rules("qt.static") + add_includedirs(".", {public = true}) + add_files("*.h") + add_files("*.cpp") + add_frameworks("QtCore") + add_frameworks("QtNetwork") + add_deps("Struct") + add_deps("Util") + add_deps("Protocol") \ No newline at end of file diff --git a/Console/CMakeLists.txt b/Console/CMakeLists.txt deleted file mode 100644 index 06fcdcd..0000000 --- a/Console/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(frelayConsole LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) - -add_executable(frelayConsole Console.h Console.cpp main.cpp ../Res/ico.rc) -target_link_libraries(frelayConsole PRIVATE Protocol Util ClientCore) - -if(NOT DEFINED COMPILER_USE_MINGW) -target_link_libraries(frelayConsole PRIVATE crashelper) -endif() - -target_link_libraries(frelayConsole PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) diff --git a/Console/main.cpp b/Console/main.cpp index c7dbce7..f5de00f 100644 --- a/Console/main.cpp +++ b/Console/main.cpp @@ -4,7 +4,7 @@ #include "Console.h" -#ifndef COMPILER_USE_MINGW +#ifndef NO_CRASHELPER #include #endif @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) return 0; } -#ifndef COMPILER_USE_MINGW +#ifndef NO_CRASHELPER auto configDir = Util::GetCurConfigPath("frelay"); #ifdef _WIN32 backward::SetDumpFileSavePath(configDir + "/dumpfile"); diff --git a/Console/xmake.lua b/Console/xmake.lua new file mode 100644 index 0000000..6e51388 --- /dev/null +++ b/Console/xmake.lua @@ -0,0 +1,15 @@ +add_rules("mode.debug", "mode.release") + +target("frelayConsole") + set_rules("qt.console") + add_files("../Res/ico.rc") + add_files("Console.cpp", "Console.h", "main.cpp") + add_deps("ClientCore") + add_deps("Protocol") + add_deps("Util") + add_frameworks("QtNetwork") + + if is_plat("mingw") then + else + add_deps("crashelper") + end \ No newline at end of file diff --git a/Gui/CMakeLists.txt b/Gui/CMakeLists.txt deleted file mode 100644 index 4876b3b..0000000 --- a/Gui/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(frelayGUI VERSION ${PROJECT_VERSION} LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -add_definitions(-DUSE_QT_GUI) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -set(PROJECT_SOURCES main.cpp -frelayGUI.cpp frelayGUI.h frelayGUI.ui -Control/LogControl.h Control/LogControl.cpp Control/LogControl.ui -Control/FileControl.h Control/FileControl.cpp Control/FileControl.ui -Control/ConnectControl.h Control/ConnectControl.cpp Control/ConnectControl.ui -Control/CompareControl.h Control/CompareControl.cpp Control/CompareControl.ui -GuiUtil/Public.h GuiUtil/Public.cpp -Form/Transform.h Form/Transform.cpp Form/Transform.ui -../Res/frelay.qrc ../Res/ico.rc -Control/cusTableWidget.cpp Control/cusTableWidget.h -Control/cpTableWidget.h Control/cpTableWidget.cpp -GuiUtil/Config.h GuiUtil/Config.cpp -) - -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(frelayGUI - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ) -# Define target properties for Android with Qt 6 as: -# set_property(TARGET frelayGUI APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR -# ${CMAKE_CURRENT_SOURCE_DIR}/android) -# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation -else() - if(ANDROID) - add_library(frelayGUI SHARED - ${PROJECT_SOURCES} - ) -# Define properties for Android with Qt 5 after find_package() calls as: -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") - else() - add_executable(frelayGUI - ${PROJECT_SOURCES} - ) - endif() -endif() - -target_link_libraries(frelayGUI PRIVATE - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Network - ClientCore Protocol - Util - Struct SingleApplication::SingleApplication -) - -if(NOT DEFINED COMPILER_USE_MINGW) -target_link_libraries(frelayGUI PRIVATE crashelper) -endif() - -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") - target_link_libraries(frelayGUI PRIVATE ws2_32 wsock32) -endif() - -# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. -# If you are developing for iOS or macOS you should consider setting an -# explicit, fixed bundle identifier manually though. -if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.frelayGUI) -endif() -set_target_properties(frelayGUI PROPERTIES - ${BUNDLE_ID_OPTION} - MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - MACOSX_BUNDLE TRUE - WIN32_EXECUTABLE TRUE -) - -include(GNUInstallDirs) -install(TARGETS frelayGUI - BUNDLE DESTINATION . - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) - -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(frelayGUI) -endif() diff --git a/Gui/frelayGUI.cpp b/Gui/frelayGUI.cpp index bc1482a..682510e 100644 --- a/Gui/frelayGUI.cpp +++ b/Gui/frelayGUI.cpp @@ -28,7 +28,7 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU int height = static_cast(availableGeometry.height() * 0.6); resize(width, height); - setWindowTitle(QString(tr("frelay %1")).arg(VERSION_NUM)); + setWindowTitle(QString(tr("frelay %1.%2.%3.%4")).arg(VERSION_MAJOR).arg(VERSION_MINOR).arg(VERSION_ALTER).arg(VERSION_BUILD)); QLabel* permanent = new QLabel(this); permanent->setFrameStyle(QFrame::Box | QFrame::Sunken); diff --git a/Gui/main.cpp b/Gui/main.cpp index bbaeda8..20ae9b0 100644 --- a/Gui/main.cpp +++ b/Gui/main.cpp @@ -5,14 +5,14 @@ #include "frelayGUI.h" -#ifndef COMPILER_USE_MINGW +#ifndef NO_CRASHELPER #include #endif int main(int argc, char* argv[]) { -#ifndef COMPILER_USE_MINGW +#ifndef NO_CRASHELPER auto configDir = Util::GetCurConfigPath("frelay"); #ifdef _WIN32 backward::SetDumpFileSavePath(configDir + "/dumpfile"); diff --git a/Gui/xmake.lua b/Gui/xmake.lua new file mode 100644 index 0000000..ba5b37f --- /dev/null +++ b/Gui/xmake.lua @@ -0,0 +1,28 @@ +add_rules("mode.debug", "mode.release") + +target("frelayGUI") + add_rules("qt.widgetapp") + add_defines("QAPPLICATION_CLASS=QApplication") + add_includedirs(".", {public = true}) + add_files("Control/*.h") + add_files("Form/*.h") + add_files("GuiUtil/*.h") + add_files("Control/*.cpp") + add_files("Control/*.ui") + add_files("Form/*.cpp") + add_files("Form/*.ui") + add_files("GuiUtil/*.cpp") + add_files("*.cpp") + add_files("*.ui") + add_files("*.h") + add_files("../Res/frelay.qrc") + add_files("../Res/ico.rc") + add_frameworks("QtCore") + add_frameworks("QtGui") + add_frameworks("QtNetwork") + add_deps("Struct") + add_deps("Protocol") + add_deps("Util") + add_deps("ClientCore") + add_deps("SingleApplication") + add_deps("crashelper") \ No newline at end of file diff --git a/Protocol/CMakeLists.txt b/Protocol/CMakeLists.txt deleted file mode 100644 index 206f62f..0000000 --- a/Protocol/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(Protocol LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) - -set(SOURCES -Protocol.cxx -Protocol.h -) - -add_library(Protocol STATIC ${SOURCES}) -target_link_libraries(Protocol Qt${QT_VERSION_MAJOR}::Core Struct) -target_include_directories(Protocol PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Protocol/xmake.lua b/Protocol/xmake.lua new file mode 100644 index 0000000..2d6f9d3 --- /dev/null +++ b/Protocol/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") + +target("Protocol") + add_rules("qt.static") + add_includedirs(".", {public = true}) + add_files("*.cxx") + add_files("*.h") + add_deps("Struct") + add_frameworks("QtCore") diff --git a/Server/CMakeLists.txt b/Server/CMakeLists.txt deleted file mode 100644 index 308ef3c..0000000 --- a/Server/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(frelayServer LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) - -add_executable(frelayServer Server.h Server.cpp main.cpp ../Res/server.rc) -target_link_libraries(frelayServer PRIVATE Protocol Util) - -if(NOT DEFINED COMPILER_USE_MINGW) -target_link_libraries(frelayServer PRIVATE crashelper) -endif() - -target_link_libraries(frelayServer PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) \ No newline at end of file diff --git a/Server/xmake.lua b/Server/xmake.lua new file mode 100644 index 0000000..dbe1c9a --- /dev/null +++ b/Server/xmake.lua @@ -0,0 +1,15 @@ +add_rules("mode.debug", "mode.release") + +target("frelayServer") + set_rules("qt.console") + add_files("../Res/server.rc") + add_files("Server.cpp", "Server.h", "main.cpp") + add_deps("ClientCore") + add_deps("Protocol") + add_deps("Util") + add_frameworks("QtNetwork") + + if is_plat("mingw") then + else + add_deps("crashelper") + end \ No newline at end of file diff --git a/Struct/CMakeLists.txt b/Struct/CMakeLists.txt deleted file mode 100644 index a517f2e..0000000 --- a/Struct/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(Struct LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) - -set(SOURCES -InfoClient.h -InfoClient.cpp -InfoPack.hpp -InfoDirFile.h -InfoDirFile.cpp -InfoMsg.h -InfoMsg.cpp -) - -add_library(Struct STATIC ${SOURCES}) -target_link_libraries(Struct Qt${QT_VERSION_MAJOR}::Core) -target_include_directories(Struct PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Struct/xmake.lua b/Struct/xmake.lua new file mode 100644 index 0000000..5f90cbb --- /dev/null +++ b/Struct/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.debug", "mode.release") + +target("Struct") + add_rules("qt.static") + add_includedirs(".", {public = true}) + add_files("*.h") + add_files("*.cpp") + add_frameworks("QtCore") diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt deleted file mode 100644 index 0a31571..0000000 --- a/Test/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(frelayTest LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) - -set(MSOURCES -msgTest.h msgTest.cpp -protocolTest.cpp infoTest.h infoTest.cpp -) - -add_executable(frelayTest ${MSOURCES}) -target_link_libraries(frelayTest PRIVATE Protocol Util) - -add_executable(frelayBaseTest BaseTest.cpp) -target_link_libraries(frelayBaseTest Qt${QT_VERSION_MAJOR}::Core) diff --git a/Test/xmake.lua b/Test/xmake.lua new file mode 100644 index 0000000..8d774ce --- /dev/null +++ b/Test/xmake.lua @@ -0,0 +1,18 @@ +add_rules("mode.debug", "mode.release") + +target("frelayTest") + set_rules("qt.console") + add_files("msgTest.cpp", "msgTest.h", "protocolTest.cpp") + add_files("infoTest.cpp", "infoTest.h") + add_deps("ClientCore") + add_deps("Protocol") + add_deps("Util") + add_frameworks("QtNetwork") + +target("frelayBaseTest") + set_rules("qt.console") + add_files("BaseTest.cpp") + add_deps("ClientCore") + add_deps("Protocol") + add_deps("Util") + add_frameworks("QtNetwork") \ No newline at end of file diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt deleted file mode 100644 index 5d8717a..0000000 --- a/Util/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(Util LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) - -add_library(Util STATIC Util.h Util.cpp LocalFile.h LocalFile.cpp) -target_link_libraries(Util PRIVATE Qt${QT_VERSION_MAJOR}::Core Struct) -target_include_directories(Util PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Util/xmake.lua b/Util/xmake.lua new file mode 100644 index 0000000..24bf913 --- /dev/null +++ b/Util/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") + +target("Util") + add_rules("qt.static") + add_includedirs(".", {public = true}) + add_files("*.cpp") + add_files("*.h") + add_deps("Protocol") + add_frameworks("QtCore") diff --git a/crashelper/CMakeLists.txt b/crashelper/CMakeLists.txt deleted file mode 100644 index ad690a0..0000000 --- a/crashelper/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(crashelper LANGUAGES CXX) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") -message(FATAL_ERROR "Unsupported MinGW Currently.") -endif() - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) - -set(CRASHELPER_SOURCES -src/crashelper.cxx -) - -include_directories(include) -add_library(crashelper STATIC ${CRASHELPER_SOURCES}) - -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") -target_link_libraries(crashelper PUBLIC pthread dl bfd Qt${QT_VERSION_MAJOR}::Core) -target_compile_options(crashelper PUBLIC -g) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") -target_link_libraries(crashelper PUBLIC pthread dl bfd Qt${QT_VERSION_MAJOR}::Core) -target_compile_options(crashelper PUBLIC -g) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") -target_link_libraries(crashelper PRIVATE DbgHelp Qt${QT_VERSION_MAJOR}::Core) -target_compile_options(crashelper PUBLIC $<$,MSVC>,$,MSVC>>:/Zi>) -target_link_options(crashelper PUBLIC $<$,MSVC>,$,MSVC>>:/DEBUG>) -else() -message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}. This project only supports Linux, macOS, and Windows.") -endif() -#message(STATUS "crashelper:${CMAKE_CURRENT_LIST_DIR}") -target_include_directories(crashelper PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include) \ No newline at end of file diff --git a/crashelper/xmake.lua b/crashelper/xmake.lua new file mode 100644 index 0000000..31639a9 --- /dev/null +++ b/crashelper/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") + +target("crashelper") + add_rules("qt.static") + add_includedirs("include", {public = true}) + add_files("src/*.cxx") + add_frameworks("QtCore") diff --git a/version.h.in b/version.h.in index d06491c..e7503d4 100644 --- a/version.h.in +++ b/version.h.in @@ -1,9 +1,12 @@ -#ifndef VERSION_H -#define VERSION_H +#ifndef VERSION +#define VERSION -#define VERSION_GIT_COMMIT "@VERSION_GIT_HASH@" -#define VERSION_GIT_BRANCH "@VERSION_GIT_BRANCH@" -#define VERSION_NUM "@PROJECT_VERSION@" -#define VERSION_URL "@PROJECT_URL@" +#define VERSION_MAJOR ${VERSION_MAJOR} +#define VERSION_MINOR ${VERSION_MINOR} +#define VERSION_ALTER ${VERSION_ALTER} +#define VERSION_BUILD ${VERSION_BUILD} -#endif +#define VERSION_GIT_COMMIT "${GIT_COMMIT}" +#define VERSION_GIT_BRANCH "${GIT_BRANCH}" + +#endif \ No newline at end of file diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..1361a4b --- /dev/null +++ b/xmake.lua @@ -0,0 +1,43 @@ +add_rules("mode.debug", "mode.release") + +set_version("0.2.1", {build = "1"}) + +if is_plat("windows") then + add_cxflags("/utf-8") +end + +if is_plat("mingw") then + add_defines("NO_CRASHELPER=ON") +end + +if has_config("xp") then + add_defines("_WIN32_WINNT=0x0501") +else + add_defines("_WIN32_WINNT=0x0601") +end + +add_defines("FMT_HEADER_ONLY") +add_includedirs("3rd") + +if has_config("gui") then + includes("Gui", "3rd/SingleApplication-3.5.2") +end + +add_includedirs("$(builddir)") +add_configfiles("version.h.in", {filename = "fversion.h", outputdir = "$(builddir)"}) +includes("Struct", "Protocol", "Util", "ClientCore", "Console", "Server", "Test") + +if is_plat("mingw") then +else + includes("crashelper") +end + +option("xp") + set_default(false) + set_showmenu(true) + set_description("Enable Windows XP support") + +option("gui") + set_default(false) + set_showmenu(true) + set_description("Enable GUI support") \ No newline at end of file