# Protocol Buffers (Protobuf) Integration This project supports optional Protocol Buffers integration via [vcpkg](https://vcpkg.io/). ## Installation Install protobuf via vcpkg: ```bash vcpkg install protobuf[zlib] protobuf[zlib]:x64-windows ``` ## CMake Configuration ### Option 1: Using vcpkg Toolchain (Recommended) When configuring CMake, specify the vcpkg toolchain file: ```bash cmake -S applications -B build --toolchain [path to vcpkg]/scripts/buildsystems/vcpkg.cmake ``` Or set it as an environment variable: ```powershell $env:CMAKE_TOOLCHAIN_FILE = "[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" cmake -S applications -B build ``` ### Option 2: Disable Protobuf (if not needed) ```bash cmake -S applications -B build -DENABLE_PROTOBUF=OFF ``` ## CMake Options - `ENABLE_PROTOBUF` (default: `ON`) - Enable or disable Protocol Buffers support ## Usage in Code When protobuf is enabled, the `ENABLE_PROTOBUF` preprocessor macro is defined: ```cpp #ifdef ENABLE_PROTOBUF #include // Use protobuf APIs #else // Fallback code when protobuf is disabled #endif ``` ## Targets All executables automatically link to protobuf when available: - `nodehub` - `nodehub-console` - `core_tests` Protobuf is linked via the `protobuf_interface` interface library, which provides: - `protobuf::libprotobuf` - Main protobuf library - `protobuf::libprotoc` - Protocol compiler library - `ENABLE_PROTOBUF=1` compile definition ## References - [Protobuf CMake README](https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md) - [vcpkg Documentation](https://vcpkg.io/)