seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.68k stars 654 forks source link

PcapPlusPlus Configuration Error in CMake with vcpkg #1356

Closed kezniklm closed 5 months ago

kezniklm commented 5 months ago

I've encountered a configuration error related to PcapPlusPlus when building my project using vcpkg to manage dependencies. The error specifically mentions a problem with PcapPlusPlusConfig.cmake, indicating that a file or directory referenced by the variable PcapPlusPlus_INCLUDE_DIR does not exist. This issue has emerged recently, as CI builds were proceeding without problems two days ago.

Steps to Reproduce

  1. Set up vcpkg and integrate it with any project.
  2. Install PcapPlusPlus along with other dependencies using vcpkg install.
  3. Run CMake to configure the project, pointing it to use the vcpkg toolchain file.

The following error occurs during the CMake configuration phase: CMake Error at build/vcpkg_installed/x64-linux/share/pcapplusplus/PcapPlusPlusConfig.cmake:18 (message): File or directory /include/pcapplusplus referenced by variable PcapPlusPlus_INCLUDE_DIR does not exist ! Call Stack (most recent call first): build/vcpkg_installed/x64-linux/share/pcapplusplus/PcapPlusPlusConfig.cmake:38 (set_and_check) /home/user/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package) CMakeLists.txt:13 (find_package)

After commenting out the set_and_check(PcapPlusPlus_INCLUDE_DIR ${PACKAGE_PREFIX_DIR}/include/pcapplusplus) in PcapPlusPlusConfig.cmake it works, but It is impractical to comment it out every build.

egecetin commented 5 months ago

Looks like MacOS CI workflows also has the same problem

https://github.com/seladb/PcapPlusPlus/actions/runs/8687358735/job/23820713337?pr=1360

egecetin commented 5 months ago

@kezniklm What is your CMake version in your system?

Might be related with this. Looks like runners updated recently and they bumped the CMake version to 3.29.1 https://github.com/actions/runner-images/pull/9652

kezniklm commented 5 months ago

@kezniklm What is your CMake version in your system?

Might be related with this. Looks like runners updated recently and they bumped the CMake version to 3.29.1 actions/runner-images#9652

@egecetin I have: cmake version 3.29.2

egecetin commented 5 months ago

@clementperon Do you have any idea about this? Probably a bug introduced with CMake 3.29.1.

clementperon commented 5 months ago

Hi,

From linux Ubuntu 22.04, cmake version 3.29.2.

I can build the PcapPlusPlus example without any issue.

$> git clone vcpkg
$> ./vcpkg/vcpkg install pcapplusplus
$> cmake -B test -S . "-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake"
$> cmake --build test

Could you give the output of the PcapPlusPLusConfig.cmake ?

I will check the CI

kezniklm commented 5 months ago

The output should be in the issue definition. After compiling locally on 3.29.2 it eventually started to work, while in CI, where the cmake is 3.29.1 error persists.

clementperon commented 5 months ago

https://github.com/microsoft/vcpkg/issues/37968 It's a CMake regression: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9390

kezniklm commented 5 months ago

Updating CMake in CI to 3.29.2 fixed the issue.