Skip to content

Commit 0aa4cd6

Browse files
Merge pull request #8 from stefanDeveloper/add-vcpkg
Update CI Workflow for `vcpkg`
2 parents b3fd411 + 21b2143 commit 0aa4cd6

3 files changed

Lines changed: 43 additions & 83 deletions

File tree

.github/workflows/build_test_linux.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,29 @@ jobs:
2323
- name: Set up CMake
2424
uses: lukka/get-cmake@v3.29.2
2525

26-
- name: Cache APT packages
26+
- name: Cache vcpkg packages
2727
uses: actions/cache@v4
2828
with:
2929
path: |
30-
/var/cache/apt/archives
31-
key: ${{ runner.os }}-apt-${{ hashFiles('**/CMakeLists.txt') }}
30+
~/.cache/vcpkg
31+
heiFIP/build/vcpkg_installed
32+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('heiFIP/vcpkg.json') }}
3233
restore-keys: |
33-
${{ runner.os }}-apt-${{ hashFiles('**/CMakeLists.txt') }}
34+
${{ runner.os }}-vcpkg-
3435
3536
- name: Install dependencies
3637
run: |
3738
sudo apt-get update
3839
sudo apt-get install -y \
3940
build-essential \
40-
libssl-dev \
41-
libopencv-dev \
41+
pkg-config \
4242
libpcap-dev \
43-
libpthread-stubs0-dev \
4443
git
4544
46-
- name: Install precompiled PcapPlusPlus
47-
run: |
48-
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
49-
tar -xzf pcapplusplus-25.05-ubuntu-22.04-gcc-11.4.0-x86_64.tar.gz
50-
cd pcapplusplus-25.05-ubuntu-22.04-gcc-11.4.0-x86_64
51-
sudo cp -r include/* /usr/local/include/
52-
sudo cp -r lib/* /usr/local/lib/
53-
sudo ldconfig
54-
5545
- name: Configure and Build
5646
run: |
5747
cd heiFIP/
58-
59-
mkdir -p build && cd build
60-
61-
cmake .. \
48+
cmake -B build -S . \
6249
-DCMAKE_BUILD_TYPE=Release \
63-
-DUSE_MANUAL_PCAPPLUSPLUS=ON \
64-
-DPcapPlusPlus_INCLUDE_DIRS="/usr/local/include/pcapplusplus/" \
65-
-DPcapPlusPlus_LIBRARIES="/usr/local/lib/libCommon++.a;/usr/local/lib/libPacket++.a;/usr/local/lib/libPcap++.a" \
66-
-DUSE_MANUAL_OPENSSL=ON \
67-
-DOPENSSL_INCLUDE_DIR="/usr/include/openssl" \
68-
-DOPENSSL_CRYPTO_LIBRARY="/usr/lib/x86_64-linux-gnu/libcrypto.a"
69-
70-
make -j$(nproc)
50+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
51+
cmake --build build -j$(nproc)

.github/workflows/build_test_macos.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,25 @@ jobs:
2323
- name: Set up CMake
2424
uses: lukka/get-cmake@v3.29.2
2525

26-
- name: Set up Homebrew cache
26+
- name: Cache vcpkg packages
2727
uses: actions/cache@v4
2828
with:
2929
path: |
30-
/Users/runner/Library/Caches/Homebrew
31-
/usr/local/Homebrew/Library/Taps
32-
/usr/local/Cellar
33-
key: ${{ runner.os }}-brew-${{ hashFiles('**/CMakeLists.txt') }}
30+
~/.cache/vcpkg
31+
heiFIP/build/vcpkg_installed
32+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('heiFIP/vcpkg.json') }}
3433
restore-keys: |
35-
${{ runner.os }}-brew-${{ hashFiles('**/CMakeLists.txt') }}
34+
${{ runner.os }}-vcpkg-
3635
3736
- name: Install dependencies
3837
run: |
3938
brew update
40-
brew install openssl opencv libpcap cmake git pcapplusplus
39+
brew install pkg-config cmake git
4140
4241
- name: Configure and Build
4342
run: |
4443
cd heiFIP/
45-
46-
mkdir -p build && cd build
47-
48-
cmake .. \
49-
-DCMAKE_BUILD_TYPE=Release
50-
51-
make
44+
cmake -B build -S . \
45+
-DCMAKE_BUILD_TYPE=Release \
46+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
47+
cmake --build build -j$(sysctl -n hw.ncpu)

README.md

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -92,55 +92,38 @@ The idea to create heiFIP came from working with Deep Learning approaches to cla
9292

