CMake: Replace PACKAGELIST magic

This is more explicit and easier to read with slightly better locality
while using less code.

Also less awkward when the package doesn't fit the narrow package list
expectations.

The ws_find_package() macro doesn't include all the status messages. The
choice was to rely on standard find_package() and feature_summary() output
and be less verbose.

Avoid polluting the CLI build interface. Per target include paths and
macro definitions are preferred.

Because this patch intentionally removes the global CMAKE_*_FLAGS
and include_directories() usage in favor of target properties, some
untested build configurations may inadvertently break because of
missing ${PACKAGE}_INCLUDE_DIRS or ${PACKAGE}_DEFINITIONS. This
required a manual review of dependencies that might have been
incomplete.

${PACKAGE_VAR}_LINK_FLAGS seems to be unused.

Changing the CMake Qt code to use more modern CMake component syntax
is left as future work.

Change-Id: I3ed75252189a6e05a23ed6e619088f519cd7ed78
Reviewed-on: https://code.wireshark.org/review/31496
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
João Valverde 2019-01-10 01:45:00 +00:00 committed by Peter Wu
parent be103a4286
commit a3991874eb
11 changed files with 191 additions and 271 deletions

View File

@ -297,17 +297,6 @@ if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
set( DUMPCAP_INSTALL_OPTION ) set( DUMPCAP_INSTALL_OPTION )
endif() endif()
if(APPLE AND EXISTS /usr/local/opt/qt5)
# Homebrew installs Qt5 (up to at least 5.11.0) in
# /usr/local/qt5. Ensure that it can be found by CMake
# since it is not in the default /usr/local prefix.
# Add it to PATHS so that it doesn't override the
# CMAKE_PREFIX_PATH environment variable.
# QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
# e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
set (QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
endif()
set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz") set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz")
mark_as_advanced(OSS_FUZZ) mark_as_advanced(OSS_FUZZ)
if(OSS_FUZZ) if(OSS_FUZZ)
@ -915,23 +904,30 @@ if(APPLE AND EXISTS /usr/local/opt/gettext)
link_directories(/usr/local/opt/gettext/lib) link_directories(/usr/local/opt/gettext/lib)
endif() endif()
# The packagelist is doing some magic: If we add XXX to the packagelist, we # ws_find_package(<PackageName>
# - may optionally set XXX_OPTIONS to pass to the find_package command # <CMakeOptions.txt boolean variable>
# - will call FindXXX.cmake or find_package # <cmakeconfig.h.in macro definition>
# - return found libraries in XXX_LIBRARIES # [remaining find_package() arguments])
# - return found include in XXX_INCLUDE_DIRS macro(ws_find_package _package_name _enable_package _package_cmakedefine)
# - set HAVE_XXX if(${_enable_package})
find_package(${_package_name} ${ARGN})
if(${_package_name}_FOUND)
set(${_package_cmakedefine} 1)
endif()
endif()
endmacro()
# The minimum package list # The minimum package list
set(PACKAGELIST Git GLIB2 GMODULE2 GTHREAD2 GCRYPT LEX YACC Perl) find_package(Git)
set(LEX_OPTIONS REQUIRED)
set(GLIB2_OPTIONS REQUIRED)
set(GLIB2_FIND_OPTIONS REQUIRED)
set(GLIB2_MIN_VERSION 2.32.0) set(GLIB2_MIN_VERSION 2.32.0)
set(GTHREAD2_OPTIONS REQUIRED) find_package(GLIB2 REQUIRED)
set(GCRYPT_OPTIONS "1.4.2" REQUIRED) include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
set(Perl_OPTIONS REQUIRED) find_package(GMODULE2)
set(YACC_OPTIONS REQUIRED) find_package(GTHREAD2 REQUIRED)
find_package(GCRYPT "1.4.2" REQUIRED)
find_package(LEX REQUIRED)
find_package(YACC REQUIRED)
find_package(Perl REQUIRED)
if(CMAKE_VERSION VERSION_LESS "3.12") if(CMAKE_VERSION VERSION_LESS "3.12")
# Locate the Python interpreter. Finds the wrong (Python 2) version if: # Locate the Python interpreter. Finds the wrong (Python 2) version if:
@ -947,35 +943,40 @@ else()
endif() endif()
if (NOT WIN32) if (NOT WIN32)
set(PACKAGELIST ${PACKAGELIST} Gettext M) find_package(Gettext)
set(M_OPTIONS REQUIRED) find_package(M REQUIRED)
endif() endif()
set(PACKAGELIST ${PACKAGELIST} LIBSSH) if(BUILD_sshdump OR BUILD_ciscodump)
set(LIBSSH_OPTIONS "0.6") set(ENABLE_LIBSSH ON)
else()
if(ENABLE_PCAP) set(ENABLE_LIBSSH OFF)
set(PACKAGELIST ${PACKAGELIST} PCAP)
endif() endif()
ws_find_package(LIBSSH ENABLE_LIBSSH HAVE_LIBSSH "0.6")
if(ENABLE_AIRPCAP) ws_find_package(PCAP ENABLE_PCAP HAVE_LIBPCAP)
set(PACKAGELIST ${PACKAGELIST} AIRPCAP) ws_find_package(AIRPCAP ENABLE_AIRPCAP HAVE_AIRPCAP)
endif() ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
if(BUILD_sdjournal)
set(PACKAGELIST ${PACKAGELIST} Systemd)
endif()
# Build the Qt GUI? # Build the Qt GUI?
if(BUILD_wireshark) if(BUILD_wireshark)
# Untested, may not work if CMAKE_PREFIX_PATH gets overwritten # Untested, may not work if CMAKE_PREFIX_PATH gets overwritten
# somewhere. The if WIN32 in this place is annoying as well. # somewhere. The if WIN32 in this place is annoying as well.
if( WIN32 ) if(WIN32)
set( QT5_BASE_PATH "$ENV{QT5_BASE_DIR}" ) set(QT5_BASE_PATH "$ENV{QT5_BASE_DIR}")
set( CMAKE_PREFIX_PATH "${QT5_BASE_PATH}" ) set(CMAKE_PREFIX_PATH "${QT5_BASE_PATH}")
endif() endif()
list (INSERT QT_FIND_PACKAGE_OPTIONS 0 REQUIRED) if(APPLE AND EXISTS /usr/local/opt/qt5)
set(PACKAGELIST ${PACKAGELIST} # Homebrew installs Qt5 (up to at least 5.11.0) in
# /usr/local/qt5. Ensure that it can be found by CMake
# since it is not in the default /usr/local prefix.
# Add it to PATHS so that it doesn't override the
# CMAKE_PREFIX_PATH environment variable.
# QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
# e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
endif()
set(QT_PACKAGELIST
Qt5Core Qt5Core
Qt5LinguistTools Qt5LinguistTools
Qt5Multimedia Qt5Multimedia
@ -983,51 +984,41 @@ if(BUILD_wireshark)
Qt5Svg Qt5Svg
Qt5Widgets Qt5Widgets
) )
set(Qt5Core_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) if(APPLE)
set(Qt5LinguistTools_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) list(APPEND QT_PACKAGELIST Qt5MacExtras)
set(Qt5Multimedia_OPTIONS ${QT_FIND_PACKAGE_OPTIONS})
set(Qt5PrintSupport_OPTIONS ${QT_FIND_PACKAGE_OPTIONS})
set(Qt5Svg_OPTIONS ${QT_FIND_PACKAGE_OPTIONS})
set(Qt5Widgets_OPTIONS ${QT_FIND_PACKAGE_OPTIONS})
if (APPLE)
set(PACKAGELIST ${PACKAGELIST} Qt5MacExtras)
set(Qt5MacExtras_OPTIONS ${QT_FIND_PACKAGE_OPTIONS})
endif() endif()
if( WIN32 ) if(WIN32)
set(PACKAGELIST ${PACKAGELIST} Qt5WinExtras) list(APPEND QT_PACKAGELIST Qt5WinExtras)
set(Qt5WinExtras_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) endif()
foreach(_qt_package IN LISTS QT_PACKAGELIST)
find_package(${_qt_package} REQUIRED ${QT_FIND_PACKAGE_OPTIONS})
list(APPEND QT_LIBRARIES ${${_qt_package}_LIBRARIES})
list(APPEND QT_INCLUDE_DIRS ${${_qt_package}_INCLUDE_DIRS})
list(APPEND QT_COMPILE_DEFINITIONS ${${_qt_package}_COMPILE_DEFINITIONS})
endforeach()
set(QT_FOUND ON)
if(Qt5MacExtras_FOUND)
set(QT_MACEXTRAS_LIB 1)
endif() endif()
endif() endif()
# MaxMind DB address resolution # MaxMind DB address resolution
if(BUILD_mmdbresolve) ws_find_package(MaxMindDB BUILD_mmdbresolve HAVE_MAXMINDDB)
set(PACKAGELIST ${PACKAGELIST} MaxMindDB)
endif()
# SMI SNMP # SMI SNMP
if(ENABLE_SMI) ws_find_package(SMI ENABLE_SMI HAVE_LIBSMI)
set(PACKAGELIST ${PACKAGELIST} SMI)
endif()
# Support for TLS decryption using RSA private keys. # Support for TLS decryption using RSA private keys.
if(ENABLE_GNUTLS) ws_find_package(GNUTLS ENABLE_GNUTLS HAVE_LIBGNUTLS "3.2.0")
set(PACKAGELIST ${PACKAGELIST} GNUTLS)
# Minimum version needed.
# 3.0.2 due to GNUTLS_PRIVKEY_IMPORT_COPY
# 3.2.0 to remain GPLv2-compatible.
set(GNUTLS_OPTIONS "3.2.0")
endif()
# Kerberos # Kerberos
if(ENABLE_KERBEROS) ws_find_package(KERBEROS ENABLE_KERBEROS HAVE_KERBEROS)
set(PACKAGELIST ${PACKAGELIST} KERBEROS)
endif()
# C Asynchronous resolver # C Asynchronous resolver
if(ENABLE_CARES) ws_find_package(CARES ENABLE_CARES HAVE_C_ARES "1.5.0")
set(PACKAGELIST ${PACKAGELIST} CARES) if(NOT CARES_FOUND)
# Minimum version needed. message(WARNING "Not using c-ares.")
set(CARES_OPTIONS "1.5.0") message(WARNING "DNS name resolution for captures will be disabled.")
endif() endif()
# Zlib compression # Zlib compression
@ -1054,123 +1045,48 @@ if(ENABLE_ZLIB)
EXCLUDE_FROM_DEFAULT_BUILD True EXCLUDE_FROM_DEFAULT_BUILD True
) )
endif() endif()
set(PACKAGELIST ${PACKAGELIST} ZLIB) ws_find_package(ZLIB ENABLE_ZLIB HAVE_ZLIB)
endif() endif()
# LZ4 compression # LZ4 compression
if(ENABLE_LZ4) ws_find_package(LZ4 ENABLE_LZ4 HAVE_LZ4)
set(PACKAGELIST ${PACKAGELIST} LZ4)
endif()
# Snappy compression # Snappy compression
if(ENABLE_SNAPPY) ws_find_package(SNAPPY ENABLE_SNAPPY HAVE_SNAPPY)
set(PACKAGELIST ${PACKAGELIST} SNAPPY)
endif()
# Enhanced HTTP/2 dissection # Enhanced HTTP/2 dissection
if(ENABLE_NGHTTP2) ws_find_package(NGHTTP2 ENABLE_NGHTTP2 HAVE_NGHTTP2)
set(PACKAGELIST ${PACKAGELIST} NGHTTP2)
endif()
# Embedded Lua interpreter # Embedded Lua interpreter
if(ENABLE_LUA) ws_find_package(LUA ENABLE_LUA HAVE_LUA "5.1")
set(PACKAGELIST ${PACKAGELIST} LUA)
set(LUA_OPTIONS "5.1")
endif()
if(ENABLE_NETLINK) ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
set(PACKAGELIST ${PACKAGELIST} NL)
endif()
if(ENABLE_SBC) ws_find_package(SBC ENABLE_SBC HAVE_SBC)
set(PACKAGELIST ${PACKAGELIST} SBC)
endif()
if(ENABLE_SPANDSP) ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
set(PACKAGELIST ${PACKAGELIST} SPANDSP)
endif()
if(ENABLE_BCG729) ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
set(PACKAGELIST ${PACKAGELIST} BCG729)
endif()
if(ENABLE_LIBXML2) ws_find_package(LibXml2 ENABLE_LIBXML2 HAVE_LIBXML2)
set(PACKAGELIST ${PACKAGELIST} LibXml2) if(NOT LIBXML2_FOUND)
# The (official) FindLibXml2.cmake file sets this cache variable to a
# non-empty value, be sure to clear it when not found.
set(LIBXML2_LIBRARIES "")
endif() endif()
# Capabilities # Capabilities
if(ENABLE_CAP) ws_find_package(CAP ENABLE_CAP HAVE_LIBCAP)
set(PACKAGELIST ${PACKAGELIST} CAP SETCAP) if(NOT WIN32)
find_package(SETCAP)
endif() endif()
# Windows version updates # Windows version updates
if(ENABLE_WINSPARKLE) ws_find_package(WINSPARKLE ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
set(PACKAGELIST ${PACKAGELIST} WINSPARKLE)
endif()
set(PACKAGELIST ${PACKAGELIST} POD) find_package(POD)
set(PACKAGELIST ${PACKAGELIST} DOXYGEN) find_package(DOXYGEN)
set(PROGLIST)
# Sort the package list
list(SORT PACKAGELIST)
string(REPLACE ";" " " _package_list "${PACKAGELIST}")
message(STATUS "Package List: ${_package_list}")
# Let's loop the package list
foreach(PACKAGE ${PACKAGELIST})
# Most packages export uppercase variables, but there are exceptions.
if(PACKAGE MATCHES "^(Qt5)")
set(PACKAGE_VAR "${PACKAGE}")
else()
string(TOUPPER "${PACKAGE}" PACKAGE_VAR)
endif()
if(${PACKAGE}_OPTIONS)
find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
else()
find_package(${PACKAGE})
endif()
if (${PACKAGE_VAR}_FOUND)
message(STATUS "${PACKAGE_VAR} FOUND")
set(HAVE_LIB${PACKAGE_VAR} 1)
if (NOT DEFINED ${PACKAGE_VAR}_INCLUDE_DIRS AND ${PACKAGE_VAR}_INCLUDE_DIR)
set(${PACKAGE_VAR}_INCLUDE_DIRS ${${PACKAGE_VAR}_INCLUDE_DIR})
endif()
if (${PACKAGE_VAR}_INCLUDE_DIRS)
include_directories(SYSTEM ${${PACKAGE_VAR}_INCLUDE_DIRS})
message(STATUS "${PACKAGE} includes: ${${PACKAGE_VAR}_INCLUDE_DIRS}")
endif()
if (${PACKAGE_VAR}_LIBRARIES)
message(STATUS "${PACKAGE} libs: ${${PACKAGE_VAR}_LIBRARIES}")
endif()
if (${PACKAGE_VAR}_DEFINITIONS)
message(STATUS "${PACKAGE} definitions: ${${PACKAGE_VAR}_DEFINITIONS}")
string(REPLACE ";" " " _definitions "${${PACKAGE_VAR}_DEFINITIONS}")
set(CMAKE_C_FLAGS "${_definitions} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${_definitions} ${CMAKE_CXX_FLAGS}")
endif()
if (${PACKAGE_VAR}_LINK_FLAGS)
string(REPLACE ";" " " _link_flags "${${PACKAGE_VAR}_LINK_FLAGS}")
set(WS_LINK_FLAGS "${_link_flags} ${WS_LINK_FLAGS}")
message(STATUS "${PACKAGE} other link flags: ${_link_flags}")
endif()
if (${PACKAGE_VAR}_EXECUTABLE)
message(STATUS "${PACKAGE} executable: ${${PACKAGE_VAR}_EXECUTABLE}")
endif()
else()
#
# Not finding a package is only a fatal error if the
# package is required; if it's required, then its
# XXX_OPTIONS variable contains REQUIRED, and the above
# code will pass REQUIRED to find_package, and the
# configure will fail if the package isn't found.
#
# Do *NOT* report this as an error!
#
message(STATUS "${PACKAGE_VAR} NOT FOUND")
endif()
endforeach()
# dist target that prepares source dir # dist target that prepares source dir
# XXX Duplicated in the RPM section below. # XXX Duplicated in the RPM section below.
@ -1179,13 +1095,6 @@ add_custom_target(dist
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
if(HAVE_LIBAIRPCAP)
set(HAVE_AIRPCAP 1)
endif()
if(HAVE_LIBLUA)
set(HAVE_LUA_H 1)
set(HAVE_LUA 1)
endif()
if(GNUTLS_FOUND AND NOT GNUTLS_VERSION VERSION_LESS "3.4.0") if(GNUTLS_FOUND AND NOT GNUTLS_VERSION VERSION_LESS "3.4.0")
# While all Linux and Windows builds have PKCS #11 support enabled, # While all Linux and Windows builds have PKCS #11 support enabled,
# macos-setup.sh explicitly disables it using --without-p11-kit. # macos-setup.sh explicitly disables it using --without-p11-kit.
@ -1202,58 +1111,8 @@ if(GNUTLS_FOUND AND NOT GNUTLS_VERSION VERSION_LESS "3.4.0")
check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11) check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11)
cmake_pop_check_state() cmake_pop_check_state()
endif() endif()
if(HAVE_LIBKERBEROS)
set(HAVE_KERBEROS 1)
endif()
if(MAXMINDDB_FOUND)
set(HAVE_MAXMINDDB 1)
endif()
if(LIBSSH_FOUND)
set(HAVE_LIBSSH 1)
endif()
if(NGHTTP2_FOUND)
set(HAVE_NGHTTP2 1)
endif()
if(HAVE_LIBCARES)
set(HAVE_C_ARES 1)
endif()
if(NOT HAVE_LIBCARES)
message(WARNING "Not using c-ares.")
message(WARNING "DNS name resolution for captures will be disabled.")
endif()
if(HAVE_LIBNL AND HAVE_AIRPCAP)
message(ERROR "Airpcap and Libnl support are mutually exclusive")
endif()
if(HAVE_LIBSBC)
set(HAVE_SBC 1)
endif()
if(SPANDSP_FOUND)
set(HAVE_SPANDSP 1)
endif()
if(BCG729_FOUND)
set(HAVE_BCG729 1)
endif()
if(LIBXML2_FOUND)
set(HAVE_LIBXML2 1)
else()
# The (official) FindLibXml2.cmake file sets this cache variable to a
# non-empty value, be sure to clear it when not found.
set(LIBXML2_LIBRARIES "")
endif()
if (HAVE_LIBWINSPARKLE)
set(HAVE_SOFTWARE_UPDATE 1)
endif()
if(HAVE_LIBZLIB)
set(HAVE_ZLIB 1)
endif()
if(HAVE_LIBLZ4)
set(HAVE_LZ4 1)
endif()
if(SNAPPY_FOUND)
set(HAVE_SNAPPY 1)
endif()
if (Qt5Widgets_FOUND) if (QT_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.2) if (Qt5Widgets_VERSION VERSION_LESS 5.2)
message(FATAL_ERROR "Qt 5.2 or later is required.") message(FATAL_ERROR "Qt 5.2 or later is required.")
endif() endif()
@ -1263,27 +1122,6 @@ if (Qt5Widgets_FOUND)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif() endif()
set (QT_FOUND ON)
set (QT_LIBRARIES ${Qt5Widgets_LIBRARIES} ${Qt5PrintSupport_LIBRARIES})
if(Qt5Multimedia_FOUND)
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5Multimedia_LIBRARIES})
# That's the name autotools used
set(QT_MULTIMEDIA_LIB 1)
endif()
if(Qt5Svg_FOUND)
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5Svg_LIBRARIES})
# That's the name autotools used
set(QT_SVG_LIB 1)
endif()
if(Qt5MacExtras_FOUND)
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES})
# That's the name autotools used
set(QT_MACEXTRAS_LIB 1)
endif()
if(Qt5WinExtras_FOUND)
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5WinExtras_LIBRARIES})
# set(QT_WINEXTRAS_LIB 1) # Not needed?
endif()
if(NOT DEFINED MOC_OPTIONS) if(NOT DEFINED MOC_OPTIONS)
# Squelch moc verbose "nothing to do" output # Squelch moc verbose "nothing to do" output
set(MOC_OPTIONS -nn) set(MOC_OPTIONS -nn)
@ -1738,6 +1576,9 @@ endif()
set(VERSION_INFO_LIBS set(VERSION_INFO_LIBS
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
) )
set(VERSION_INFO_INCLUDE_DIRS
${ZLIB_INCLUDE_DIRS}
)
if(WIN32) if(WIN32)
set(_dll_output_dir "${DATAFILE_DIR}") set(_dll_output_dir "${DATAFILE_DIR}")
@ -2129,6 +1970,7 @@ set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks")
# Shared code, build object files once for all users. # Shared code, build object files once for all users.
add_library(version_info OBJECT version_info.c) add_library(version_info OBJECT version_info.c)
target_include_directories(version_info SYSTEM PRIVATE ${VERSION_INFO_INCLUDE_DIRS})
add_dependencies(version_info version) add_dependencies(version_info version)
# sources common for wireshark, tshark, rawshark and sharkd # sources common for wireshark, tshark, rawshark and sharkd
add_library(shark_common OBJECT add_library(shark_common OBJECT
@ -2141,6 +1983,7 @@ add_library(shark_common OBJECT
) )
add_library(cli_main OBJECT cli_main.c) add_library(cli_main OBJECT cli_main.c)
add_library(capture_opts OBJECT capture_opts.c) add_library(capture_opts OBJECT capture_opts.c)
target_include_directories(capture_opts SYSTEM PRIVATE ${PCAP_INCLUDE_DIRS})
set_target_properties(version_info shark_common cli_main capture_opts set_target_properties(version_info shark_common cli_main capture_opts
PROPERTIES PROPERTIES
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}" COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
@ -2242,16 +2085,14 @@ if(BUILD_wireshark AND QT_FOUND)
capchild capchild
caputils caputils
wiretap wiretap
${QT_LIBRARIES}
${GTHREAD2_LIBRARIES}
wscodecs wscodecs
epan epan
${QT_LIBRARIES}
${VERSION_INFO_LIBS} ${VERSION_INFO_LIBS}
${APPLE_APPLICATION_SERVICES_LIBRARY} ${APPLE_APPLICATION_SERVICES_LIBRARY}
${APPLE_APPKIT_LIBRARY} ${APPLE_APPKIT_LIBRARY}
${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_CORE_FOUNDATION_LIBRARY}
${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
${NL_LIBRARIES}
${WIN_VERSION_LIBRARY} ${WIN_VERSION_LIBRARY}
${WINSPARKLE_LIBRARIES} ${WINSPARKLE_LIBRARIES}
$<$<BOOL:${WIN32}>:UxTheme.lib> $<$<BOOL:${WIN32}>:UxTheme.lib>
@ -2286,6 +2127,7 @@ if(BUILD_wireshark AND QT_FOUND)
endif() endif()
target_link_libraries(wireshark ${wireshark_LIBS}) target_link_libraries(wireshark ${wireshark_LIBS})
install( install(
TARGETS wireshark TARGETS wireshark
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@ -2635,7 +2477,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_CORE_FOUNDATION_LIBRARY}
${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
${NL_LIBRARIES}
) )
set(dumpcap_FILES set(dumpcap_FILES
$<TARGET_OBJECTS:capture_opts> $<TARGET_OBJECTS:capture_opts>
@ -2730,7 +2571,8 @@ if (MAXMINDDB_FOUND)
add_executable(mmdbresolve ${mmdbresolve_FILES}) add_executable(mmdbresolve ${mmdbresolve_FILES})
set_extra_executable_properties(mmdbresolve "Executables") set_extra_executable_properties(mmdbresolve "Executables")
target_link_libraries(mmdbresolve ${mmdbresolve_LIBS}) target_link_libraries(mmdbresolve ${mmdbresolve_LIBS})
target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIR}) target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIRS})
target_compile_definitions(mmdbresolve PUBLIC ${MAXMINDDB_DEFINITIONS})
install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()

View File

@ -26,6 +26,8 @@ add_library(capchild STATIC
${CAPCHILD_SRC} ${CAPCHILD_SRC}
) )
target_link_libraries(capchild PRIVATE wsutil)
set_target_properties(capchild PROPERTIES set_target_properties(capchild PROPERTIES
LINK_FLAGS "${WS_LINK_FLAGS}" LINK_FLAGS "${WS_LINK_FLAGS}"
FOLDER "Libs") FOLDER "Libs")

