Prepare the cmake infrastucture for eventually building
[metze/wireshark/wip.git] / CMakeLists.txt
index 4ed2dd72c00ea7d086ab24375f2934be67a533ff..a0e770f24ce4031aa5b6963e585cb3741f474caa 100644 (file)
 project(Wireshark C)
 
 cmake_minimum_required(VERSION 2.6)
+set(CMAKE_BACKWARDS_COMPATIBILITY 2.6)
+
+# Needs to be set after cmake_minimum_required or cmake_policy(VERSION)
+if(COMMAND cmake_policy)
+       # Backward compatibility for versions < 2.6.3
+       cmake_policy(SET CMP0011 OLD)
+#      cmake_policy(SET CMP0015 NEW)
+endif(COMMAND cmake_policy)
+
+# set(PROJECT_VERSION "1.3.4-rc5")
+# set(PROJECT_VERSION "1.3.4rc5")
+# set(PROJECT_VERSION "1.3.4")
+# If not set, copy over Wireshark version from configure.in AC_INIT
+if(NOT PROJECT_VERSION)
+       file(STRINGS
+               ${CMAKE_SOURCE_DIR}/configure.in
+               VERSIONLINE
+               REGEX "\\(wireshark, .*\\)"
+       )
+       string(REGEX REPLACE ".*\\(wireshark, (.*)\\).*"
+               "\\1"
+               PROJECT_VERSION
+               ${VERSIONLINE}
+       )
+endif()
+string(REGEX REPLACE "([0-9]+)\\..*"
+       "\\1"
+       PROJECT_MAJOR_VERSION
+       ${PROJECT_VERSION}
+)
+string(REGEX REPLACE ".*\\.([0-9]+)\\..*"
+       "\\1"
+       PROJECT_MINOR_VERSION
+       ${PROJECT_VERSION}
+)
+string(REGEX REPLACE ".*\\..*\\.([0-9]+).*"
+       "\\1"
+       PROJECT_PATCH_VERSION
+       ${PROJECT_VERSION}
+)
+string(REGEX REPLACE ".*\\..*\\.[0-9]+(.*)"
+       "\\1"
+       PROJECT_VERSION_EXTENSION
+       ${PROJECT_VERSION}
+)
+message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
 
 #Where to find local cmake scripts
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
@@ -33,8 +79,8 @@ INCLUDE(UseMakeTapReg)
 
 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
 
-# Disable this later. Alternative: "make VERBOSE=1"
-set(CMAKE_VERBOSE_MAKEFILE ON)
+# Enable with: "make VERBOSE=1"
+set(CMAKE_VERBOSE_MAKEFILE OFF)
 
 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
 include(CMakeInstallDirs)
@@ -53,41 +99,8 @@ if(NOT LIBRARY_OUTPUT_PATH)
                   "Single output directory for building all libraries.")
 endif()
 
