Allow make-version.pl to use git when missing from path
[metze/wireshark/wip.git] / CMakeLists.txt
index 1f3b00769851124933b6b402379b891192b68d97..50d645d18358aac38fe1d749d1e7ad23d780c0ba 100644 (file)
@@ -359,7 +359,6 @@ else()
                -Wignored-qualifiers
                -Wpragmas
                -Wno-overlength-strings
-               -Wwrite-strings
                -Wno-long-long
                -Wheader-guard
                -Wunused-const-variable
@@ -386,6 +385,10 @@ else()
        set(WIRESHARK_EXTRA_COMPILER_COMMON_FLAGS
                # The following are for C and C++
                -Wpedantic
+               #
+               # As we use variadic macros, we don't want warnings
+               # about them, even with -Wpedantic.
+               #
                -Wno-variadic-macros
                #
                # Various code blocks this one.
@@ -561,7 +564,7 @@ endif()
 #
 if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
        #
-       # Try the GCC-and-copatible -fvisibility-hidden first.
+       # Try the GCC-and-compatible -fvisibility-hidden first.
        #
        check_c_compiler_flag(-fvisibility=hidden FVHIDDEN)
        if(FVHIDDEN)
@@ -592,25 +595,22 @@ else()
        set (C_UNUSED "" )
 endif()
 
-
-if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
-       set(WIRESHARK_LD_FLAGS
-               -Wl,--as-needed
-               # -flto
-               # -fwhopr
-               # -fwhole-program
+set(WIRESHARK_LD_FLAGS
+       -Wl,--as-needed
+       # -flto
+       # -fwhopr
+       # -fwhole-program
+)
+# CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake
+# 2.8.9. Do not add -pie automatically for older versions.
+#
+# XXX - are there other compilers that don't support -pie?  It's
+# not as if the only platforms we support are Windows and Linux....
+#
+if(NOT CMAKE_VERSION VERSION_LESS "2.8.9")
+       set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS}
+               -pie
        )
-       # CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake
-       # 2.8.9. Do not add -pie automatically for older versions.
-       #
-       # XXX - are there other compilers that don't support -pie?  It's
-       # not as if the only platforms we support are Windows and Linux....
-       #
-       if(NOT CMAKE_VERSION VERSION_LESS "2.8.9")
-               set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS}
-                       -pie
-               )
-       endif()
 endif()
 
 include(CheckCLinkerFlag)
@@ -642,7 +642,7 @@ endif()
 # - set HAVE_XXX
 
 #The minimum package list
-set(PACKAGELIST Gettext M GLIB2 GMODULE2 GTHREAD2 LEX YACC Perl SED SH PythonInterp)
+set(PACKAGELIST Gettext M Git GLIB2 GMODULE2 GTHREAD2 LEX YACC Perl SED SH PythonInterp)
 set(LEX_REQUIRED TRUE)
 set(GLIB2_REQUIRED TRUE)
 set(GLIB2_FIND_REQUIRED TRUE)
@@ -754,7 +754,9 @@ if(ENABLE_ZLIB)
        if (WIN32)
                # On Windows we build our own version of zlib, so add the paths
                set(ZLIB_SRC_DIR "${_PROJECT_LIB_DIR}/zlib-1.2.8-ws")
+               set(SKIP_INSTALL_ALL True) # We copy the DLL ourselves.
                add_subdirectory("${ZLIB_SRC_DIR}" "${CMAKE_BINARY_DIR}/zlib")
+               unset(SKIP_INSTALL_ALL)
                set(ZLIB_INCLUDE_DIR  "${ZLIB_SRC_DIR}" "${CMAKE_BINARY_DIR}/zlib")
                set(ZLIB_LIBRARY zlib)
                set(ZLIB_DLL "zlib1.dll")
@@ -1009,7 +1011,7 @@ add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
 if(NOT WIN32)
-       add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil color.h)
+       add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil)
 endif()
 
 if(ENABLE_ECHLD)
@@ -1037,15 +1039,17 @@ endif()
 
 set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.")
 