View File

@ -47,7 +47,17 @@ add_library(caputils STATIC
${CAPUTILS_SRC} ${CAPUTILS_SRC}
) )
target_link_libraries(caputils PUBLIC ${PCAP_LIBRARIES}) target_link_libraries(caputils
PUBLIC
wsutil
PRIVATE
${NL_LIBRARIES}
)
target_include_directories(caputils SYSTEM
PRIVATE
${NL_INCLUDE_DIRS}
)
if(WIN32) if(WIN32)
target_link_libraries(caputils PRIVATE "iphlpapi.lib") target_link_libraries(caputils PRIVATE "iphlpapi.lib")

View File

@ -345,14 +345,11 @@
#cmakedefine PCAP_NG_DEFAULT 1 #cmakedefine PCAP_NG_DEFAULT 1
/* Define if we have QtMultimedia */ /* Define if we have QtMultimedia */
#cmakedefine QT_MULTIMEDIA_LIB 1 #define QT_MULTIMEDIA_LIB 1
/* Define if we have QtMacExtras */ /* Define if we have QtMacExtras */
#cmakedefine QT_MACEXTRAS_LIB 1 #cmakedefine QT_MACEXTRAS_LIB 1
/* Define if we have QtWinExtras */
/* #cmakedefine QT_WINEXTRAS_LIB 1 */
/* Build androiddump with libpcap instead of wireshark stuff */ /* Build androiddump with libpcap instead of wireshark stuff */
#cmakedefine ANDROIDDUMP_USE_LIBPCAP 1 #cmakedefine ANDROIDDUMP_USE_LIBPCAP 1

