From Colin O'Flynn:
[obnox/wireshark/wip.git] / CMakeLists.txt
index 29f1da6fccb9f01ecfc7105a67b9371282fbb088..118fab5b22b2b7f1cd684cf1e0cd36eb00032193 100644 (file)
@@ -21,7 +21,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
 
-project(Wireshark C)
+project(Wireshark C CXX)
 
 cmake_minimum_required(VERSION 2.6)
 set(CMAKE_BACKWARDS_COMPATIBILITY 2.6)
@@ -182,13 +182,13 @@ 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)
-       add_definitions( -D_U_=__attribute__\(\(unused\)\) )
+       set (C_UNUSED "__attribute__((unused))" )
 else()
-       add_definitions( -D_U_=\"\" )
+       set (C_UNUSED "" )
 endif()
 
 set(WIRESHARK_LD_FLAGS
@@ -241,7 +241,7 @@ if(ENABLE_PCAP)
        set(PACKAGELIST ${PACKAGELIST} PCAP)
 endif()
 
-#Build the gui ?
+# Build the GTK-GUI?
 if(BUILD_wireshark)
        if(ENABLE_GTK3)
                set(PACKAGELIST ${PACKAGELIST} GTK3)
@@ -253,6 +253,12 @@ if(BUILD_wireshark)
        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 ${PACKAGELIST} SMI)
@@ -319,12 +325,17 @@ set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
 
 #Let's loop the package list
 foreach(PACKAGE ${PACKAGELIST})
+       if(${PACKAGE} STREQUAL "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)
@@ -372,6 +383,13 @@ endif()
 if(HAVE_LIBZLIB)
        set(HAVE_LIBZ 1)
 endif()
+# QT_LIBRARIES and QT_INCLUDES are not set above. They require extra magic:
+if(QT_FOUND)
+       include(${QT_USE_FILE})
+       include_directories(${QT_INCLUDE_DIR})
+       message(STATUS "QT includes: ${QT_INCLUDE_DIR}")
+       message(STATUS "QT libs: ${QT_LIBRARIES}")
+endif()
 
 include(ConfigureChecks.cmake)
 
@@ -422,9 +440,14 @@ add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
 if(BUILD_wireshark AND GTK_FOUND)
-       add_subdirectory( gtk )
+       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}")
@@ -470,7 +493,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
@@ -495,10 +519,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}
@@ -649,18 +669,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
@@ -675,12 +684,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}")
@@ -688,6 +714,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}
@@ -824,7 +874,7 @@ if(BUILD_editcap)
        )
        set(editcap_FILES
                editcap.c
-               epan/crypt/crypt-md5.c
+               epan/crypt/md5.c
                epan/nstime.c
                ${WTAP_PLUGIN_SOURCES}
        )