[libtins] Misc fixes (#21789)

* Fix source writes

* Revise dependencies, switch to libpcap

* Revise portfile

* Enable libpcap on osx

* Minor portfile updates

* Update versions

* Find pcap_static lib

* Update versions
This commit is contained in:
Kai Pastor 2021-12-03 04:51:12 +01:00 committed by GitHub
parent 2647956afd
commit 5a54a4308e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 26 deletions

View File

@ -1,5 +1,3 @@
vcpkg_fail_port_install(ON_TARGET "UWP" "OSX")
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/winpcap")
message(FATAL_ERROR "FATAL ERROR: winpcap and libpcap are incompatible.")
endif()
@ -13,8 +11,6 @@ These can be installed on Ubuntu systems via sudo apt install flex libbison-dev"
)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO the-tcpdump-group/libpcap
@ -72,13 +68,13 @@ if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
endif()
# Even if compiled with BUILD_SHARED_LIBS=ON, pcap also install a pcap_static library
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pcap_static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/pcap_static.lib")
endif()
vcpkg_fixup_pkgconfig()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/share/man")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/share/man")

View File

@ -1,9 +1,10 @@
{
"name": "libpcap",
"version-semver": "1.10.1",
"port-version": 1,
"description": "A portable C/C++ library for network traffic capture",
"homepage": "https://www.tcpdump.org/",
"supports": "!(uwp | osx)",
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",

View File

@ -0,0 +1,13 @@
diff --git a/cmake/Modules/FindPCAP.cmake b/cmake/Modules/FindPCAP.cmake
index 388b30b..f5264c3 100644
--- a/cmake/Modules/FindPCAP.cmake
+++ b/cmake/Modules/FindPCAP.cmake
@@ -38,7 +38,7 @@ if (${CMAKE_SIZEOF_VOID_P} EQUAL 8 AND WIN32)
endif ()
find_library(PCAP_LIBRARY
- NAMES pcap wpcap
+ NAMES pcap wpcap pcap_static NAMES_PER_DIR
HINTS ${HINT_DIR}
)

View File

@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e13def..eda8d68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -228,8 +228,9 @@ ENDIF(DOXYGEN_FOUND)
# Configuration file
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/include/tins/config.h.in"
- "${PROJECT_SOURCE_DIR}/include/tins/config.h"
+ "${PROJECT_BINARY_DIR}/include/tins/config.h"
)
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/include")
IF (NOT CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR lib)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e07772e..94bc8bf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -82,7 +82,7 @@ set(HEADERS
${LIBTINS_INCLUDE_DIR}/tins/handshake_capturer.h
${LIBTINS_INCLUDE_DIR}/tins/stp.h
${LIBTINS_INCLUDE_DIR}/tins/pppoe.h
- ${LIBTINS_INCLUDE_DIR}/tins/config.h
+ ${PROJECT_BINARY_DIR}/include/tins/config.h
${LIBTINS_INCLUDE_DIR}/tins/constants.h
${LIBTINS_INCLUDE_DIR}/tins/crypto.h
${LIBTINS_INCLUDE_DIR}/tins/cxxstd.h
@@ -229,6 +229,7 @@ MACRO(INSTALL_HEADERS_WITH_DIRECTORY HEADER_LIST)
FOREACH(HEADER ${HEADERS})
# Extract directory name and remove leading '../'
get_filename_component(DIR ${HEADER} PATH)
+ string(REPLACE "${PROJECT_BINARY_DIR}/" "" DIR ${DIR})
STRING(REGEX REPLACE "^\\.\\.\\/" "" DIR ${DIR})
INSTALL(FILES ${HEADER} DESTINATION ${DIR})
ENDFOREACH(HEADER)

View File

@ -4,28 +4,27 @@ vcpkg_from_github(
REF v4.3
SHA512 29d606004fe9a440c9a53eede42fd5c6dbd049677d2cca2c5cfd26311ee2ca4c64ca3e665fbc81efd5bfab5577a5181ed0754c617e139317d9ae0cabba05aff7
HEAD_REF master
PATCHES
fix-source-writes.patch
find-pcap_static.patch
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" LIBTINS_BUILD_SHARED)
set(ENABLE_PCAP FALSE)
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(ENABLE_PCAP TRUE)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DLIBTINS_BUILD_SHARED=${LIBTINS_BUILD_SHARED}
-DLIBTINS_ENABLE_PCAP=${ENABLE_PCAP}
-DLIBTINS_ENABLE_CXX11=1
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=1
)
vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "windows" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") #Windows
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_cmake_config_fixup(CONFIG_PATH CMake)
else() #Linux/Unix/Darwin
else()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libtins)
endif()
@ -39,5 +38,3 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libtins" RENAME copyright)
vcpkg_fixup_pkgconfig()

View File

@ -1,11 +1,14 @@
{
"name": "libtins",
"version-string": "4.3",
"port-version": 3,
"version": "4.3",
"port-version": 4,
"description": "High-level, multiplatform C++ network packet sniffing and crafting library",
"supports": "!uwp",
"dependencies": [
"boost-any",
"boost-icl",
"libpcap",
"openssl",
{
"name": "vcpkg-cmake",
"host": true
@ -13,10 +16,6 @@
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "winpcap",
"platform": "windows"
}
]
}

View File

@ -3766,7 +3766,7 @@
},
"libpcap": {
"baseline": "1.10.1",
"port-version": 0
"port-version": 1
},
"libpff": {
"baseline": "2018-07-14",
@ -3962,7 +3962,7 @@
},
"libtins": {
"baseline": "4.3",
"port-version": 3
"port-version": 4
},
"libtomcrypt": {
"baseline": "1.18.2",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "4a0a395c4b517e9a54e1b96327b1ac90e317c225",
"version-semver": "1.10.1",
"port-version": 1
},
{
"git-tree": "5fb18d1935c9d7db3a7ff158e2aba95d5a9c6cd2",
"version-semver": "1.10.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "de1a1dc51c90ca57412fe5f8d57eeef42a41ec74",
"version": "4.3",
"port-version": 4
},
{
"git-tree": "909dcc117f47579bc754369cd0a7a9d5a66b23bc",
"version-string": "4.3",