Prepare the cmake infrastucture for eventually building
[metze/wireshark/wip.git] / CMakeLists.txt
index 09100d7fd1f2d1727dc080fa095900921a97853b..a0e770f24ce4031aa5b6963e585cb3741f474caa 100644 (file)
@@ -161,6 +161,7 @@ endif()
 add_definitions(
        -DHAVE_CONFIG_H
        -DG_DISABLE_DEPRECATED
+       -DG_DISABLE_SINGLE_INCLUDES
 )
 
 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
@@ -181,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)
@@ -227,33 +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.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)
        if(ENABLE_GTK3)
                set(PACKAGELIST ${PACKAGELIST} GTK3)
-               set(ENABLE_UI_MANAGER ON)
        else()
                set(PACKAGELIST ${PACKAGELIST} GTK2)
                set(GTK2_OPTIONS COMPONENTS gtk)
                set(GTK2_FIND_VERSION 2.12)
                set(GTK2_DEBUG false)
        endif()
-       if(ENABLE_THREADS)
-               set(PACKAGELIST ${PACKAGELIST} GTHREAD2)
-       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
@@ -322,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)
@@ -425,12 +433,14 @@ add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
 if(BUILD_wireshark AND GTK_FOUND)
-       add_subdirectory( gtk )
-       if (ENABLE_UI_MANAGER)
-               set(MAIN_MENU_USE_UIMANAGER 1)
-       endif()
+       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}")
@@ -443,10 +453,6 @@ if(ENABLE_PCAP_NG_DEFAULT)
        set(PCAP_NG_DEFAULT 1)
 endif()
 
-if(ENABLE_THREADS)
-       set(USE_THREADS 1)
-endif()
-
 #Platform specific
 if(UNIX)
        set(WS_VAR_IMPORT "extern")
@@ -480,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
@@ -505,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}
@@ -539,7 +542,6 @@ set(WTAP_PLUGIN_SOURCES
 )
 
 set(SHARK_COMMON_CAPTURE_SRC
-       capture_errs.c
        capture_ifinfo.c
        capture_ui_utils.c
 )
@@ -572,6 +574,7 @@ 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
@@ -659,18 +662,7 @@ set(LIBEPAN_LIBS
                ${M_LIBRARIES}
 )
 
-if(BUILD_wireshark AND GTK_FOUND)
-       set(wireshark_LIBS
-               ui
-               ${GTK2_LIBRARIES}
-               ${GTK3_LIBRARIES}
-               ${GTHREAD2_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
@@ -685,12 +677,29 @@ if(BUILD_wireshark AND GTK_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}")
@@ -698,6 +707,30 @@ if(BUILD_wireshark AND GTK_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}
@@ -834,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}
        )