From 354e0ba42e2babdb59412b2bf4290fb86c68c7f7 Mon Sep 17 00:00:00 2001 From: Zheng Qu Date: Mon, 14 Oct 2024 12:45:07 +0200 Subject: [PATCH] Support MacOS (#365) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过这个PR,FreeKill可以在MacOS上编译运行。 在repo根目录运行 `./build/FreeKill`,游戏可玩,有背景音,但是出牌语音似乎没了。是我的运行方式有问题么? --- docs/inner/01-compile.rst | 20 +++++++++++++++++++- lang/en_US.ts | 2 +- lang/zh_CN.ts | 2 +- src/CMakeLists.txt | 24 ++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/docs/inner/01-compile.rst b/docs/inner/01-compile.rst index b50bda55..36df95b8 100644 --- a/docs/inner/01-compile.rst +++ b/docs/inner/01-compile.rst @@ -98,7 +98,25 @@ Linux服务器 MacOS ----- -大致与Windows类似,但尚且缺少确切的方案。 +安装依赖: + +.. code:: sh + + $ brew install libgit2 swig qt lua + +更新submodule: + +.. code:: sh + + $ git submodule update --init --recursive + +然后使用命令行编译: + +.. code:: sh + + $ mkdir build && cd build + $ cmake .. + $ make -j8 -------------- diff --git a/lang/en_US.ts b/lang/en_US.ts index dc62d504..fcb29b43 100644 --- a/lang/en_US.ts +++ b/lang/en_US.ts @@ -1,4 +1,4 @@ - + Init diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts index 9133b542..c9dd612b 100644 --- a/lang/zh_CN.ts +++ b/lang/zh_CN.ts @@ -1,4 +1,4 @@ - + ClientSocket diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 566bcec7..5ecec622 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,6 +63,30 @@ elseif (ANDROID) QT_ANDROID_EXTRA_LIBS "${LUA_LIB};${SQLITE3_LIB};${CRYPTO_LIB};${SSL_LIB};${SSH_LIB};${GIT_LIB}" ) list(REMOVE_ITEM QT_LIB Qt6::QuickControls2) +elseif (APPLE) + set(LUA_LIB ${LUA_LIBRARIES}) + set(SQLITE3_LIB sqlite3) + set(CRYPTO_LIB OpenSSL::Crypto) + set(READLINE_LIB readline) + + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/opt/homebrew/Cellar/libgit2") + find_package(PkgConfig) + if (PkgConfig_FOUND) + pkg_check_modules(LIBGIT2 libgit2) + if (LIBGIT2_FOUND) + message(STATUS "Found libgit2: ${LIBGIT2_LIBRARIES}") + else () + message(WARNING "libgit2 not found, try to find libgit2 by CMake") + find_package(LibGit2) + endif () + else () + message(WARNING "PkgConfig not found, try to find libgit2 by CMake") + find_package(LibGit2) + endif () + set(GIT_LIB ${LIBGIT2_LIBRARIES}) + target_link_directories(FreeKill PRIVATE + ${LIBGIT2_LIBRARY_DIRS} + ) else () set(LUA_LIB lua5.4) set(SQLITE3_LIB sqlite3)