-option(BUILD_wireshark   "Build the GUI version of Wireshark" ON)
-option(BUILD_tshark      "Build tshark" ON)
-option(BUILD_rawshark    "Build rawshark" ON)
-option(BUILD_dumpcap     "Build dumpcap" ON)
-option(BUILD_text2pcap   "Build text2pcap" ON)
-option(BUILD_mergecap    "Build mergecap" ON)
-option(BUILD_editcap     "Build editcap" ON)
-option(BUILD_capinfos    "Build capinfos" ON)
-option(BUILD_randpkt     "Build randpkt" ON)
-option(BUILD_dftest      "Build dftest" ON)
-option(AUTOGEN_dcerpc    "Autogenerate dcerpc dissectors" OFF)
-option(AUTOGEN_pidl      "Autogenerate pidl dissectors" OFF)
-
-option(DISABLE_WERROR   "Do not treat Warnings as errors" OFF)
-option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" OFF)
-option(ENABLE_AIRPCAP   "Enable Airpcap support" ON)
-option(ENABLE_STATIC     "Build a static version of Wireshark (not yet working)" OFF)
-option(ENABLE_PLUGINS    "Build with plugins" ON)
-# todo
-option(ENABLE_GUIDES     "Build Guides (not yet implemented)" OFF)
-
-option(ENABLE_ADNS       "Build with adns support" ON)
-option(ENABLE_PCRE       "Build with pcre support" ON)
-option(ENABLE_PORTAUDIO  "Build with portaudio support" ON)
-option(ENABLE_Z          "Build with zlib compression support" ON)
-option(ENABLE_LUA       "Build with lua dissector support" ON)
-option(ENABLE_PYTHON    "Build with python dissector support" ON)
-option(ENABLE_SMI       "Build with smi snmp support" ON)
-option(ENABLE_GNUTLS    "Build with GNU TLS support" ON)
-option(ENABLE_GCRYPT    "Build with GNU crypto support" ON)
-option(ENABLE_GEOIP     "Build with GeoIP support" ON)
-option(ENABLE_CAP       "Build with posix capabilities support" ON)
-option(ENABLE_CARES      "Build with c_ares support" ON)
-# todo Mostly hardcoded
-option(ENABLE_KERBEROS  "Build with Kerberos support" ON)
+
+include(CMakeOptions.txt)
 
 
 set(WIRESHARK_C_FLAGS
@@ -102,6 +115,8 @@ set(WIRESHARK_C_FLAGS
        -Warray-bounds
        -Wcast-align
        -Wformat-security
+       -Wold-style-definition
+       -fexcess-precision=fast
 )
 
 set(WIRESHARK_EXTRA_C_FLAGS
@@ -128,7 +143,10 @@ set(WIRESHARK_EXTRA_C_FLAGS
        -Wjump-misses-init
        # packet-ncp2222.inc prevents this from going into all warnings
        -Wwrite-strings
+       # GLib blocks this for now.
        -Wstrict-prototypes
+       # All the registration functions block these for now.
+       -Wmissing-prototypes
        -Wmissing-declarations
        # Problem with packet-afs.c
        -Wshadow
@@ -142,8 +160,8 @@ endif()
 
 add_definitions(
        -DHAVE_CONFIG_H
-       -DPACKAGE=\"wireshark\"
-       -DNEW_PACKET_LIST
+       -DG_DISABLE_DEPRECATED
+       -DG_DISABLE_SINGLE_INCLUDES
 )
 
 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
@@ -164,7 +182,7 @@ endforeach()
 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
        check_c_compiler_flag(-Werror WERROR)
 else()
-       set(WERROR 0)
+       unset(WERROR)
 endif()
 
 if(CMAKE_COMPILER_IS_GNUCC)
@@ -173,12 +191,26 @@ else()
        add_definitions( -D_U_=\"\" )
 endif()
 
-# todo
-# Same for linker flags, but it looks like it's do-it-yourself here
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
+set(WIRESHARK_LD_FLAGS
+       -Wl,--as-needed
+       # -flto
+       # -fwhopr
+       # -fwhole-program
+)
+
+include(CheckCLinkerFlag)
+set(C 0)
+# Sigh: Have to use THIS_FLAG instead of ${F} for some reason
+foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
+       set(F WS_LD_FLAG_${C})
+       set(${F} ${THIS_FLAG})
+       set(V WS_LD_FLAG_VALID${C})
+       check_c_linker_flag(${${F}} ${V})
+       if (${${V}})
+               set(WS_LINK_FLAGS ${WS_LINK_FLAGS} ${${F}})
+       endif()
+       math(EXPR C "${C} + 1")
+endforeach()
 
 if(ENABLE_STATIC)
   set(LINK_MODE_LIB STATIC)
@@ -188,81 +220,123 @@ else()
   set(LINK_MODE_MODULE MODULE)
 endif()
 
+# The packagelist is doing some magic:  If we add XXX to the packagelist, we
+# - may optionally set XXX_OPTIONS to pass to the find_package command
+# - will call FindXXX.cmake
+# - return found libraries in XXX_LIBRARIES
+# - return found include in XXX_INCLUDE_DIRS
+# - set HAVE_XXX
+
 #The minimum package list
-set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
+set(PACKAGELIST GLIB2 GMODULE2 GTHREAD2 M LEX YACC Perl SH PythonInterp)
+set(GLIB2_FIND_REQUIRED)
+set(GLIB2_MIN_VERSION 2.14.0)
+set(GTHREAD2_REQUIRED)
+set(PCAP_REQUIRED)
+set(M_REQUIRED)
+
+set(PACKAGELIST ${PACKAGELIST} HtmlViewer)
 
-#Build the gui ?
+if(ENABLE_PCAP)
+       set(PACKAGELIST ${PACKAGELIST} PCAP)
+endif()
+
+# Build the GTK-GUI?
 if(BUILD_wireshark)
-       set(PACKAGELIST GTK2 ${PACKAGELIST})
+       if(ENABLE_GTK3)
+               set(PACKAGELIST ${PACKAGELIST} GTK3)
+       else()
+               set(PACKAGELIST ${PACKAGELIST} GTK2)
+               set(GTK2_OPTIONS COMPONENTS gtk)
+               set(GTK2_FIND_VERSION 2.12)
+               set(GTK2_DEBUG false)
+       endif()
+endif()
+
+# Build the Qt GUI?
+if(BUILD_qtshark)
+       set(PACKAGELIST ${PACKAGELIST} QT)
+       # set(QT_OPTIONS 4.7.1 REQUIRED QtCore QtGui)
 endif()
 
 # SMI SNMP
 if(ENABLE_SMI)
-       set(PACKAGELIST SMI ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} SMI)
 endif()
 
 # GNU crypto
 if(ENABLE_GCRYPT)
-       set(PACKAGELIST GCRYPT ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} GCRYPT)
 endif()
 
 # GNU SSL/TLS support
 if(ENABLE_GNUTLS)
-       set(PACKAGELIST GNUTLS ${PACKAGELIST})
-endif()
-
-# Regular expressions lib
-if(ENABLE_PCRE)
-       set(PACKAGELIST PCRE ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} GNUTLS)
 endif()
 
 # Kerberos
 if(ENABLE_KERBEROS)
-       set(PACKAGELIST KERBEROS ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} KERBEROS)
 endif()
 
 # Portable audio
 if(ENABLE_PORTAUDIO)
