vpn: add Windows linker flags + manifest embedding to cmake
This commit is contained in:
parent
c6ec61ef9c
commit
9086f45de2
1 changed files with 60 additions and 11 deletions
|
|
@ -4,18 +4,35 @@
|
||||||
#
|
#
|
||||||
# include(app/vpn/CMakeLists_vpn.cmake)
|
# include(app/vpn/CMakeLists_vpn.cmake)
|
||||||
#
|
#
|
||||||
# Prerequisites:
|
# Prerequisites (per platform):
|
||||||
# Run scripts/build-boringtun.sh first to produce deps/boringtun/libboringtun.a
|
# macOS : bash scripts/build-boringtun.sh --universal
|
||||||
|
# Windows: pwsh scripts/build-boringtun-win.ps1
|
||||||
|
# Linux : bash scripts/build-boringtun.sh
|
||||||
|
#
|
||||||
|
# The build scripts drop the static library at:
|
||||||
|
# macOS/Linux : deps/boringtun/libboringtun.a
|
||||||
|
# Windows : deps/boringtun/boringtun.lib
|
||||||
|
|
||||||
# ─── boringtun static library ─────────────────────────────────────────────────
|
# ─── boringtun static library ─────────────────────────────────────────────────
|
||||||
|
|
||||||
set(BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/libboringtun.a")
|
if(WIN32)
|
||||||
|
set(BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/boringtun.lib")
|
||||||
|
else()
|
||||||
|
set(BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/libboringtun.a")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT EXISTS "${BORINGTUN_LIB}")
|
if(NOT EXISTS "${BORINGTUN_LIB}")
|
||||||
|
if(WIN32)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"boringtun static library not found at ${BORINGTUN_LIB}\n"
|
||||||
|
"Run: pwsh scripts/build-boringtun-win.ps1\n"
|
||||||
|
"then re-run CMake.")
|
||||||
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"boringtun static library not found at ${BORINGTUN_LIB}\n"
|
"boringtun static library not found at ${BORINGTUN_LIB}\n"
|
||||||
"Run: bash scripts/build-boringtun.sh --universal\n"
|
"Run: bash scripts/build-boringtun.sh --universal\n"
|
||||||
"then re-run CMake.")
|
"then re-run CMake.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(boringtun STATIC IMPORTED)
|
add_library(boringtun STATIC IMPORTED)
|
||||||
|
|
@ -33,12 +50,12 @@ set(VPN_SOURCES
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_mac.mm)
|
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_mac.mm)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_win.cpp) # future
|
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_win.cpp)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_linux.cpp) # future
|
list(APPEND VPN_SOURCES app/vpn/tunnelmanager_linux.cpp) # future
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ─── Integration into moonlight-qt target ────────────────────────────────────
|
# ─── Integration into moonlight-qt target ─────────────────────────────────────
|
||||||
# Replace moonlight-qt below with whatever your top-level CMakeLists calls the app target.
|
# Replace moonlight-qt below with whatever your top-level CMakeLists calls the app target.
|
||||||
|
|
||||||
target_sources(moonlight-qt PRIVATE ${VPN_SOURCES})
|
target_sources(moonlight-qt PRIVATE ${VPN_SOURCES})
|
||||||
|
|
@ -50,15 +67,47 @@ target_include_directories(moonlight-qt PRIVATE
|
||||||
target_link_libraries(moonlight-qt PRIVATE boringtun)
|
target_link_libraries(moonlight-qt PRIVATE boringtun)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# Frameworks required by boringtun on macOS
|
# Frameworks required by boringtun + tunnel implementation on macOS
|
||||||
target_link_libraries(moonlight-qt PRIVATE
|
target_link_libraries(moonlight-qt PRIVATE
|
||||||
"-framework Security"
|
"-framework Security"
|
||||||
"-framework Network"
|
"-framework Network"
|
||||||
"-framework SystemConfiguration"
|
"-framework SystemConfiguration"
|
||||||
)
|
)
|
||||||
# Objective-C++ needed for tunnelmanager_mac.mm
|
# Objective-C++ ARC needed for tunnelmanager_mac.mm
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
app/vpn/tunnelmanager_mac.mm
|
app/vpn/tunnelmanager_mac.mm
|
||||||
PROPERTIES COMPILE_FLAGS "-fobjc-arc"
|
PROPERTIES COMPILE_FLAGS "-fobjc-arc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
elseif(WIN32)
|
||||||
|
# Windows system libraries required by Wintun + IP Helper API + Winsock
|
||||||
|
# iphlpapi — CreateUnicastIpAddressEntry, CreateIpForwardEntry2
|
||||||
|
# ws2_32 — socket, sendto, recvfrom, WSAEventSelect, …
|
||||||
|
# ntdll — required by boringtun's ring0 primitives
|
||||||
|
# ole32 — CoCreateGuid (adapter GUID)
|
||||||
|
target_link_libraries(moonlight-qt PRIVATE
|
||||||
|
iphlpapi
|
||||||
|
ws2_32
|
||||||
|
ntdll
|
||||||
|
ole32
|
||||||
|
)
|
||||||
|
|
||||||
|
# Embed the UAC manifest so Windows prompts for elevation at launch.
|
||||||
|
# Visual Studio picks this up automatically; for Ninja/MSBuild add
|
||||||
|
# a custom command that runs mt.exe post-link.
|
||||||
|
if(MSVC)
|
||||||
|
set_target_properties(moonlight-qt PROPERTIES
|
||||||
|
LINK_FLAGS "/MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_SOURCE_DIR}/app/DragonMoonlight.manifest"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# MinGW: link the manifest as a resource
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_SOURCE_DIR}/app/DragonMoonlight.manifest"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/DragonMoonlight.manifest"
|
||||||
|
COPYONLY
|
||||||
|
)
|
||||||
|
target_sources(moonlight-qt PRIVATE
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/DragonMoonlight.manifest"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue