From 343f2c87912b0fd07f6254e054834213d96e1d7c Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Wed, 6 May 2026 19:21:11 -0400 Subject: [PATCH] =?UTF-8?q?cmake:=20WireGuard=20module=20for=20Artemis=20?= =?UTF-8?q?=E2=80=94=20boringtun=20+=20platform=20dispatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/wg.cmake | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cmake/wg.cmake diff --git a/cmake/wg.cmake b/cmake/wg.cmake new file mode 100644 index 0000000..7d29163 --- /dev/null +++ b/cmake/wg.cmake @@ -0,0 +1,77 @@ +# cmake/wg.cmake — WireGuard client integration for Artemis (Sunshine fork). +# +# Include from the top-level CMakeLists.txt: +# +# include(cmake/wg.cmake) +# artemis_wg_configure(sunshine) # pass the name of your app target +# +# Prerequisites: +# Run scripts/build-boringtun.sh (Linux/macOS) or +# scripts/build-boringtun-win.ps1 (Windows) +# to produce deps/boringtun/libboringtun.a (or .lib on Windows). + +# ─── boringtun static library ───────────────────────────────────────────────── + +if(WIN32) + set(ARTEMIS_BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/boringtun.lib") +else() + set(ARTEMIS_BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/libboringtun.a") +endif() + +if(NOT EXISTS "${ARTEMIS_BORINGTUN_LIB}") + message(FATAL_ERROR + "boringtun library not found at ${ARTEMIS_BORINGTUN_LIB}\n" + "Run the appropriate build script in scripts/ and re-run CMake.") +endif() + +add_library(artemis_boringtun STATIC IMPORTED GLOBAL) +set_target_properties(artemis_boringtun PROPERTIES + IMPORTED_LOCATION "${ARTEMIS_BORINGTUN_LIB}" +) + +# ─── WireGuard source files ─────────────────────────────────────────────────── + +set(ARTEMIS_WG_SOURCES + src/wg/wgconfig.cpp + src/wg/relayreg.cpp +) + +if(WIN32) + list(APPEND ARTEMIS_WG_SOURCES src/wg/wgclient_win.cpp) +elseif(UNIX AND NOT APPLE) + list(APPEND ARTEMIS_WG_SOURCES src/wg/wgclient_linux.cpp) +elseif(APPLE) + # macOS: future — use utun approach from DragonMoonlight if needed + message(WARNING "Artemis WireGuard client not yet implemented for macOS") +endif() + +# ─── Configuration function ─────────────────────────────────────────────────── + +function(artemis_wg_configure TARGET) + target_sources(${TARGET} PRIVATE ${ARTEMIS_WG_SOURCES}) + + target_include_directories(${TARGET} PRIVATE + "${CMAKE_SOURCE_DIR}/src/wg" + "${CMAKE_SOURCE_DIR}/deps/boringtun" # boringtun_ffi.h + ) + + target_link_libraries(${TARGET} PRIVATE artemis_boringtun) + + # libcurl (already a Sunshine dependency) + find_package(CURL REQUIRED) + target_link_libraries(${TARGET} PRIVATE CURL::libcurl) + + if(WIN32) + target_link_libraries(${TARGET} PRIVATE + iphlpapi ws2_32 ntdll ole32 + ) + elseif(UNIX AND NOT APPLE) + # pthread for std::thread on Linux + target_link_libraries(${TARGET} PRIVATE pthread) + endif() + + # Enable the WireGuard relay feature in Artemis source + target_compile_definitions(${TARGET} PRIVATE ARTEMIS_RELAY_ENABLED=1) + + message(STATUS "Artemis: WireGuard relay client enabled for target '${TARGET}'") +endfunction()