-       set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} PORTAUDIO)
 endif()
 
 
 # Prefer c-ares over adns
 if(ENABLE_CARES)        # C Asynchronouse resolver
-       set(PACKAGELIST CARES ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} CARES)
 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
-       set(PACKAGELIST ADNS ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} ADNS)
 endif()
 
 # Zlib compression
-if(ENABLE_Z)
-       set(PACKAGELIST Z ${PACKAGELIST})
+if(ENABLE_ZLIB)
+       set(PACKAGELIST ${PACKAGELIST} ZLIB)
 endif()
 
 # Lua 5.1 dissectors
 if(ENABLE_LUA)
-       set(PACKAGELIST LUA ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} LUA)
 endif()
 
 # GeoIP address resolving
 if(ENABLE_GEOIP)
-       set(PACKAGELIST GEOIP ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} GEOIP)
 endif()
 
 # Capabilities
 if(ENABLE_CAP)
-       set(PACKAGELIST CAP ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} CAP)
 endif()
 
 if(ENABLE_PYTHON)
-       set(PACKAGELIST PYTHON ${PACKAGELIST})
+       set(PACKAGELIST ${PACKAGELIST} PYTHON)
 endif()
 
+set(PACKAGELIST ${PACKAGELIST} YAPP)
+
+set(PACKAGELIST ${PACKAGELIST} POD)
+
+
 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
 
 #Let's loop the package list
 foreach(PACKAGE ${PACKAGELIST})