View File

@ -64,6 +64,13 @@ set_target_properties(wscodecs PROPERTIES
target_link_libraries(wscodecs ${wscodecs_LIBS}) target_link_libraries(wscodecs ${wscodecs_LIBS})
target_include_directories(wscodecs SYSTEM
PRIVATE
${SBC_INCLUDE_DIRS}
${SPANDSP_INCLUDE_DIRS}
${BCG729_INCLUDE_DIRS}
)
install(TARGETS wscodecs install(TARGETS wscodecs
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -15,12 +15,34 @@ if (HAVE_HFI_SECTION_INIT)
) )
endif() endif()
include_directories(
${GLIB2_INCLUDE_DIRS}
${CARES_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GTHREAD2_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${KERBEROS_INCLUDE_DIRS}
${LUA_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
${PCAP_INCLUDE_DIRS}
${SMI_INCLUDE_DIRS}
${SNAPPY_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
)
add_definitions(
${LIBXML2_DEFINITIONS}
${KERBEROS_DEFINITIONS}
)
add_subdirectory(crypt) add_subdirectory(crypt)
add_subdirectory(dfilter) add_subdirectory(dfilter)
add_subdirectory(dissectors) add_subdirectory(dissectors)
add_subdirectory(ftypes) add_subdirectory(ftypes)
add_subdirectory(wmem) add_subdirectory(wmem)
if (HAVE_LIBLUA) if(LUA_FOUND)
add_subdirectory(wslua) add_subdirectory(wslua)
endif() endif()
@ -279,7 +301,7 @@ add_library(epan
$<TARGET_OBJECTS:ftypes> $<TARGET_OBJECTS:ftypes>
$<TARGET_OBJECTS:version_info> $<TARGET_OBJECTS:version_info>
$<TARGET_OBJECTS:wmem> $<TARGET_OBJECTS:wmem>
$<$<BOOL:${HAVE_LIBLUA}>:$<TARGET_OBJECTS:wslua>> $<$<BOOL:${LUA_FOUND}>:$<TARGET_OBJECTS:wslua>>
${CMAKE_BINARY_DIR}/image/libwireshark.rc ${CMAKE_BINARY_DIR}/image/libwireshark.rc
) )
@ -370,10 +392,10 @@ target_include_directories(epan
INTERFACE INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/wireshark> $<INSTALL_INTERFACE:include/wireshark>
PUBLIC
${GLIB2_INCLUDE_DIRS}
) )
target_include_directories(epan SYSTEM PUBLIC ${GLIB2_INCLUDE_DIRS})
add_dependencies(epan lemon) add_dependencies(epan lemon)
install(TARGETS epan install(TARGETS epan

View File

@ -78,6 +78,10 @@ add_custom_target(extcaps)
add_library(extcap-base OBJECT extcap-base.c) add_library(extcap-base OBJECT extcap-base.c)
if(LIBSSH_FOUND) if(LIBSSH_FOUND)
add_library(ssh-base OBJECT ssh-base.c) add_library(ssh-base OBJECT ssh-base.c)
target_include_directories(ssh-base SYSTEM
PRIVATE
${LIBSSH_INCLUDE_DIRS}
)
endif() endif()
if(BUILD_androiddump) if(BUILD_androiddump)
@ -132,7 +136,7 @@ if(BUILD_sshdump AND LIBSSH_FOUND)
add_executable(sshdump ${sshdump_FILES}) add_executable(sshdump ${sshdump_FILES})
set_extcap_executable_properties(sshdump) set_extcap_executable_properties(sshdump)
target_link_libraries(sshdump ${sshdump_LIBS}) target_link_libraries(sshdump ${sshdump_LIBS})
target_include_directories(sshdump PUBLIC ${LIBSSH_INCLUDE_DIR}) target_include_directories(sshdump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
install(TARGETS sshdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR}) install(TARGETS sshdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
add_dependencies(extcaps sshdump) add_dependencies(extcaps sshdump)
elseif (BUILD_sshdump) elseif (BUILD_sshdump)
@ -158,7 +162,7 @@ if(BUILD_ciscodump AND LIBSSH_FOUND)
add_executable(ciscodump ${ciscodump_FILES}) add_executable(ciscodump ${ciscodump_FILES})
set_extcap_executable_properties(ciscodump) set_extcap_executable_properties(ciscodump)
target_link_libraries(ciscodump ${ciscodump_LIBS}) target_link_libraries(ciscodump ${ciscodump_LIBS})
target_include_directories(ciscodump PUBLIC ${LIBSSH_INCLUDE_DIR}) target_include_directories(ciscodump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
install(TARGETS ciscodump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR}) install(TARGETS ciscodump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
add_dependencies(extcaps ciscodump) add_dependencies(extcaps ciscodump)
elseif (BUILD_ciscodump) elseif (BUILD_ciscodump)
@ -182,7 +186,7 @@ if(BUILD_dpauxmon AND HAVE_LIBNL3)
add_executable(dpauxmon ${dpauxmon_FILES}) add_executable(dpauxmon ${dpauxmon_FILES})
set_extcap_executable_properties(dpauxmon) set_extcap_executable_properties(dpauxmon)
target_link_libraries(dpauxmon ${dpauxmon_LIBS}) target_link_libraries(dpauxmon ${dpauxmon_LIBS})
target_include_directories(dpauxmon PUBLIC ${NL_INCLUDE_DIR}) target_include_directories(dpauxmon SYSTEM PRIVATE ${NL_INCLUDE_DIRS})
install(TARGETS dpauxmon RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR}) install(TARGETS dpauxmon RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
add_dependencies(extcaps dpauxmon) add_dependencies(extcaps dpauxmon)
elseif (BUILD_dpauxmon) elseif (BUILD_dpauxmon)
@ -253,6 +257,8 @@ if(BUILD_sdjournal AND SYSTEMD_FOUND)
add_executable(sdjournal ${sdjournal_FILES}) add_executable(sdjournal ${sdjournal_FILES})
set_extcap_executable_properties(sdjournal) set_extcap_executable_properties(sdjournal)
target_link_libraries(sdjournal ${sdjournal_LIBS}) target_link_libraries(sdjournal ${sdjournal_LIBS})
target_include_directories(sdjournal SYSTEM PRIVATE ${SYSTEMD_INCLUDE_DIRS})
target_compile_definitions(sdjournal PRIVATE ${SYSTEMD_DEFINITIONS})
install(TARGETS sdjournal RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR}) install(TARGETS sdjournal RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
add_dependencies(extcaps sdjournal) add_dependencies(extcaps sdjournal)
elseif (BUILD_sdjournal) elseif (BUILD_sdjournal)

View File

@ -86,11 +86,18 @@ set_target_properties(ui PROPERTIES
FOLDER "UI" FOLDER "UI"
) )
target_link_libraries(ui wsutil)
if (HTML_HELP_COMPILER) if (HTML_HELP_COMPILER)
add_definitions(-DHHC_DIR) add_definitions(-DHHC_DIR)
target_link_libraries(ui Htmlhelp.lib) target_link_libraries(ui Htmlhelp.lib)
endif() endif()
target_include_directories(ui SYSTEM
PRIVATE
${WINSPARKLE_INCLUDE_DIRS}
)
add_definitions(-DDOC_DIR="${CMAKE_INSTALL_FULL_DOCDIR}") add_definitions(-DDOC_DIR="${CMAKE_INSTALL_FULL_DOCDIR}")
CHECKAPI( CHECKAPI(

View File

@ -655,6 +655,20 @@ add_library(qtui OBJECT
${WIRESHARK_QT_TAP_SRC} ${WIRESHARK_QT_TAP_SRC}
wireshark-tap-register.c wireshark-tap-register.c
) )
target_include_directories(qtui SYSTEM
PUBLIC
${QT_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
PRIVATE
${PCAP_INCLUDE_DIRS}
)
target_compile_definitions(qtui
PUBLIC
${QT_COMPILE_DEFINITIONS}
)
set_target_properties(qtui PROPERTIES set_target_properties(qtui PROPERTIES
LINK_FLAGS "${WS_LINK_FLAGS}" LINK_FLAGS "${WS_LINK_FLAGS}"
FOLDER "UI" FOLDER "UI"

View File

@ -138,6 +138,11 @@ target_link_libraries(wiretap
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
) )
target_include_directories(wiretap SYSTEM
PRIVATE
${ZLIB_INCLUDE_DIRS}
)
install(TARGETS wiretap install(TARGETS wiretap
EXPORT WiresharkTargets EXPORT WiresharkTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

View File

@ -263,6 +263,7 @@ target_link_libraries(wsutil
${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_CORE_FOUNDATION_LIBRARY}
${GMODULE2_LIBRARIES} ${GMODULE2_LIBRARIES}
${GLIB2_LIBRARIES} ${GLIB2_LIBRARIES}
${PCAP_LIBRARIES}
${GCRYPT_LIBRARIES} ${GCRYPT_LIBRARIES}
${WIN_WSOCK32_LIBRARY} ${WIN_WSOCK32_LIBRARY}
${GNUTLS_LIBRARIES} ${GNUTLS_LIBRARIES}
@ -272,6 +273,13 @@ if(WIN32)
target_link_libraries(wsutil PRIVATE "iphlpapi.lib" "ws2_32.lib") target_link_libraries(wsutil PRIVATE "iphlpapi.lib" "ws2_32.lib")
endif(WIN32) endif(WIN32)
target_include_directories(wsutil SYSTEM
PUBLIC
${PCAP_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
)
install(TARGETS wsutil install(TARGETS wsutil
EXPORT WiresharkTargets EXPORT WiresharkTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}