Phase 0 makes implementations that already existed reachable. macOS now declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a new bit and Linux declares it too. SystemManager was dead code -- its constructor took a second argument and it did not derive IOCPManager, so the sub-connection skeleton could never instantiate it -- and now matches the createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user, so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC for exec_command / terminal_* and for SupportsProcess() for kill_process, so an old build gets "client is too old" instead of a command nobody answers; kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the terminal works on macOS, but the probe uses GNU-only base64 -w. Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage, scales and ships BGRX for the server to encode, and the capability is only declared when preflight or a real capture says the display is readable. ActivityHistory samples the frontmost layer-0 window once a second and prints the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the receive thread raises a flag, the capture thread -- which owns the encoder -- consumes it and puts it back if the frame never went out. The macOS quality level persists in NSUserDefaults because main.mm rewrites config.conf. Linux client and Debug x64 server rebuild green; check_platform_table PASS. Not built or run on a Mac. Co-Authored-By: deepseek-flash
131 lines
5.0 KiB
CMake
131 lines
5.0 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
||
project(ghost_macos)
|
||
|
||
set(CMAKE_CXX_STANDARD 17)
|
||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||
|
||
# macOS deployment target。arm64 的底线就是 11.0(Apple Silicon 首发系统),
|
||
# 与 Homebrew openssl@3 自身的最低版本一致,避免链接时出现 "built for newer" 告警。
|
||
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version")
|
||
|
||
# 只构建 Apple Silicon。仓库里发布过的 macos/ghost 一直是 arm64-only(universal 设置从未
|
||
# 真正落地),且 Homebrew 的 OpenSSL 是单架构——保留 x86_64 slice 会让链接直接失败。
|
||
# 将来真要支持 Intel Mac,应单独用 x86_64 的 OpenSSL 构建一份,而不是把这里改回 universal。
|
||
# 注意 CMAKE_OSX_ARCHITECTURES 是 cache 变量:旧 build 目录里存的值不会因这里改字面量而
|
||
# 更新,build.sh 因此显式传 -DCMAKE_OSX_ARCHITECTURES=arm64。
|
||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures (arm64 only)")
|
||
|
||
include_directories(../)
|
||
include_directories(../client)
|
||
include_directories(../compress)
|
||
|
||
# Source files
|
||
set(SOURCES
|
||
main.mm
|
||
../client/Buffer.cpp
|
||
../client/IOCPClient.cpp
|
||
# TLS 传输(OpenSSL 实现,与 Linux/Android 共用)。文件名叫 Linux 是历史原因,
|
||
# 平台守卫为 __linux__ || __APPLE__;macOS 的差异只有 ExeDir() 用 _NSGetExecutablePath。
|
||
../client/TlsChannelLinux.cpp
|
||
../client/sign_shim_unix.cpp
|
||
ScreenHandler.mm
|
||
ScreenPreview.mm
|
||
ActivityHistory.mm
|
||
InputHandler.mm
|
||
SystemManager.mm
|
||
Permissions.mm
|
||
H264Encoder.mm
|
||
)
|
||
|
||
# Create executable
|
||
add_executable(ghost ${SOURCES})
|
||
|
||
# Include directories
|
||
target_include_directories(ghost PRIVATE
|
||
${CMAKE_CURRENT_SOURCE_DIR}
|
||
)
|
||
|
||
# Find and link macOS frameworks
|
||
find_library(COCOA_FRAMEWORK Cocoa REQUIRED)
|
||
find_library(COREGRAPHICS_FRAMEWORK CoreGraphics REQUIRED)
|
||
find_library(IOKIT_FRAMEWORK IOKit REQUIRED)
|
||
find_library(IOSURFACE_FRAMEWORK IOSurface REQUIRED)
|
||
find_library(APPLICATIONSERVICES_FRAMEWORK ApplicationServices REQUIRED)
|
||
find_library(SECURITY_FRAMEWORK Security REQUIRED)
|
||
find_library(CARBON_FRAMEWORK Carbon REQUIRED)
|
||
find_library(VIDEOTOOLBOX_FRAMEWORK VideoToolbox REQUIRED)
|
||
find_library(COREMEDIA_FRAMEWORK CoreMedia REQUIRED)
|
||
find_library(COREVIDEO_FRAMEWORK CoreVideo REQUIRED)
|
||
find_library(ACCELERATE_FRAMEWORK Accelerate REQUIRED)
|
||
find_library(ICONV_LIBRARY iconv REQUIRED)
|
||
|
||
# ---- OpenSSL(TLS 传输,见 client/TlsChannelLinux.cpp)----
|
||
# macOS 不自带 OpenSSL。优先用 Homebrew 的 openssl@3;也可显式指定
|
||
# cmake .. -DOPENSSL_ROOT_DIR=/path/to/openssl
|
||
# Apple Silicon 的 Homebrew 前缀是 /opt/homebrew,Intel 是 /usr/local。
|
||
if(NOT OPENSSL_ROOT_DIR)
|
||
foreach(_openssl_candidate
|
||
/opt/homebrew/opt/openssl@3
|
||
/usr/local/opt/openssl@3
|
||
/opt/homebrew/opt/openssl
|
||
/usr/local/opt/openssl)
|
||
if(EXISTS "${_openssl_candidate}/include/openssl/ssl.h")
|
||
set(OPENSSL_ROOT_DIR "${_openssl_candidate}")
|
||
break()
|
||
endif()
|
||
endforeach()
|
||
endif()
|
||
if(NOT OPENSSL_ROOT_DIR)
|
||
message(FATAL_ERROR
|
||
"找不到 OpenSSL。先执行: brew install openssl@3\n"
|
||
"或显式指定: cmake .. -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3")
|
||
endif()
|
||
|
||
# 有静态库就静态链接:产物保持单文件,install.sh 不需要打包 dylib 或修 @rpath。
|
||
# Homebrew 的 openssl@3 同时装 .a 和 .dylib;只有动态库时这里退化为动态链接并告警,
|
||
# 那种情况下发布前必须把 libssl/libcrypto dylib 一并放进 .app 的 Contents/Frameworks。
|
||
if(EXISTS "${OPENSSL_ROOT_DIR}/lib/libssl.a" AND EXISTS "${OPENSSL_ROOT_DIR}/lib/libcrypto.a")
|
||
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
||
else()
|
||
message(WARNING
|
||
"OpenSSL 静态库不存在(${OPENSSL_ROOT_DIR}/lib/libssl.a),将动态链接;"
|
||
"发布前请确认目标 Mac 装有同一份 OpenSSL,或把 dylib 放进 Contents/Frameworks。")
|
||
endif()
|
||
find_package(OpenSSL REQUIRED)
|
||
message(STATUS "OpenSSL: ${OPENSSL_VERSION} (${OPENSSL_INCLUDE_DIR})")
|
||
|
||
target_link_libraries(ghost PRIVATE
|
||
${COCOA_FRAMEWORK}
|
||
${COREGRAPHICS_FRAMEWORK}
|
||
${IOKIT_FRAMEWORK}
|
||
${IOSURFACE_FRAMEWORK}
|
||
${APPLICATIONSERVICES_FRAMEWORK}
|
||
${SECURITY_FRAMEWORK}
|
||
${CARBON_FRAMEWORK}
|
||
${VIDEOTOOLBOX_FRAMEWORK}
|
||
${COREMEDIA_FRAMEWORK}
|
||
${COREVIDEO_FRAMEWORK}
|
||
${ACCELERATE_FRAMEWORK}
|
||
${ICONV_LIBRARY}
|
||
"${CMAKE_SOURCE_DIR}/lib/libzstd.a"
|
||
# 私有签名库(提供 signMessage / verifyMessage,源码不开源)
|
||
# 该库由 SimplePlugins 仓库本地构建后放置于 lib/,构建机需先准备好
|
||
# libsign.a 内部使用 macOS CommonCrypto(HMAC-SHA256),CCHmac 在 libSystem
|
||
# 中已被 Cocoa/CoreFoundation 等链接自动引入,故此处无需额外 framework
|
||
"${CMAKE_SOURCE_DIR}/lib/libsign.a"
|
||
OpenSSL::SSL
|
||
OpenSSL::Crypto
|
||
)
|
||
|
||
# Compiler flags
|
||
target_compile_options(ghost PRIVATE
|
||
-Wall
|
||
-Wextra
|
||
-fobjc-arc
|
||
)
|
||
|
||
# Output directory
|
||
set_target_properties(ghost PROPERTIES
|
||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||
)
|