-       find_package(${PACKAGE} REQUIRED)
+       if(${PACKAGE} EQUAL "QT")
+               set(PACKAGE_NAME "Qt4")
+       else()
+               set(PACKAGE_NAME ${PACKAGE})
+       endif()
+       if(${PACKAGE}_OPTIONS)
+               find_package(${PACKAGE_NAME} ${${PACKAGE}_OPTIONS})
+       elseif(${PACKAGE}_REQUIRED)
+               find_package(${PACKAGE_NAME} REQUIRED)
+       else()
+               find_package(${PACKAGE_NAME})
+       endif()
        message(${PACKAGE}_FOUND)
        if (${PACKAGE}_FOUND)
                set(HAVE_LIB${PACKAGE} 1)
@@ -272,8 +346,6 @@ foreach(PACKAGE ${PACKAGELIST})
        endif()
 endforeach()
 
-find_package(YAPP)
-
 #packaging
 include(CPackConfig.txt)
 
@@ -303,6 +375,14 @@ endif()
 if(ENABLE_AIRPCAP)
        set(HAVE_AIRPCAP 1)
 endif()
+# No matter which version of GTK is present
+if(GTK2_FOUND OR GTK3_FOUND)
+       set(GTK_FOUND ON)
+endif()
+# That's the name autofoo uses
+if(HAVE_LIBZLIB)
+       set(HAVE_LIBZ 1)
+endif()
 
 include(ConfigureChecks.cmake)
 
@@ -326,7 +406,6 @@ if(ENABLE_PLUGINS)
                plugins/mate
                plugins/opcua
                plugins/profinet
-               plugins/sercosiii
                plugins/stats_tree
                plugins/unistim
                plugins/wimax
@@ -349,15 +428,31 @@ endforeach()
 
 add_subdirectory( codecs )
 add_subdirectory( epan )
-add_subdirectory( gtk )
 add_subdirectory( tools/lemon )
 add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
+if(BUILD_wireshark AND GTK_FOUND)
+       add_subdirectory( ui/gtk )
+endif()
+
+if(BUILD_qtshark AND QT_FOUND)
+       add_subdirectory( ui/qt )
+endif()
+
+
+# Basedir where to install guides
+set(DOC_DIR "$ENV{docdir}")
+message(STATUS "docdir: ${DOC_DIR}")
+
 if(ENABLE_GUIDES)
        add_subdirectory( docbook )
 endif()
 
+if(ENABLE_PCAP_NG_DEFAULT)
+       set(PCAP_NG_DEFAULT 1)
+endif()
+
 #Platform specific
 if(UNIX)
        set(WS_VAR_IMPORT "extern")
@@ -373,11 +468,14 @@ endif()
 if(WIN32)
        add_definitions(-D_NEED_VAR_IMPORT_)
        set(WS_VAR_IMPORT "__declspec(dllimport) extern")
+       set(WS_MSVC_NORETURN "__declspec(noreturn)")
 
        # Disable deprecation
        if(MSVC80 OR MSVC90)
                add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
        endif()
+else()
+       set(WS_MSVC_NORETURN " ")
 endif()
 
 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
@@ -388,35 +486,41 @@ PRINT_ENABLED_FEATURES()
 PRINT_DISABLED_FEATURES()
 
 link_directories(
-       gtk
-       codecs
-       epan
-       wiretap
-       wsutil
+       ${CMAKE_BINARY_DIR}/ui/gtk
+       ${CMAKE_BINARY_DIR}/ui/qt
+       ${CMAKE_BINARY_DIR}/codecs
+       ${CMAKE_BINARY_DIR}/epan
+       ${CMAKE_BINARY_DIR}/wiretap
+       ${CMAKE_BINARY_DIR}/wsutil
 )
 
 ADD_CUSTOM_TARGET(
        svnversion ALL
-       COMMAND LANG=C ${PERL}
+       COMMAND ${PERL}
                ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
                ${CMAKE_CURRENT_SOURCE_DIR}
        DEPENDS
                ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
 )
 
