From 21b2143453d2d994dfca4798030e6c6737938cf3 Mon Sep 17 00:00:00 2001 From: Stefan Machmeier Date: Sun, 22 Mar 2026 21:36:51 +0100 Subject: [PATCH] Update CI Workflow for vcpkg --- .github/workflows/build_test_linux.yml | 37 ++++----------- .github/workflows/build_test_macos.yml | 24 ++++------ README.md | 65 ++++++++++---------------- 3 files changed, 43 insertions(+), 83 deletions(-) diff --git a/.github/workflows/build_test_linux.yml b/.github/workflows/build_test_linux.yml index 90c449a..02b6ba1 100644 --- a/.github/workflows/build_test_linux.yml +++ b/.github/workflows/build_test_linux.yml @@ -23,48 +23,29 @@ jobs: - name: Set up CMake uses: lukka/get-cmake@v3.29.2 - - name: Cache APT packages + - name: Cache vcpkg packages uses: actions/cache@v4 with: path: | - /var/cache/apt/archives - key: ${{ runner.os }}-apt-${{ hashFiles('**/CMakeLists.txt') }} + ~/.cache/vcpkg + heiFIP/build/vcpkg_installed + key: ${{ runner.os }}-vcpkg-${{ hashFiles('heiFIP/vcpkg.json') }} restore-keys: | - ${{ runner.os }}-apt-${{ hashFiles('**/CMakeLists.txt') }} + ${{ runner.os }}-vcpkg- - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y \ build-essential \ - libssl-dev \ - libopencv-dev \ + pkg-config \ libpcap-dev \ - libpthread-stubs0-dev \ git - - name: Install precompiled PcapPlusPlus - run: | - curl -LO https://github.com/seladb/PcapPlusPlus/releases/download/v25.05/pcapplusplus-25.05-ubuntu-22.04-gcc-11.4.0-x86_64.tar.gz - tar -xzf pcapplusplus-25.05-ubuntu-22.04-gcc-11.4.0-x86_64.tar.gz - cd pcapplusplus-25.05-ubuntu-22.04-gcc-11.4.0-x86_64 - sudo cp -r include/* /usr/local/include/ - sudo cp -r lib/* /usr/local/lib/ - sudo ldconfig - - name: Configure and Build run: | cd heiFIP/ - - mkdir -p build && cd build - - cmake .. \ + cmake -B build -S . \ -DCMAKE_BUILD_TYPE=Release \ - -DUSE_MANUAL_PCAPPLUSPLUS=ON \ - -DPcapPlusPlus_INCLUDE_DIRS="/usr/local/include/pcapplusplus/" \ - -DPcapPlusPlus_LIBRARIES="/usr/local/lib/libCommon++.a;/usr/local/lib/libPacket++.a;/usr/local/lib/libPcap++.a" \ - -DUSE_MANUAL_OPENSSL=ON \ - -DOPENSSL_INCLUDE_DIR="/usr/include/openssl" \ - -DOPENSSL_CRYPTO_LIBRARY="/usr/lib/x86_64-linux-gnu/libcrypto.a" - - make -j$(nproc) + -DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + cmake --build build -j$(nproc) diff --git a/.github/workflows/build_test_macos.yml b/.github/workflows/build_test_macos.yml index d8e1d1a..6362922 100644 --- a/.github/workflows/build_test_macos.yml +++ b/.github/workflows/build_test_macos.yml @@ -23,29 +23,25 @@ jobs: - name: Set up CMake uses: lukka/get-cmake@v3.29.2 - - name: Set up Homebrew cache + - name: Cache vcpkg packages uses: actions/cache@v4 with: path: | - /Users/runner/Library/Caches/Homebrew - /usr/local/Homebrew/Library/Taps - /usr/local/Cellar - key: ${{ runner.os }}-brew-${{ hashFiles('**/CMakeLists.txt') }} + ~/.cache/vcpkg + heiFIP/build/vcpkg_installed + key: ${{ runner.os }}-vcpkg-${{ hashFiles('heiFIP/vcpkg.json') }} restore-keys: | - ${{ runner.os }}-brew-${{ hashFiles('**/CMakeLists.txt') }} + ${{ runner.os }}-vcpkg- - name: Install dependencies run: | brew update - brew install openssl opencv libpcap cmake git pcapplusplus + brew install pkg-config cmake git - name: Configure and Build run: | cd heiFIP/ - - mkdir -p build && cd build - - cmake .. \ - -DCMAKE_BUILD_TYPE=Release - - make + cmake -B build -S . \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + cmake --build build -j$(sysctl -n hw.ncpu) diff --git a/README.md b/README.md index 672bf79..e4cdb72 100644 --- a/README.md +++ b/README.md @@ -92,55 +92,38 @@ The idea to create heiFIP came from working with Deep Learning approaches to cla * **C++ Compiler**: GCC ≥ 9.0, Clang ≥ 10, or MSVC 2019 with C++17 support. * **CMake**: Version ≥ 3.14 -* **PcapPlusPlus**: Installed system‑wide or built locally. ([https://github.com/seladb/PcapPlusPlus](https://github.com/seladb/PcapPlusPlus)) -* **OpenSSL**: For SHA256 hashing (libcrypto). -* **OpenCV**: Version ≥ 4.0 for image handling and saving (e.g., cv::imwrite). -* **pthread**: POSIX threads (Linux/macOS). Windows users require linking against `-lws2_32` and `-lIPHLPAPI`. -* **libpcap**: PCAP Support (Linux/macOS) +* **vcpkg**: A C++ package manager to automatically download and build dependencies. -Optional: - -* **getopt\_long**: For CLI parsing (provided by libc on Linux/macOS). Windows may need `getopt` replacement. +Dependencies managed automatically by `vcpkg`: +* **PcapPlusPlus** +* **OpenSSL** +* **OpenCV** +* **libpcap** (Linux/macOS) / `pthread` ## Building from source +We use `vcpkg` to manage all C++ dependencies for heiFIP smoothly. If you don't have `vcpkg` installed, follow their [official instructions](https://github.com/microsoft/vcpkg#quick-start-windows-linux-macos). + +Ensure the `VCPKG_ROOT` environment variable is set to your `vcpkg` installation path (e.g., `export VCPKG_ROOT=~/vcpkg`). ```bash # Clone this repo -git clone https://github.com/yourusername/heiFIPCpp.git +git clone https://github.com/stefanDeveloper/heiFIP.git cd heiFIP/heiFIP/ -# Create build directory -mkdir build && cd build - -cmake .. - -# We highly recommend that locating necessary dependencies is done manually since espically -# Pcap Plus Plus is often not installed in standard locations. While we do use scripts to automatically detect -# the necessary dependencies if those scripts fail you can specify the paths to the include directories of the header -# files aswell as the paths to libaries manually like so. Also do not forget to specify all three of Pcap Plus Plus's -# libaries libCommon++, libPacket++, libPcap++. For OpenCV doing this manually while possible, due to number of links -# necessary, is very difficult. Since OpenCV is configured for Cmake anyway this is unnecessary anyway. When using macOS -# you need to be very careful that the linked libraries are not Intel (x86_64) bottles, since if this happens the code -# will still be compiled as ARM64 but dynamically linking against x86_64 .dylib. This forces macOS to convert -# back to ARM64 at runtime using Rosetta 2 which encures significant overhead. So if possible use a Linux distribution - -cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_MANUAL_PCAPPLUSPLUS=ON \ - -DPcapPlusPlus_INCLUDE_DIRS="/opt/homebrew/Cellar/pcapplusplus/25.05/include" \ - -DPcapPlusPlus_LIBRARIES="/opt/homebrew/Cellar/pcapplusplus/25.05/lib/libCommon++.a\;/opt/homebrew/Cellar/pcapplusplus/25.05/lib/libPacket++.a\;/opt/homebrew/Cellar/pcapplusplus/25.05/lib/libPcap++.a" \ - -DUSE_MANUAL_OPENSSL=ON \ - -DOPENSSL_INCLUDE_DIR="/opt/homebrew/opt/openssl@3/include" \ - -DOPENSSL_CRYPTO_LIBRARY="/opt/homebrew/opt/openssl@3/lib/libcrypto.a" - -# Compile -make -j$(nproc) - -# or -cmake --build build - -# The executable 'heiFIPCpp' will be produced in build/ +# Set up vcpkg +git clone https://github.com/microsoft/vcpkg.git +./vcpkg/bootstrap-vcpkg.sh +export VCPKG_ROOT=$(pwd)/vcpkg + +# Create build directory and run CMake using the vcpkg toolchain +# The toolchain will automatically read vcpkg.json and install dependencies! +cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" + +# Compile the project +cmake --build build -j$(nproc) + +# The executables 'heiFIP' and 'main' will be produced in build/ ``` @@ -210,7 +193,7 @@ The following people contributed to heiFIP: - [Stefan Machmeier](https://github.com/stefanDeveloper): Creator - [Manuel Trageser](https://github.com/maxi99manuel99): Header extraction and customization. -- [Henri Rebitzky](https://github.com/HenriRebitzky): Coversion from python to c++ +- [Henri Rebitzky](https://github.com/HenriRebitzky): Conversion from Python to C++ ## License