-if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
-       set(ABSOLUTE_CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
-else()
-       set(ABSOLUTE_CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
-endif()
-
 if(ENABLE_EXTCAP)
+       # Target platform locations
+       # UNIX, Linux, non-bundled OS X: $DESTDIR/lib/wireshark/extcap
+       # Windows: $DESTDIR/extcap
+       # OS X app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap
        set(HAVE_EXTCAP 1)
-       set(EXTCAP_DIR "${ABSOLUTE_CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/extcap/")
+       if (WIN32)
+               set(EXTCAP_DIR "extcap")
+       else ()
+               set(EXTCAP_DIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/extcap")
+       endif()
 endif()
 
 if(LIBSSH_FOUND)
@@ -1059,10 +1063,18 @@ endif()
 # Location of our plugins. PLUGIN_DIRECTORY should allow running
 # from the build directory similar to DATAFILE_DIR above.
 if(ENABLE_PLUGINS)
+       # Target platform locations
+       # UNIX, Linux, non-bundled OS X: $DESTDIR/lib/wireshark/plugins/$VERSION
+       # Windows: $DESTDIR/wireshark/plubins/$VERSION
+       # OS X app bundle: Wireshark.app/Contents/PlugIns/wireshark
        set(HAVE_PLUGINS 1)
        add_custom_target(plugins)
        set_target_properties(plugins PROPERTIES FOLDER "Plugins")
-       set(PLUGIN_INSTALL_DIR "${ABSOLUTE_CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins/${CPACK_PACKAGE_VERSION}")
+       if (WIN32)
+               set(PLUGIN_INSTALL_DIR "plugins/${CPACK_PACKAGE_VERSION}")
+       else ()
+               set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins/${CPACK_PACKAGE_VERSION}")
+       endif()
        set(PLUGIN_SRC_DIRS
                plugins/docsis
                plugins/ethercat
@@ -1130,11 +1142,14 @@ else()
        set(WS_MSVC_NORETURN " ")
 endif()
 
+if (${GIT_EXECUTABLE})
+       set(GIT_BIN_PARAM "--git-bin ${GIT_EXECUTABLE}")
+endif()
 set( VERSION ${PROJECT_VERSION} )
 execute_process(
        COMMAND ${PERL_EXECUTABLE}
                ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
-               --print-vcs
+               --print-vcs ${GIT_BIN_PARAM}
                ${CMAKE_CURRENT_SOURCE_DIR}
        OUTPUT_VARIABLE VERSION_H_CONTENT
 )
@@ -1143,6 +1158,12 @@ configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h
 configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
 #set_target_properties(${CMAKE_BINARY_DIR}/version.h PROPERTIES FOLDER "Auxiliary")
 
+set( prefix "${CMAKE_INSTALL_PREFIX}" )
+set( exec_prefix "\${prefix}" )
+set( libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}" )
+set( includedir  "\${prefix}/include" )
+set( plugindir "\${libdir}/wireshark/plugins/${CPACK_PACKAGE_VERSION}" )
+
 set(ICON_PATH "${CMAKE_SOURCE_DIR}/image/")
 set( IN_FILES
        adns_dll.rc
@@ -1291,6 +1312,7 @@ set(INSTALL_FILES
        ${CMAKE_BINARY_DIR}/mergecap.html
        pdml2html.xsl
        ${CMAKE_BINARY_DIR}/randpkt.html
+       ${CMAKE_BINARY_DIR}/randpktdump.html
        ${CMAKE_BINARY_DIR}/rawshark.html
        ${CMAKE_BINARY_DIR}/reordercap.html
        services
@@ -1322,6 +1344,7 @@ set(MAN1_FILES
        ${CMAKE_BINARY_DIR}/idl2wrs.1
        ${CMAKE_BINARY_DIR}/mergecap.1
        ${CMAKE_BINARY_DIR}/randpkt.1
+       ${CMAKE_BINARY_DIR}/androiddump.1
        ${CMAKE_BINARY_DIR}/rawshark.1
        ${CMAKE_BINARY_DIR}/reordercap.1
        ${CMAKE_BINARY_DIR}/sshdump.1
@@ -1583,9 +1606,15 @@ if(ENABLE_EXTCAP)
        )
        list(APPEND copy_data_files_depends "${DATAFILE_DIR}/extcap")
 endif()
+set(_help_files
+       help/capture_filters.txt
+       help/capturing.txt
+       help/display_filters.txt
+       help/getting_started.txt
+       help/overview.txt
+)
 if(WIN32)
        file(TO_NATIVE_PATH "${DATAFILE_DIR}/help" _help_dest_dir)
-       file(GLOB _help_files RELATIVE "${CMAKE_SOURCE_DIR}" "help/*.txt")
        foreach(_help_file IN LISTS _help_files)
                add_custom_command(OUTPUT "${DATAFILE_DIR}/${_help_file}"
                        COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/help"
@@ -1598,7 +1627,7 @@ if(WIN32)
                list(APPEND copy_data_files_depends "${DATAFILE_DIR}/${_help_file}")
        endforeach()
 else()
-       list(APPEND DATA_FILES_SRC "help/*.txt")
+       list(APPEND DATA_FILES_SRC ${_help_files})
 endif(WIN32)
 
 # Create help/faq.txt when missing
@@ -1617,7 +1646,7 @@ list(APPEND copy_data_files_depends "${DATAFILE_DIR}/help/faq.txt")
 # Install LUA files in staging directory such that LUA can used when Wireshark
 # is ran from the build directory. For install targets, see
 # epan/wslua/CMakeLists.txt
-if(LUA_FOUND)
+if(LUA_FOUND AND ENABLE_LUA)
        set(_lua_files
                "${CMAKE_BINARY_DIR}/epan/wslua/init.lua"
                "${CMAKE_SOURCE_DIR}/epan/wslua/console.lua"
@@ -1636,7 +1665,7 @@ if(LUA_FOUND)
                                "${_lua_file}"
                )
        endforeach()
-endif(LUA_FOUND)
+endif(LUA_FOUND AND ENABLE_LUA)
 # doc/*.html handled elsewhere.
 
 # TODO shouldn't this use full (relative) paths instead of glob patterns?
@@ -1678,7 +1707,6 @@ if( (BUILD_wireshark AND QT_FOUND) OR (BUILD_wireshark_gtk AND GTK_FOUND) )
        set(WIRESHARK_SRC
                capture_info.c
                capture_opts.c
-               color_filters.c
                file.c
                fileset.c
                summary.c
@@ -2353,6 +2381,24 @@ elseif (BUILD_sshdump)
        #message( WARNING "Cannot find libssh, cannot build sshdump" )
 endif()
 
+if(BUILD_randpktdump)
+       set(randpktdump_LIBS
+               wiretap
+               ${GLIB2_LIBRARIES}
+               ${CMAKE_DL_LIBS}
+       )
+       set(randpktdump_FILES
+               extcap/randpktdump.c
+               randpkt-core.c
+       )
+
+       add_executable(randpktdump WIN32 ${randpktdump_FILES})
+       # XXX Shouldn't we add wsutil to randpktdump_LIBS instead?
+       set_extcap_executable_properties(randpktdump)
+       target_link_libraries(randpktdump ${randpktdump_LIBS})
+       install(TARGETS randpktdump RUNTIME DESTINATION ${EXTCAP_DIR})
+endif()
+
 ADD_CUSTOM_COMMAND(
        OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
        COMMAND ${PERL_EXECUTABLE}
@@ -2472,6 +2518,7 @@ pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2deb 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/randpktdump 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/reordercap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/sshdump 1 )
@@ -2495,6 +2542,7 @@ add_custom_target(
                idl2wrs.html
                mergecap.html
                randpkt.html
+               randpktdump.html
                rawshark.html
                reordercap.html
                sshdump.html
@@ -2511,6 +2559,7 @@ set(CLEAN_FILES
        ${rawshark_FILES}
        ${dftest_FILES}
        ${randpkt_FILES}
+       ${randpktdump_FILES}
        ${text2pcap_CLEAN_FILES}
        ${mergecap_FILES}
        ${capinfos_FILES}