9393
* **C++ Compiler**: GCC ≥ 9.0, Clang ≥ 10, or MSVC 2019 with C++17 support.
9494
* **CMake**: Version ≥ 3.14
95-
* **PcapPlusPlus**: Installed system‑wide or built locally. ([https://github.com/seladb/PcapPlusPlus](https://github.com/seladb/PcapPlusPlus))
96-
* **OpenSSL**: For SHA256 hashing (libcrypto).
97-
* **OpenCV**: Version ≥ 4.0 for image handling and saving (e.g., cv::imwrite).
98-
* **pthread**: POSIX threads (Linux/macOS). Windows users require linking against `-lws2_32` and `-lIPHLPAPI`.
99-
* **libpcap**: PCAP Support (Linux/macOS)
95+
* **vcpkg**: A C++ package manager to automatically download and build dependencies.
10096

101-
Optional:
102-
103-
* **getopt\_long**: For CLI parsing (provided by libc on Linux/macOS). Windows may need `getopt` replacement.
97+
Dependencies managed automatically by `vcpkg`:
98+
* **PcapPlusPlus**
99+
* **OpenSSL**
100+
* **OpenCV**
101+
* **libpcap** (Linux/macOS) / `pthread`
104102

105103
## Building from source
106104

105+
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).
106+
107+
Ensure the `VCPKG_ROOT` environment variable is set to your `vcpkg` installation path (e.g., `export VCPKG_ROOT=~/vcpkg`).
107108

108109
```bash
109110
# Clone this repo
110-
git clone https://github.com/yourusername/heiFIPCpp.git
111+
git clone https://github.com/stefanDeveloper/heiFIP.git
111112
cd heiFIP/heiFIP/
112113

113-
# Create build directory
114-
mkdir build && cd build
115-
116-
cmake ..
117-
118-
# We highly recommend that locating necessary dependencies is done manually since espically
119-
# Pcap Plus Plus is often not installed in standard locations. While we do use scripts to automatically detect
120-
# the necessary dependencies if those scripts fail you can specify the paths to the include directories of the header
121-
# files aswell as the paths to libaries manually like so. Also do not forget to specify all three of Pcap Plus Plus's
122-
# libaries libCommon++, libPacket++, libPcap++. For OpenCV doing this manually while possible, due to number of links
123-
# necessary, is very difficult. Since OpenCV is configured for Cmake anyway this is unnecessary anyway. When using macOS
124-
# you need to be very careful that the linked libraries are not Intel (x86_64) bottles, since if this happens the code
125-
# will still be compiled as ARM64 but dynamically linking against x86_64 .dylib. This forces macOS to convert
126-
# back to ARM64 at runtime using Rosetta 2 which encures significant overhead. So if possible use a Linux distribution
127-
128-
cmake .. \
129-
-DCMAKE_BUILD_TYPE=Release \
130-
-DUSE_MANUAL_PCAPPLUSPLUS=ON \
131-
-DPcapPlusPlus_INCLUDE_DIRS="/opt/homebrew/Cellar/pcapplusplus/25.05/include" \
132-
-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" \
133-
-DUSE_MANUAL_OPENSSL=ON \
134-
-DOPENSSL_INCLUDE_DIR="/opt/homebrew/opt/openssl@3/include" \
135-
-DOPENSSL_CRYPTO_LIBRARY="/opt/homebrew/opt/openssl@3/lib/libcrypto.a"
136-
137-
# Compile
138-
make -j$(nproc)
139-
140-
# or
141-
cmake --build build
142-
143-
# The executable 'heiFIPCpp' will be produced in build/
114+
# Set up vcpkg
115+
git clone https://github.com/microsoft/vcpkg.git
116+
./vcpkg/bootstrap-vcpkg.sh
117+
export VCPKG_ROOT=$(pwd)/vcpkg
118+
119+
# Create build directory and run CMake using the vcpkg toolchain
120+
# The toolchain will automatically read vcpkg.json and install dependencies!
121+
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
122+
123+
# Compile the project
124+
cmake --build build -j$(nproc)
125+
126+
# The executables 'heiFIP' and 'main' will be produced in build/
144127
```
145128

146129

@@ -210,7 +193,7 @@ The following people contributed to heiFIP:
210193

211194
- [Stefan Machmeier](https://github.com/stefanDeveloper): Creator
212195
- [Manuel Trageser](https://github.com/maxi99manuel99): Header extraction and customization.
213-
- [Henri Rebitzky](https://github.com/HenriRebitzky): Coversion from python to c++
196+
- [Henri Rebitzky](https://github.com/HenriRebitzky): Conversion from Python to C++
214197

215198
## License
216199

0 commit comments

Comments
 (0)