Skip to content

Commit

Permalink
[pcapplusplus] Export targets and fix usage (#28215)
Browse files Browse the repository at this point in the history
* add usage

* revert

* Fix usage
  • Loading branch information
Adela0814 committed Dec 8, 2022
1 parent ca28e3a commit bd5b968
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
17 changes: 11 additions & 6 deletions ports/pcapplusplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ file(GLOB COMMONPP_SOURCES "${CMAKE_CURRENT_LIST_DIR}/Common++/src/*.cpp")

add_library(commonpp ${COMMONPP_SOURCES})

target_include_directories(commonpp PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Common++/header"
"${CMAKE_CURRENT_LIST_DIR}/3rdParty/EndianPortable/include")
target_include_directories(commonpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common++/header> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/EndianPortable/include> $<INSTALL_INTERFACE:include>)

set_target_properties(commonpp PROPERTIES OUTPUT_NAME Common++)
if (WIN32)
target_compile_definitions(commonpp PRIVATE WPCAP HAVE_REMOTE _CRT_SECURE_NO_WARNINGS)
Expand All @@ -53,8 +53,7 @@ list(APPEND PACKETPP_SOURCES "${CMAKE_CURRENT_LIST_DIR}/3rdParty/hash-library/md

add_library(packetpp ${PACKETPP_SOURCES})

target_include_directories(packetpp PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Packet++/header"
"${CMAKE_CURRENT_LIST_DIR}/3rdParty/hash-library")
target_include_directories(packetpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Packet++/header> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/hash-library> $<INSTALL_INTERFACE:include>)
target_link_libraries(packetpp PRIVATE commonpp)
set_target_properties(packetpp PROPERTIES OUTPUT_NAME Packet++)
if (WIN32)
Expand All @@ -72,8 +71,8 @@ file(GLOB LIGHTPCAPNG_SOURCES "${CMAKE_CURRENT_LIST_DIR}/3rdParty/LightPcapNg/Li

add_library(pcappp ${PCAPPP_SOURCES})

target_include_directories(pcappp PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Pcap++/header" "${PCAP_INCLUDES}"
"${CMAKE_CURRENT_LIST_DIR}/3rdParty/LightPcapNg/LightPcapNg/include")
target_include_directories(pcappp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Pcap++/header> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/LightPcapNg/LightPcapNg/include> "${PCAP_INCLUDES}" $<INSTALL_INTERFACE:include>)

target_link_libraries(pcappp PUBLIC commonpp packetpp ${PCAP_LIBRARIES} Threads::Threads)

if (WIN32)
Expand All @@ -100,7 +99,13 @@ install(FILES "${CMAKE_CURRENT_LIST_DIR}/LICENSE" DESTINATION share/pcapplusplus

install(
TARGETS pcappp commonpp packetpp
EXPORT unofficial-pcapplusplus-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

install(EXPORT unofficial-pcapplusplus-config
NAMESPACE unofficial::pcapplusplus::
DESTINATION share/unofficial-pcapplusplus
)
8 changes: 7 additions & 1 deletion ports/pcapplusplus/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ vcpkg_cmake_configure(
vcpkg_cmake_install()
vcpkg_copy_pdbs()

file(APPEND ${CURRENT_PACKAGES_DIR}/share/unofficial-pcapplusplus/unofficial-pcapplusplus-config.cmake "
include(CMakeFindDependencyMacro)
find_dependency(Threads)")

vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-pcapplusplus)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSE" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSE" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
5 changes: 5 additions & 0 deletions ports/pcapplusplus/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "pcapplusplus",
"version-string": "22.05",
"port-version": 1,
"description": "PcapPlusPlus is a multi-platform C++ library for capturing, parsing and crafting of network packets",
"homepage": "https://github.com/seladb/PcapPlusPlus",
"license": null,
Expand All @@ -17,6 +18,10 @@
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "winpcap",
"platform": "windows"
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5714,7 +5714,7 @@
},
"pcapplusplus": {
"baseline": "22.05",
"port-version": 0
"port-version": 1
},
"pcg": {
"baseline": "2021-04-06",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/pcapplusplus.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "fc809c85d5fb8f4c3132cac73cd48df0704dd170",
"version-string": "22.05",
"port-version": 1
},
{
"git-tree": "1bcf1e7a1ad1f7899adc1c423c248fea6b86553e",
"version-string": "22.05",
Expand Down

0 comments on commit bd5b968

Please sign in to comment.