diff --git a/app/vpn/CMakeLists_vpn.cmake b/app/vpn/CMakeLists_vpn.cmake new file mode 100644 index 0000000..8eb7491 --- /dev/null +++ b/app/vpn/CMakeLists_vpn.cmake @@ -0,0 +1,64 @@ +# app/vpn/CMakeLists_vpn.cmake +# +# Include this file from the top-level moonlight-qt CMakeLists.txt: +# +# include(app/vpn/CMakeLists_vpn.cmake) +# +# Prerequisites: +# Run scripts/build-boringtun.sh first to produce deps/boringtun/libboringtun.a + +# ─── boringtun static library ───────────────────────────────────────────────── + +set(BORINGTUN_LIB "${CMAKE_SOURCE_DIR}/deps/boringtun/libboringtun.a") + +if(NOT EXISTS "${BORINGTUN_LIB}") + message(FATAL_ERROR + "boringtun static library not found at ${BORINGTUN_LIB}\n" + "Run: bash scripts/build-boringtun.sh --universal\n" + "then re-run CMake.") +endif() + +add_library(boringtun STATIC IMPORTED) +set_target_properties(boringtun PROPERTIES + IMPORTED_LOCATION "${BORINGTUN_LIB}" +) + +# ─── VPN source files ────────────────────────────────────────────────────────── + +set(VPN_SOURCES + app/vpn/wireguardconfig.cpp + app/vpn/relayclient.cpp +) + +if(APPLE) + list(APPEND VPN_SOURCES app/vpn/tunnelmanager_mac.mm) +elseif(WIN32) + list(APPEND VPN_SOURCES app/vpn/tunnelmanager_win.cpp) # future +elseif(UNIX) + list(APPEND VPN_SOURCES app/vpn/tunnelmanager_linux.cpp) # future +endif() + +# ─── Integration into moonlight-qt target ──────────────────────────────────── +# Replace moonlight-qt below with whatever your top-level CMakeLists calls the app target. + +target_sources(moonlight-qt PRIVATE ${VPN_SOURCES}) + +target_include_directories(moonlight-qt PRIVATE + "${CMAKE_SOURCE_DIR}/app/vpn" +) + +target_link_libraries(moonlight-qt PRIVATE boringtun) + +if(APPLE) + # Frameworks required by boringtun on macOS + target_link_libraries(moonlight-qt PRIVATE + "-framework Security" + "-framework Network" + "-framework SystemConfiguration" + ) + # Objective-C++ needed for tunnelmanager_mac.mm + set_source_files_properties( + app/vpn/tunnelmanager_mac.mm + PROPERTIES COMPILE_FLAGS "-fobjc-arc" + ) +endif()