Prepare the cmake infrastucture for eventually building
[metze/wireshark/wip.git] / CMakeLists.txt
index 446d49705e12609869afd7a705ef0137adb5dcde..a0e770f24ce4031aa5b6963e585cb3741f474caa 100644 (file)
@@ -27,9 +27,11 @@ 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)
+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)
+endif(COMMAND cmake_policy)
 
 # set(PROJECT_VERSION "1.3.4-rc5")
 # set(PROJECT_VERSION "1.3.4rc5")
@@ -77,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)
@@ -158,7 +160,8 @@ endif()
 
 add_definitions(
        -DHAVE_CONFIG_H
-       -DPACKAGE=\"wireshark\"
+       -DG_DISABLE_DEPRECATED
+       -DG_DISABLE_SINGLE_INCLUDES
 )
 
 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
@@ -179,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)
@@ -225,24 +228,35 @@ endif()
 # - set HAVE_XXX
 
 #The minimum package list
-set(PACKAGELIST GLIB2 GMODULE2 PCAP M LEX YACC Perl SH PythonInterp)
+set(PACKAGELIST GLIB2 GMODULE2 GTHREAD2 M LEX YACC Perl SH PythonInterp)
 set(GLIB2_FIND_REQUIRED)
-set(GLIB2_MIN_VERSION 2.4.0)
+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 ${PACKAGELIST} GTK2)
-       set(GTK2_OPTIONS COMPONENTS gtk)
-       set(GTK2_DEBUG false)
+       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()
 
-if(BUILD_dumpcap)
-       set(PACKAGELIST ${PACKAGELIST} GTHREAD2)
-       set(GHTREAD2_REQUIRED)
+# Build the Qt GUI?
+if(BUILD_qtshark)
+       set(PACKAGELIST ${PACKAGELIST} QT)
+       # set(QT_OPTIONS 4.7.1 REQUIRED QtCore QtGui)
 endif()
 
 # SMI SNMP
@@ -260,11 +274,6 @@ if(ENABLE_GNUTLS)
        set(PACKAGELIST ${PACKAGELIST} GNUTLS)
 endif()
 
-# Regular expressions lib
-if(ENABLE_PCRE)
-       set(PACKAGELIST ${PACKAGELIST} PCRE)
-endif()
-
 # Kerberos
 if(ENABLE_KERBEROS)
        set(PACKAGELIST ${PACKAGELIST} KERBEROS)
@@ -316,12 +325,17 @@ set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
 
 #Let's loop the package list
 foreach(PACKAGE ${PACKAGELIST})
+       if(${PACKAGE} EQUAL "QT")
+               set(PACKAGE_NAME "Qt4")
+       else()
+               set(PACKAGE_NAME ${PACKAGE})
+       endif()
        if(${PACKAGE}_OPTIONS)
-               find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
+               find_package(${PACKAGE_NAME} ${${PACKAGE}_OPTIONS})
        elseif(${PACKAGE}_REQUIRED)
-               find_package(${PACKAGE} REQUIRED)
+               find_package(${PACKAGE_NAME} REQUIRED)
        else()
-               find_package(${PACKAGE})
+               find_package(${PACKAGE_NAME})
        endif()
        message(${PACKAGE}_FOUND)
        if (${PACKAGE}_FOUND)
@@ -361,6 +375,10 @@ 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)
@@ -383,7 +401,6 @@ if(ENABLE_PLUGINS)
                plugins/ethercat
                plugins/giop
                plugins/gryphon
-               plugins/interlink
                plugins/irda
                plugins/m2m
                plugins/mate
@@ -415,10 +432,15 @@ add_subdirectory( tools/lemon )
 add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
-if(BUILD_wireshark AND GTK2_FOUND)
-       add_subdirectory( gtk )
+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}")
@@ -427,6 +449,10 @@ 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")
@@ -460,7 +486,8 @@ PRINT_ENABLED_FEATURES()
 PRINT_DISABLED_FEATURES()
 
 link_directories(
-       ${CMAKE_BINARY_DIR}/gtk
+       ${CMAKE_BINARY_DIR}/ui/gtk
+       ${CMAKE_BINARY_DIR}/ui/qt
        ${CMAKE_BINARY_DIR}/codecs
        ${CMAKE_BINARY_DIR}/epan
        ${CMAKE_BINARY_DIR}/wiretap
@@ -485,10 +512,6 @@ ADD_CUSTOM_COMMAND(
                ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
 )
 
-register_tap_files(tshark-tap-register.c
-       ${TSHARK_TAP_SRC}
-)
-
 ADD_CUSTOM_COMMAND(
        OUTPUT  ps.c
        COMMAND ${PYTHON_EXECUTABLE}
@@ -519,7 +542,6 @@ set(WTAP_PLUGIN_SOURCES
 )
 
 set(SHARK_COMMON_CAPTURE_SRC
-       capture_errs.c
        capture_ifinfo.c
        capture_ui_utils.c
 )
@@ -552,23 +574,28 @@ set(TSHARK_TAP_SRC
        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
@@ -621,7 +648,6 @@ set(LIBEPAN_LIBS
 #              @SSL_LIBS@      # -lcrypto
                epan
 #              $(plugin_ldadd) # in case of static
-               ${PCRE_LIBRARIES}
                ${PCAP_LIBRARIES}
                ${CARES_LIBRARIES}
                ${ADNS_LIBRARIES}
@@ -636,16 +662,7 @@ set(LIBEPAN_LIBS
                ${M_LIBRARIES}
 )
 
-if(BUILD_wireshark AND GTK2_FOUND)
-       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
@@ -660,12 +677,29 @@ if(BUILD_wireshark AND GTK2_FOUND)
                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}")
@@ -673,6 +707,30 @@ if(BUILD_wireshark AND GTK2_FOUND)
        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}
@@ -695,7 +753,7 @@ if(BUILD_tshark)
        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}
@@ -809,7 +867,7 @@ if(BUILD_editcap)
        )
        set(editcap_FILES
                editcap.c
-               epan/crypt/crypt-md5.c
+               epan/crypt/md5.c
                epan/nstime.c
                ${WTAP_PLUGIN_SOURCES}
        )
@@ -820,7 +878,7 @@ if(BUILD_editcap)
        install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
-if(BUILD_dumpcap)
+if(BUILD_dumpcap AND PCAP_FOUND)
        set(dumpcap_LIBS
 #              @INET_NTOP_LO@
                wsutil