### Build Amnezia Client and Installers (Unix-like) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Builds executables and installers for the host platform. Specify 'all' to include all available installer types. ```bash deploy/build.sh --installer all ``` -------------------------------- ### Install Binaries Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Installs binary files to the bin directory. ```cmake install(FILES ${CONAN_BINS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN ) ``` -------------------------------- ### Build Amnezia Client with IFW Installer (Windows) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Builds the Windows client executables and includes the Qt Installer Framework (IFW) installer. ```batch deploy/build.bat --installer ifw ``` -------------------------------- ### Install Project Target Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Installs the main project target to the bin directory. ```cmake install(TARGETS ${PROJECT} DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME_DEPENDENCY_SET service_deps COMPONENT AmneziaVPN ) ``` -------------------------------- ### Build Amnezia Client with IFW and WIX Installers (Windows) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Builds the Windows client, including installers generated by both Qt Installer Framework (IFW) and WIX toolset. ```batch deploy/build.bat --installer ifw --installer wix ``` -------------------------------- ### Install Windows Drivers (tap-windows6) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Copies the tap-windows6 driver directory after the build and installs it. ```cmake if (WIN32) find_package(tap-windows6 REQUIRED) add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${TAP_WINDOWS6_BIN}" "$/tap" ) install(DIRECTORY "${TAP_WINDOWS6_BIN}/" DESTINATION "${CMAKE_INSTALL_BINDIR}/tap" COMPONENT AmneziaVPN ) endif() ``` -------------------------------- ### Build Amnezia Client with All Installers (Windows) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Builds the Windows client and includes all supported installer types. ```batch deploy/build.bat --installer all ``` -------------------------------- ### Install Executables (Windows) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Installs executables to the bin directory, omitting permissions on Windows. ```cmake if(WIN32) # using PERMISSIONS on Windows appends read-only flag # to the files so just omit it for it install(FILES ${CONAN_EXECS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN ) else() install(FILES ${CONAN_EXECS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() ``` -------------------------------- ### Install OpenVPN Scripts Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Copies OpenVPN scripts to the installation directory if they exist, ensuring they are executable by the owner, group, and others. ```cmake if(OVPN_SCRIPTS) add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OVPN_SCRIPTS} "$" ) install(FILES ${OVPN_SCRIPTS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() ``` -------------------------------- ### Install Windows Drivers (win-split-tunnel) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Copies the win-split-tunnel driver directory after the build and installs it. ```cmake find_package(win-split-tunnel REQUIRED) add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${WIN_SPLIT_TUNNEL_BIN}" "$" ) install(DIRECTORY "${WIN_SPLIT_TUNNEL_BIN}/" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN ) endif() ``` -------------------------------- ### Install Runtime Dependencies Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Installs runtime dependencies with specified exclusions for Windows and Linux. ```cmake install(RUNTIME_DEPENDENCY_SET service_deps PRE_EXCLUDE_REGEXES [[api-ms-win-.*]] [[ext-ms-.*]] [[kernel32.dll]] [[hvsifiletrust.dll]] [[libc.so..*]] [[libgcc_s.so..*]] [[libm.so..*]] [[libstdc++.so..*]] [[.*.framework]] [[^[Qq]t.*]] POST_EXCLUDE_REGEXES [[^.*[\/]system32[\/].*.dll$]] [[^/lib.*]] [[^/usr/lib.*]] DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} COMPONENT AmneziaVPN DESTINATION "${RUNTIME_DEPS_DIR}" ) ``` -------------------------------- ### Install Common Dependencies Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Finds and appends common dependencies such as openvpn and tun2socks. ```cmake find_package(openvpn REQUIRED) list(APPEND CONAN_EXECS $) find_package(tun2socks REQUIRED) list(APPEND CONAN_EXECS $) ``` -------------------------------- ### Install macOS Packet Filter Directory Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Installs the packet filter configuration directory to the binary installation directory on macOS. This component is named 'AmneziaVPN'. ```cmake if(APPLE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/deploy/data/macos/pf DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT AmneziaVPN ) endif() ``` -------------------------------- ### Finalize Qt Executable and Install Dependencies Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Ensures Qt modules and plugins are correctly gathered and deployed for the executable. It handles finalization and installs runtime dependencies, with platform-specific configurations for macOS and Windows. ```cmake if(COMMAND qt_import_qml_plugins) qt_import_qml_plugins(${PROJECT}) endif() if(COMMAND qt_finalize_executable) qt_finalize_executable(${PROJECT}) else() qt_finalize_target(${PROJECT}) endif() install(TARGETS ${PROJECT} DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME_DEPENDENCY_SET client_deps COMPONENT AmneziaVPN ) if(APPLE) set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}/AmneziaVPN.app/Contents/Frameworks) else() set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}) endif() install(RUNTIME_DEPENDENCY_SET client_deps PRE_EXCLUDE_REGEXES [[api-ms-win-.*]] [[ext-ms-.*]] [[kernel32.dll]] [[hvsifiletrust.dll]] [[libc.so.*]] [[libgcc_s.so.*]] [[libm.so.*]] [[libstdc++.so.*]] [[.*.framework]] [[^Qt.*]] POST_EXCLUDE_REGEXES [[^.*[\/]system32[\/].*.dll$]] [[^/lib.*]] [[^/usr/lib.*]] DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} COMPONENT AmneziaVPN DESTINATION "${RUNTIME_DEPS_DIR}" ) ``` -------------------------------- ### Install v2ray-rules-dat Dependency Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Finds the v2ray-rules-dat package and appends its data paths. ```cmake find_package(v2ray-rules-dat REQUIRED) list(APPEND CONAN_BINS ${GEOSITE_DAT_PATH} ${GEOIP_DAT_PATH}) ``` -------------------------------- ### Configure Amnezia Client Build with CMake Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/3rd/QJsonStruct/CMakeLists.txt This CMake script sets up the build environment for the Amnezia Client. It defines project details, C++ standard, and includes necessary modules. Ensure Qt5 is installed and discoverable. ```cmake cmake_minimum_required(VERSION 3.5) project(QJsonStruct LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) option(BUILD_TESTING ON) include(QJsonStruct.cmake) find_package(Qt5 COMPONENTS Core REQUIRED) if(BUILD_TESTING) include(CTest) add_subdirectory(test) endif() ``` -------------------------------- ### Build Android APK and AAB (Unix-like) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Compiles the Android application, generating both APK and AAB formats. Requires Android SDK setup. ```bash deploy/build.sh -t android --aab ``` -------------------------------- ### Install Non-Linked Dependencies (Windows) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Finds and appends Windows-specific dependencies like awg-windows and wintun to the build process. ```cmake if(WIN32) find_package(awg-windows REQUIRED) list(APPEND CONAN_EXECS $) find_package(wintun REQUIRED) list(APPEND CONAN_BINS $) else() find_package(awg-go REQUIRED) list(APPEND CONAN_EXECS $) endif() ``` -------------------------------- ### macOS Specific Build Settings Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Configures installation RPATH for macOS executables and finds several macOS system frameworks for linking. ```cmake if(APPLE) set_target_properties(${PROJECT} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks" ) find_library(FW_COREFOUNDATION CoreFoundation) find_library(FW_SYSTEMCONFIG SystemConfiguration) find_library(FW_SERVICEMGMT ServiceManagement) find_library(FW_SECURITY Security) find_library(FW_COREWLAN CoreWLAN) find_library(FW_NETWORK Network) find_library(FW_USER_NOTIFICATIONS UserNotifications) target_link_libraries(${PROJECT} PRIVATE ${FW_COREFOUNDATION}) target_link_libraries(${PROJECT} PRIVATE ${FW_SYSTEMCONFIG}) target_link_libraries(${PROJECT} PRIVATE ${FW_SERVICEMGMT}) target_link_libraries(${PROJECT} PRIVATE ${FW_SECURITY}) target_link_libraries(${PROJECT} PRIVATE ${FW_COREWLAN}) target_link_libraries(${PROJECT} PRIVATE ${FW_NETWORK}) target_link_libraries(${PROJECT} PRIVATE ${FW_USER_NOTIFICATIONS}) endif() ``` -------------------------------- ### Link OpenSSL Libraries Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Links the OpenSSL SSL and Crypto libraries to the project. Ensure OpenSSL is correctly installed and discoverable by CMake. ```cmake target_link_libraries(${PROJECT} PRIVATE OpenSSL::SSL OpenSSL::Crypto) ``` -------------------------------- ### Retrieve Git Commit Hash Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Executes a git command to get the short commit hash and defines it as a preprocessor macro. ```cmake execute_process( WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") ``` -------------------------------- ### Display Build Script Help (Unix-like) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Shows available options and usage instructions for the build script. ```bash deploy/build.sh -h ``` -------------------------------- ### Create Executable Target Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Sets up the standard Qt6 project structure and adds the main executable target for the AmneziaVPN client. ```cmake qt_standard_project_setup() qt_add_executable(${PROJECT} MANUAL_FINALIZATION) target_include_directories(${PROJECT} PUBLIC $ ) ``` -------------------------------- ### Build Amnezia Client for Host Platform (Unix-like) Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Use this script to build the executables for your current operating system. Dependencies should be in default paths. ```bash deploy/build.sh ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Ensure all submodules are downloaded and initialized after cloning the repository. ```bash git submodule update --init --recursive ``` -------------------------------- ### Project Initialization and Properties Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Sets the minimum CMake version, project name, and global properties for organizing targets. ```cmake cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT AmneziaVPN) project(${PROJECT}) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "Autogen") set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "Autogen") set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen") ``` -------------------------------- ### Generate Qt Deploy Script with Platform Options Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Generates a script for deploying Qt applications, including specific options for Windows to force OpenSSL. ```cmake set(deploy_tool_options "") if(WIN32) set(deploy_tool_options "--force-openssl --force") endif() qt_generate_deploy_qml_app_script( TARGET ${PROJECT} OUTPUT_SCRIPT QT_DEPLOY_SCRIPT NO_UNSUPPORTED_PLATFORM_ERROR DEPLOY_TOOL_OPTIONS ${deploy_tool_options} ) install(SCRIPT ${QT_DEPLOY_SCRIPT} COMPONENT AmneziaVPN ) ``` -------------------------------- ### Find and Link Qt6 Components Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Finds the required Qt6 components and sets up the libraries to be linked with the project. ```cmake find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES}) set(LIBS ${LIBS} Qt6::Core Qt6::Gui Qt6::Network Qt6::Xml Qt6::RemoteObjects Qt6::Quick Qt6::Svg Qt6::QuickControls2 Qt6::Core5Compat Qt6::Concurrent ) if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) set(LIBS ${LIBS} Qt6::Widgets) endif() ``` -------------------------------- ### Build Amnezia Client for Windows Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md Executes the build script to compile the Windows version of the client. Assumes dependencies are in standard locations. ```batch deploy/build.bat ``` -------------------------------- ### Basic CMake Configuration for macOS Network Extension Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Sets up the basic build target for the macOS Network Extension executable, defining its product type and bundle properties. ```cmake enable_language(Swift) message("Client message >> macos build >> AmneziaVPNNetworkExtension") set(CLIENT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) add_executable(AmneziaVPNNetworkExtension) ``` -------------------------------- ### Post-Build Custom Command for Copying Dependencies Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Copies found executable and binary files to the target directory after the build. ```cmake add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CONAN_EXECS} ${CONAN_BINS} "$" ) ``` -------------------------------- ### Define Project Packages Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Lists the Qt6 components required for the project, including core, GUI, network, and UI modules. ```cmake set(PACKAGES Core Gui Network Xml RemoteObjects Quick Svg QuickControls2 Core5Compat Concurrent LinguistTools ) if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) set(PACKAGES ${PACKAGES} Widgets) endif() ``` -------------------------------- ### Amnezia Client CMakeLists.txt Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/CMakeLists.txt Sets up the CMake build environment for the Amnezia VPN client. It defines project version, C++ standard, and conditionally includes the server subdirectory. ```cmake cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT service) project(${PROJECT} VERSION ${AMNEZIAVPN_VERSION}) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(NOT IOS AND NOT ANDROID AND NOT MACOS_NE) add_subdirectory(server) endif() ``` -------------------------------- ### Generate Qt Deploy App Script Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Generates a script for deploying Qt applications. ```cmake qt_generate_deploy_app_script( TARGET ${PROJECT} OUTPUT_SCRIPT QT_DEPLOY_SCRIPT NO_UNSUPPORTED_PLATFORM_ERROR ) install(SCRIPT ${QT_DEPLOY_SCRIPT} COMPONENT AmneziaVPN ) ``` -------------------------------- ### Compile Options Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Adds preprocessor definitions for GROUP_ID and NETWORK_EXTENSION. ```cmake target_compile_options(networkextension PRIVATE -DGROUP_ID="${BUILD_IOS_GROUP_IDENTIFIER}") target_compile_options(networkextension PRIVATE -DNETWORK_EXTENSION=1) ``` -------------------------------- ### Basic Network Extension Target Configuration Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Configures the 'networkextension' executable as an Xcode product type app extension. Sets bundle properties like Info.plist, bundle name, GUI identifier, and version strings. ```cmake enable_language(Swift) set(CLIENT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) add_executable(networkextension) set_target_properties(networkextension PROPERTIES XCODE_PRODUCT_TYPE com.apple.product-type.app-extension BUNDLE_EXTENSION appex MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in MACOSX_BUNDLE_INFO_STRING "AmneziaVPNNetworkExtension" MACOSX_BUNDLE_NAME "AmneziaVPNNetworkExtension" MACOSX_BUNDLE_GUI_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION_TWEAK}" MACOSX_BUNDLE_LONG_VERSION_STRING "${APPLE_PROJECT_VERSION}-${CMAKE_PROJECT_VERSION_TWEAK}" MACOSX_BUNDLE_SHORT_VERSION_STRING "${APPLE_PROJECT_VERSION}" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/AmneziaVPNNetworkExtension.entitlements XCODE_ATTRIBUTE_MARKETING_VERSION "${APP_MAJOR_VERSION}" XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${BUILD_ID}" XCODE_ATTRIBUTE_PRODUCT_NAME "AmneziaVPNNetworkExtension" XCODE_ATTRIBUTE_APPLICATION_EXTENSION_API_ONLY "YES" XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks" XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION ) ``` -------------------------------- ### Link OpenVPN Adapter Library Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Links the amnezia::openvpnadapter library to the networkextension target. This is typically done for all build configurations. ```cmake set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL) set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) target_link_libraries(networkextension PRIVATE amnezia::openvpnadapter) ``` -------------------------------- ### Configure Runtime Dependencies Directory Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Sets the destination directory for runtime dependencies based on the operating system. ```cmake if(APPLE) set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}/../Frameworks) else() set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}) endif() ``` -------------------------------- ### Finding System Framework Libraries Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Locates essential system libraries required for the network extension, such as AssetsLibrary, MobileCoreServices, UIKit, and libresolv. ```cmake find_library(FW_ASSETS_LIBRARY AssetsLibrary) find_library(FW_MOBILE_CORE MobileCoreServices) find_library(FW_UI_KIT UIKit) find_library(FW_LIBRESOLV libresolv.9.tbd) ``` -------------------------------- ### Source File Inclusion Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Includes various Swift and C source files for the network extension, covering WireGuardKit, shared utilities, and platform-specific implementations. ```cmake set(WG_APPLE_SOURCE_DIR ${CLIENT_ROOT_DIR}/3rd/amneziawg-apple/Sources) target_sources(networkextension PRIVATE ${WG_APPLE_SOURCE_DIR}/WireGuardKit/WireGuardAdapter.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/PacketTunnelSettingsGenerator.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/DNSResolver.swift ${WG_APPLE_SOURCE_DIR}/WireGuardNetworkExtension/ErrorNotifier.swift ${WG_APPLE_SOURCE_DIR}/Shared/Keychain.swift ${WG_APPLE_SOURCE_DIR}/Shared/Model/TunnelConfiguration+WgQuickConfig.swift ${WG_APPLE_SOURCE_DIR}/Shared/Model/NETunnelProviderProtocol+Extension.swift ${WG_APPLE_SOURCE_DIR}/Shared/Model/String+ArrayConversion.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/TunnelConfiguration.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/IPAddressRange.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/Endpoint.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/DNSServer.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/InterfaceConfiguration.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/PeerConfiguration.swift ${WG_APPLE_SOURCE_DIR}/Shared/FileManager+Extension.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/x25519.c ${WG_APPLE_SOURCE_DIR}/WireGuardKit/Array+ConcurrentMap.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/IPAddress+AddrInfo.swift ${WG_APPLE_SOURCE_DIR}/WireGuardKit/PrivateKey.swift ${CLIENT_ROOT_DIR}/platforms/ios/HevSocksTunnel.swift ${CLIENT_ROOT_DIR}/platforms/ios/NELogController.swift ${CLIENT_ROOT_DIR}/platforms/ios/Log.swift ${CLIENT_ROOT_DIR}/platforms/ios/LogRecord.swift ${CLIENT_ROOT_DIR}/platforms/ios/PacketTunnelProvider.swift ${CLIENT_ROOT_DIR}/platforms/ios/PacketTunnelProvider+WireGuard.swift ${CLIENT_ROOT_DIR}/platforms/ios/PacketTunnelProvider+OpenVPN.swift ${CLIENT_ROOT_DIR}/platforms/ios/PacketTunnelProvider+Xray.swift ${CLIENT_ROOT_DIR}/platforms/ios/WGConfig.swift ${CLIENT_ROOT_DIR}/platforms/ios/XrayConfig.swift ) ``` -------------------------------- ### Compile Qt Resource Files Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Compiles various Qt resource collection files (.qrc) into the project, including images, flags, and UI QML files. ```cmake qt6_add_resources(QRC ${QRC} ${CMAKE_CURRENT_LIST_DIR}/images/images.qrc ${CMAKE_CURRENT_LIST_DIR}/images/flagKit.qrc ${CMAKE_CURRENT_LIST_DIR}/client_scripts/clientScripts.qrc ${CMAKE_CURRENT_LIST_DIR}/ui/qml/qml.qrc ${CMAKE_CURRENT_LIST_DIR}/server_scripts/serverScripts.qrc ) ``` -------------------------------- ### Conditional Script Deployment for OpenVPN Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Conditionally appends OpenVPN scripts for updating resolv.conf based on the operating system (macOS or Linux). ```cmake if (APPLE AND NOT IOS AND NOT MACOS_NE) list(APPEND OVPN_SCRIPTS "${CMAKE_SOURCE_DIR}/deploy/data/macos/update-resolv-conf.sh") endif() if (LINUX AND NOT ANDROID) list(APPEND OVPN_SCRIPTS "${CMAKE_SOURCE_DIR}/deploy/data/linux/update-resolv-conf.sh") endif() ``` -------------------------------- ### Xcode Product Type and Bundle Properties Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Configures Xcode-specific properties for the network extension, such as its bundle type, versioning, and identifier. ```cmake set_target_properties(AmneziaVPNNetworkExtension PROPERTIES XCODE_PRODUCT_TYPE com.apple.product-type.app-extension # MACOSX_BUNDLE YES BUNDLE_EXTENSION appex MACOSX_BUNDLE_SHORT_VERSION_STRING "${APPLE_PROJECT_VERSION}" MACOSX_BUNDLE_INFO_STRING "AmneziaVPNNetworkExtension" MACOSX_BUNDLE_BUNDLE_NAME "AmneziaVPNNetworkExtension" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_NAME "${BUILD_IOS_APP_IDENTIFIER}.network-extension" XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/AmneziaVPNNetworkExtension.entitlements XCODE_ATTRIBUTE_MARKETING_VERSION "${APP_MAJOR_VERSION}" XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_TWEAK}" XCODE_ATTRIBUTE_PRODUCT_NAME "AmneziaVPNNetworkExtension" XCODE_ATTRIBUTE_APPLICATION_EXTENSION_API_ONLY "YES" XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "11.0" XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../../../Frameworks @loader_path/../../../../Frameworks" ) ``` -------------------------------- ### Add Qt RPC Sources Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Generates C++ source files from Qt Remote Procedure Call (RPC) interface definition files. ```cmake qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_interface.rep) ``` ```cmake qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_process_interface.rep) ``` -------------------------------- ### Define Preprocessor Macros from Environment Variables Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Adds preprocessor definitions for various public keys and endpoints, sourcing values from environment variables. ```cmake add_definitions(-DPROD_AGW_PUBLIC_KEY="$ENV{PROD_AGW_PUBLIC_KEY}") add_definitions(-DPROD_S3_ENDPOINT="$ENV{PROD_S3_ENDPOINT}") add_definitions(-DFALLBACK_S3_ENDPOINT="$ENV{FALLBACK_S3_ENDPOINT}") add_definitions(-DDEV_AGW_PUBLIC_KEY="$ENV{DEV_AGW_PUBLIC_KEY}") add_definitions(-DDEV_AGW_ENDPOINT="$ENV{DEV_AGW_ENDPOINT}") add_definitions(-DDEV_S3_ENDPOINT="$ENV{DEV_S3_ENDPOINT}") add_definitions(-DFREE_V2_ENDPOINT="$ENV{FREE_V2_ENDPOINT}") add_definitions(-DPREM_V1_ENDPOINT="$ENV{PREM_V1_ENDPOINT}") ``` -------------------------------- ### Find and Link AWG Apple Library Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Finds the awg-apple package and links it to the networkextension target. Ensures the library is available for the build. ```cmake find_package(awg-apple REQUIRED) target_link_libraries(networkextension PRIVATE amnezia::awg-apple) ``` -------------------------------- ### Add Serialization Test Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/3rd/QJsonStruct/test/CMakeLists.txt Calls the QJSONSTRUCT_ADD_TEST function to add the 'serialization' test executable, using 'serialize/main.cpp' as its source file. This is a specific instance of the general test-adding function. ```cmake QJSONSTRUCT_ADD_TEST(serialization serialize/main.cpp) ``` -------------------------------- ### Add Remote Procedure Call (RPC) Replicas Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Adds RPC replica targets for inter-process communication interfaces, conditionally based on the operating system. ```cmake if(WIN32 OR (APPLE AND NOT IOS AND NOT MACOS_NE) OR (LINUX AND NOT ANDROID)) qt_add_repc_replicas(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../ipc/ipc_interface.rep) qt_add_repc_replicas(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../ipc/ipc_process_interface.rep) endif() ``` -------------------------------- ### Manage Translations Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/CMakeLists.txt Adds translation files (.ts) to the project and configures the resource prefix for translated strings. ```cmake set(AMNEZIAVPN_TS_FILES ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru_RU.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_zh_CN.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_fa_IR.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ar_EG.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_my_MM.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_uk_UA.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ur_PK.ts ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_hi_IN.ts ) qt6_add_translations(${PROJECT} TS_FILES ${AMNEZIAVPN_TS_FILES} RESOURCE_PREFIX "/translations" ) ``` -------------------------------- ### Swift Compiler and Bridging Header Configuration Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Configures Swift-specific compiler settings, including the Swift version, module enablement, and bridging header. ```cmake set_target_properties(AmneziaVPNNetworkExtension PROPERTIES XCODE_ATTRIBUTE_SWIFT_VERSION "5.0" XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES" XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/WireGuardNetworkExtension-Bridging-Header.h" XCODE_ATTRIBUTE_SWIFT_OPTIMIZATION_LEVEL "-Onone" XCODE_ATTRIBUTE_SWIFT_PRECOMPILE_BRIDGING_HEADER "NO" ) ``` -------------------------------- ### Swift and Bridging Header Configuration Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Configures Swift-specific build settings, including the Swift version, module enablement, and the Objective-C bridging header. Sets optimization level to 'none' for debugging. ```cmake set_target_properties(networkextension PROPERTIES XCODE_ATTRIBUTE_SWIFT_VERSION "5.0" XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES" XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/WireGuardNetworkExtension-Bridging-Header.h" XCODE_ATTRIBUTE_SWIFT_OPTIMIZATION_LEVEL "-Onone" XCODE_ATTRIBUTE_SWIFT_PRECOMPILE_BRIDGING_HEADER "NO" ) ``` -------------------------------- ### Conditional Code Signing for Deployment Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Sets code signing identities and provisioning profiles based on the DEPLOY variable. Uses 'Apple Distribution' for deployment and 'Apple Development' for debug builds. ```cmake if(DEPLOY) message("DEPLOY is ON") set_target_properties(AmneziaVPNNetworkExtension PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Distribution" XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Debug] "Apple Development" XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "distr macos.org.amnezia.amneziaVPN.NE" XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "dev macos.org.amnezia.amneziaVPN.NE" ) else() set_target_properties(AmneziaVPNNetworkExtension PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_STYLE Automatic ) endif() ``` -------------------------------- ### Development Team Configuration Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/macos/networkextension/CMakeLists.txt Sets the Xcode development team identifier for code signing purposes. ```cmake set_target_properties("AmneziaVPNNetworkExtension" PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" ) ``` -------------------------------- ### Link HEV SOCKS5 Tunnel Library Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/ios/networkextension/CMakeLists.txt Links the heiher::hev-socks5-tunnel library to the networkextension target. This includes setting import properties for various build configurations. ```cmake find_package(hev-socks5-tunnel REQUIRED) # FIXME(ygurov): https://github.com/conan-io/conan/issues/20034 set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL) set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) target_link_libraries(networkextension PRIVATE heiher::hev-socks5-tunnel) ``` -------------------------------- ### Define CMake Function for Adding Tests Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/3rd/QJsonStruct/test/CMakeLists.txt Defines a CMake function to add an executable for a test, including its source files and necessary include directories. It also links against Qt::Core and registers the test with CTest. ```cmake function(QJSONSTRUCT_ADD_TEST TEST_NAME TEST_SOURCE) add_executable(${TEST_NAME} ${TEST_SOURCE} catch.hpp ${QJSONSTRUCT_SOURCES}) target_include_directories(${TEST_NAME} PRIVATE $ ) target_link_libraries( ${TEST_NAME} PRIVATE Qt::Core ) add_test(NAME QJSONSTRUCT_TEST_${TEST_NAME} COMMAND $ -s) endfunction() ``` -------------------------------- ### Enable Debug Compilation Source: https://github.com/amnezia-vpn/amnezia-client/blob/dev/service/server/CMakeLists.txt Conditionally defines the MZ_DEBUG macro when the build type is 'Debug'. This is useful for enabling debug-specific code paths. ```cmake if(CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_definitions(${PROJECT} PRIVATE "MZ_DEBUG") endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.