# app/vpn/CMakeLists_vpn.cmake # # Include this file from the top-level moonlight-qt CMakeLists.txt: # # include(app/vpn/CMakeLists_vpn.cmake) # # Prerequisites (per platform): # 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 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(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.") elseif(APPLE) message(FATAL_ERROR "boringtun static library not found at ${BORINGTUN_LIB}\n" "Run: bash scripts/build-boringtun.sh --universal\n" "then re-run CMake.") else() message(FATAL_ERROR "boringtun static library not found at ${BORINGTUN_LIB}\n" "Run: bash scripts/build-boringtun.sh\n" "then re-run CMake.") endif() 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 app/vpn/dragonrelaybackend.cpp ) if(APPLE) list(APPEND VPN_SOURCES app/vpn/tunnelmanager_mac.mm) elseif(WIN32) list(APPEND VPN_SOURCES app/vpn/tunnelmanager_win.cpp) elseif(UNIX) list(APPEND VPN_SOURCES app/vpn/tunnelmanager_linux.cpp) 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) target_link_libraries(moonlight-qt PRIVATE "-framework Security" "-framework Network" "-framework SystemConfiguration" ) set_source_files_properties( app/vpn/tunnelmanager_mac.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc" ) elseif(WIN32) target_link_libraries(moonlight-qt PRIVATE iphlpapi ws2_32 ntdll ole32 ) if(MSVC) set_target_properties(moonlight-qt PROPERTIES LINK_FLAGS "/MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_SOURCE_DIR}/app/DragonMoonlight.manifest" ) else() 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() elseif(UNIX) target_link_libraries(moonlight-qt PRIVATE pthread) endif() # Qt resources: logo images set(DRAGON_QRC_FILE "${CMAKE_SOURCE_DIR}/app/assets/dragonmoonlight.qrc") if(NOT QT_VERSION_MAJOR) if(Qt6_FOUND) set(QT_VERSION_MAJOR 6) else() set(QT_VERSION_MAJOR 5) endif() endif() if(QT_VERSION_MAJOR EQUAL 6) qt_add_resources(DRAGON_QRC_OBJS "${DRAGON_QRC_FILE}") else() qt5_add_resources(DRAGON_QRC_OBJS "${DRAGON_QRC_FILE}") endif() target_sources(moonlight-qt PRIVATE ${DRAGON_QRC_OBJS})