-register_tap_files(tshark-tap-register.c
-       ${TSHARK_TAP_SRC}
+ADD_CUSTOM_COMMAND(
+       OUTPUT  svnversion.h
+       COMMAND ${PERL}
+               ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
+               ${CMAKE_CURRENT_SOURCE_DIR}
+       DEPENDS
+               ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
 )
 
 ADD_CUSTOM_COMMAND(
-       OUTPUT ps.c
-       COMMAND ${PYTHON_EXECUTABLE}
-         ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
-         ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
-         ps.c
+       OUTPUT  ps.c
+       COMMAND ${PYTHON_EXECUTABLE}
+               ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
+               ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
+               ps.c
        DEPENDS
-         ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
-         ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
+               ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
+               ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
 )
 
 if(UNIX)
@@ -437,14 +541,18 @@ set(WTAP_PLUGIN_SOURCES
        epan/filesystem.c
 )
 
+set(SHARK_COMMON_CAPTURE_SRC
+       capture_ifinfo.c
+       capture_ui_utils.c
+)
+
 set(WIRESHARK_COMMON_SRC
        ${PLATFORM_SRC}
-       capture_errs.c
        capture-pcap-util.c
-       capture_ui_utils.c
        cfile.c
        clopts_common.c
        disabled_protos.c
+       frame_data_sequence.c
        packet-range.c
        print.c
        ps.c
@@ -458,38 +566,49 @@ set(WIRESHARK_COMMON_SRC
 )
 
 set(TSHARK_TAP_SRC
-        tap-afpstat.c
-        tap-ansi_astat.c
-        tap-bootpstat.c
-        tap-camelcounter.c
-        tap-camelsrt.c
-        tap-comparestat.c
-        tap-dcerpcstat.c
-        tap-funnel.c
-        tap-gsm_astat.c
-        tap-h225counter.c
-        tap-h225rassrt.c
-        tap-httpstat.c
-        tap-iostat.c
-        tap-iousers.c
-        tap-mgcpstat.c
-        tap-megacostat.c
-        tap-protocolinfo.c
-        tap-protohierstat.c
-        tap-radiusstat.c
-        tap-rpcstat.c
-        tap-rpcprogs.c
-        tap-rtp.c
-        tap-sctpchunkstat.c
-        tap-sipstat.c
-        tap-smbsids.c
-        tap-smbstat.c
-        tap-stats_tree.c
-        tap-wspstat.c
+       tap-afpstat.c
+       tap-ansi_astat.c
+       tap-bootpstat.c
+       tap-camelcounter.c
+       tap-camelsrt.c
+       tap-comparestat.c
+       tap-dcerpcstat.c
+       tap-diameter-avp.c
+       tap-expert.c
+       tap-funnel.c
+       tap-gsm_astat.c
+       tap-h225counter.c
+       tap-h225rassrt.c
+       tap-hosts.c
+       tap-httpstat.c
+       tap-icmpstat.c
+       tap-icmpv6stat.c
+       tap-iostat.c
+       tap-iousers.c
+       tap-macltestat.c
+       tap-mgcpstat.c
+       tap-megacostat.c
+       tap-protocolinfo.c
+       tap-protohierstat.c
+       tap-radiusstat.c
+       tap-rlcltestat.c
+       tap-rpcstat.c
+       tap-rpcprogs.c
+       tap-rtp.c
+       tap-rtspstat.c
+       tap-scsistat.c
+       tap-sctpchunkstat.c
+       tap-sipstat.c
+       tap-smbsids.c
+       tap-smbstat.c
+       tap-stats_tree.c
+       tap-sv.c
+       tap-wspstat.c
 )
 
 set(INSTALL_DIRS
        diameter
+       docbook
        dtds
        help
        radius
@@ -504,12 +623,15 @@ set(INSTALL_FILES
        cfilters
        colorfilters
        dfilters
+       ${CMAKE_BINARY_DIR}/dftest.html
        ${CMAKE_BINARY_DIR}/dumpcap.html
        ${CMAKE_BINARY_DIR}/editcap.html
        ${CMAKE_BINARY_DIR}/idl2wrs.html
        ipmap.html
        manuf
        ${CMAKE_BINARY_DIR}/mergecap.html
+       pdml2html.xsl
+       ${CMAKE_BINARY_DIR}/randpkt.html
        ${CMAKE_BINARY_DIR}/rawshark.html
        services
        smi_modules
@@ -521,19 +643,11 @@ set(INSTALL_FILES
 )
 
 set(LIBEPAN_LIBS
-#              @GETOPT_O@      # wsgetopt.c
-#              @INET_ATON_LO@  # epan/inet_aton.c
-#              @INET_NTOP_LO@  # inet_ntop.c
-#              @INET_PTON_LO@  # inet_pton.c
 #              @NSL_LIBS@      # -lnsl
 #              @SOCKET_LIBS@   # -lsocket
 #              @SSL_LIBS@      # -lcrypto
-#              @STRERROR_O@    # strerror.c
-#              @STRNCASECMP_O@ # strncasecmp.c
-#              @STRPTIME_O@    # strptime.c
                epan
 #              $(plugin_ldadd) # in case of static
-               ${PCRE_LIBRARIES}
                ${PCAP_LIBRARIES}
                ${CARES_LIBRARIES}
                ${ADNS_LIBRARIES}
@@ -544,20 +658,11 @@ set(LIBEPAN_LIBS
                ${GCRYPT_LIBRARIES}
                ${GNUTLS_LIBRARIES}
                ${SMI_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${M_LIBRARIES}
 )
 
-if(BUILD_wireshark)
-       set(wireshark_LIBS
-               ui
-               ${GTK2_LIBRARIES}
-               codecs
-               ${PORTAUDIO_LIBRARIES}
-               ${LIBEPAN_LIBS}
-               ${APPLE_CORE_SERVICES_LIBRARY}
-               ${APPLE_COCOA_LIBRARY}
-       )
+if( (BUILD_wireshark AND GTK_FOUND) OR (BUILD_qtshark AND QT_FOUND) )
        set(wireshark_FILES
                airpcap_loader.c
                alert_box.c
@@ -572,16 +677,60 @@ if(BUILD_wireshark)
                g711.c
                merge.c
                proto_hier_stats.c
+               recent.c
                summary.c
                tempfile.c
+               u3.c
+               ${SHARK_COMMON_CAPTURE_SRC}
                ${WIRESHARK_COMMON_SRC}
        )
+endif()
+
+if(BUILD_wireshark AND GTK_FOUND)
+       set(wireshark_LIBS
+               gtkui
+               ${GTK2_LIBRARIES}
+               ${GTK3_LIBRARIES}
+               ${GTHREAD2_LIBRARIES}
+               codecs
+               ${PORTAUDIO_LIBRARIES}
+               ${LIBEPAN_LIBS}
+               ${APPLE_CORE_SERVICES_LIBRARY}
+               ${APPLE_COCOA_LIBRARY}
+       )
+       # qtshark and wireshark share wireshark_FILES
+
        add_executable(wireshark ${wireshark_FILES})
        add_dependencies(wireshark svnversion)
+       set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(wireshark ${wireshark_LIBS})
        install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
+if(BUILD_qtshark AND QT_FOUND)
+       set(qtshark_LIBS
+               qtui
+               ${QT_LIBRARIES}
+               ${GTHREAD2_LIBRARIES}
+               codecs
+               ${PORTAUDIO_LIBRARIES}
+               ${LIBEPAN_LIBS}
+               ${APPLE_CORE_SERVICES_LIBRARY}
+               ${APPLE_COCOA_LIBRARY}
+       )
+       # qtshark and wireshark share wireshark_FILES
+
+       add_executable(qtshark ${wireshark_FILES})
+       add_dependencies(qtshark svnversion)
+       set_target_properties(qtshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
+       target_link_libraries(qtshark ${qtshark_LIBS})
+       install(TARGETS qtshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
+
+register_tap_files(tshark-tap-register.c
+       ${TSHARK_TAP_SRC}
+)
+
 if(BUILD_tshark)
        set(tshark_LIBS
                ${LIBEPAN_LIBS}
@@ -594,15 +743,17 @@ if(BUILD_tshark)
                tshark-tap-register.c
                tshark.c
                ${TSHARK_TAP_SRC}
+               ${SHARK_COMMON_CAPTURE_SRC}
                ${WIRESHARK_COMMON_SRC}
        )
        add_executable(tshark ${tshark_FILES})
        add_dependencies(tshark svnversion)
+       set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(tshark ${tshark_LIBS})
        install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
-if(BUILD_rawshark)
+if(BUILD_rawshark AND PCAP_FOUND)
        set(rawshark_LIBS
                ${LIBEPAN_LIBS}
                ${APPLE_COCOA_LIBRARY}
@@ -613,6 +764,7 @@ if(BUILD_rawshark)
        )
        add_executable(rawshark ${rawshark_FILES})
        add_dependencies(rawshark svnversion)
+       set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(rawshark ${rawshark_LIBS})
        install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -626,6 +778,7 @@ if(BUILD_dftest)
                util.c
        )
        add_executable(dftest ${dftest_FILES})
+       set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(dftest ${dftest_LIBS})
        install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -639,12 +792,13 @@ if(BUILD_randpkt)
 #              @NSL_LIBS@
                ${CARES_LIBRARIES}
                ${ADNS_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(randpkt_FILES
                randpkt.c
        )
        add_executable(randpkt ${randpkt_FILES})
+       set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(randpkt ${randpkt_LIBS})
        install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -653,19 +807,20 @@ if(BUILD_text2pcap)
        set(text2pcap_LIBS
                wiretap
                ${M_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
-       set(text2pcap_FILES
+       set(text2pcap_CLEAN_FILES
                text2pcap.c
        )
-       set(text2pcap_CLEAN_FILES
-               ${text2pcap_FILES}
+       set(text2pcap_FILES
+               ${text2pcap_CLEAN_FILES}
        )
        add_lex_files(text2pcap_FILES
                text2pcap-scanner.l
        )
        add_executable(text2pcap ${text2pcap_FILES})
        add_dependencies(text2pcap svnversion)
+       set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(text2pcap ${text2pcap_LIBS})
        install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -673,7 +828,7 @@ endif()
 if(BUILD_mergecap)
        set(mergecap_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(mergecap_FILES
                mergecap.c
@@ -682,6 +837,7 @@ if(BUILD_mergecap)
        )
        add_executable(mergecap ${mergecap_FILES})
        add_dependencies(mergecap svnversion)
+       set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(mergecap ${mergecap_LIBS})
        install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -689,7 +845,7 @@ endif()
 if(BUILD_capinfos)
        set(capinfos_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${GCRYPT_LIBRARIES}
                ${APPLE_COCOA_LIBRARY}
        )
@@ -698,6 +854,8 @@ if(BUILD_capinfos)
                ${WTAP_PLUGIN_SOURCES}
        )
        add_executable(capinfos ${capinfos_FILES})
+       add_dependencies(capinfos svnversion)
+       set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(capinfos ${capinfos_LIBS})
        install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -705,31 +863,32 @@ endif()
 if(BUILD_editcap)
        set(editcap_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(editcap_FILES
                editcap.c
-               epan/crypt/crypt-md5.c
+               epan/crypt/md5.c
                epan/nstime.c
                ${WTAP_PLUGIN_SOURCES}
        )
        add_executable(editcap ${editcap_FILES})
        add_dependencies(editcap svnversion)
+       set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(editcap ${editcap_LIBS})
        install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
-if(BUILD_dumpcap)
+if(BUILD_dumpcap AND PCAP_FOUND)
        set(dumpcap_LIBS
-               wiretap
 #              @INET_NTOP_LO@
+               wsutil
                ${PCAP_LIBRARIES}
                ${CAP_LIBRARIES}
 #              @SOCKET_LIBS@
 #              @NSL_LIBS@
-               ${GCRYPT_LIBRARIES}
-               ${GNUTLS_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${GLIB2_LIBRARIES}
+               ${GTHREAD2_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${APPLE_COCOA_LIBRARY}
        )
        set(dumpcap_FILES
@@ -749,17 +908,18 @@ if(BUILD_dumpcap)
        )
        add_executable(dumpcap ${dumpcap_FILES})
        add_dependencies(dumpcap svnversion)
+       set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
        target_link_libraries(dumpcap ${dumpcap_LIBS})
        install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
 ADD_CUSTOM_COMMAND(
-       OUTPUT  AUTHORS-SHORT
+       OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
        COMMAND ${PERL}
                ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
                ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
                < ${CMAKE_SOURCE_DIR}/AUTHORS
-               > AUTHORS-SHORT
+               > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
        DEPENDS
                ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
                ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
@@ -767,60 +927,48 @@ ADD_CUSTOM_COMMAND(
 )
 
 ADD_CUSTOM_COMMAND(
-       OUTPUT  AUTHORS-SHORT-FORMAT
-               wireshark.pod
+       OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
+               ${CMAKE_BINARY_DIR}/wireshark.pod
        COMMAND ${PERL}
                ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
                ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
-               < AUTHORS-SHORT
-               > AUTHORS-SHORT-FORMAT
+               < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
+               > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
        COMMAND cat
                ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
-               AUTHORS-SHORT-FORMAT
-               > wireshark.pod
+               ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
+               > ${CMAKE_BINARY_DIR}/wireshark.pod
        DEPENDS
                ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
                ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
-               AUTHORS-SHORT
+               ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
                ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
 )
 
-ADD_CUSTOM_COMMAND(
-       OUTPUT  wireshark-filter.pod
-       COMMAND tshark
-               -G fields |
-               ${PERL}
-               ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
-               ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
-               > wireshark-filter.pod
-       DEPENDS
-               ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
-               ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
-               tshark
-)
-
-find_package(POD)
-
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
 pod2manhtml( wireshark 1 )
-pod2manhtml( wireshark-filter 4 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
 
 add_custom_target(
        auxiliary ALL
        DEPENDS
                AUTHORS-SHORT
                capinfos.html
+               dftest.html
                dumpcap.html
                editcap.html
                idl2wrs.html
                mergecap.html
+               randpkt.html
                rawshark.html
                text2pcap.html
                tshark.html
@@ -830,10 +978,12 @@ add_custom_target(
 
 set(MAN1_FILES
        ${CMAKE_BINARY_DIR}/capinfos.1
+       ${CMAKE_BINARY_DIR}/dftest.1
        ${CMAKE_BINARY_DIR}/dumpcap.1
        ${CMAKE_BINARY_DIR}/editcap.1
        ${CMAKE_BINARY_DIR}/idl2wrs.1
        ${CMAKE_BINARY_DIR}/mergecap.1
+       ${CMAKE_BINARY_DIR}/randpkt.1
        ${CMAKE_BINARY_DIR}/rawshark.1
        ${CMAKE_BINARY_DIR}/text2pcap.1
        ${CMAKE_BINARY_DIR}/tshark.1