Skip to content

Commit

Permalink
CMake: Add libpcap imported library target
Browse files Browse the repository at this point in the history
Change-Id: I5326b87784817fb353329e2d686fe0515c32f6cb
Reviewed-on: https://code.wireshark.org/review/33038
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: João Valverde <j@v6e.pt>
  • Loading branch information
randstr committed May 3, 2019
1 parent e5b4e67 commit 4c5d2f5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Expand Up @@ -2433,7 +2433,6 @@ if(BUILD_randpkt)
wiretap
wsutil
${M_LIBRARIES}
${PCAP_LIBRARIES}
${CARES_LIBRARIES}
${ZLIB_LIBRARIES}
)
Expand Down Expand Up @@ -2580,7 +2579,7 @@ if(BUILD_dumpcap AND PCAP_FOUND)
wsutil
caputils
ui
${PCAP_LIBRARIES}
$<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
${CAP_LIBRARIES}
${GLIB2_LIBRARIES}
${GTHREAD2_LIBRARIES}
Expand Down
8 changes: 8 additions & 0 deletions cmake/modules/FindPCAP.cmake
Expand Up @@ -262,3 +262,11 @@ if(PCAP_FOUND)

cmake_pop_check_state()
endif()

if(PCAP_FOUND AND NOT TARGET pcap::pcap)
add_library(pcap::pcap UNKNOWN IMPORTED)
set_target_properties(pcap::pcap PROPERTIES
IMPORTED_LOCATION "${PCAP_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${PCAP_INCLUDE_DIRS}"
)
endif()
2 changes: 0 additions & 2 deletions epan/CMakeLists.txt
Expand Up @@ -26,7 +26,6 @@ include_directories(
${LUA_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
${PCAP_INCLUDE_DIRS}
${SMI_INCLUDE_DIRS}
${SNAPPY_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
Expand Down Expand Up @@ -391,7 +390,6 @@ target_link_libraries(epan
${LZ4_LIBRARIES}
${M_LIBRARIES}
${NGHTTP2_LIBRARIES}
${PCAP_LIBRARIES}
${SMI_LIBRARIES}
${SNAPPY_LIBRARIES}
${WIN_PSAPI_LIBRARY}
Expand Down
2 changes: 1 addition & 1 deletion extcap/CMakeLists.txt
Expand Up @@ -91,8 +91,8 @@ if(BUILD_androiddump)
set(androiddump_LIBS
ui
${GLIB2_LIBRARIES}
${PCAP_LIBRARIES}
${WIN_WS2_32_LIBRARY}
$<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
)
else()
message(FATAL_ERROR "You are trying to build androiddump with libpcap but do not have it")
Expand Down
2 changes: 2 additions & 0 deletions ui/qt/CMakeLists.txt
Expand Up @@ -665,6 +665,8 @@ target_include_directories(qtui SYSTEM
${WINSPARKLE_INCLUDE_DIRS}
${SPEEXDSP_INCLUDE_DIRS}
PRIVATE
# Can't use imported target, linking object libraries for usage requirements
# requires CMake 3.12
${PCAP_INCLUDE_DIRS}
)

Expand Down
3 changes: 1 addition & 2 deletions wsutil/CMakeLists.txt
Expand Up @@ -267,10 +267,10 @@ target_link_libraries(wsutil
${APPLE_CORE_FOUNDATION_LIBRARY}
${GMODULE2_LIBRARIES}
${GLIB2_LIBRARIES}
${PCAP_LIBRARIES}
${GCRYPT_LIBRARIES}
${WIN_WS2_32_LIBRARY}
${GNUTLS_LIBRARIES}
$<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
)

if(WIN32)
Expand All @@ -279,7 +279,6 @@ endif(WIN32)

target_include_directories(wsutil SYSTEM
PUBLIC
${PCAP_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
)
Expand Down

0 comments on commit 4c5d2f5

Please sign in to comment.