If something is only supposed to be included if we have libpcap, don't
[obnox/wireshark/wip.git] / CMakeLists.txt
index 568dc7b1f6ef51a9ea2a5c41c938786009d33a51..e30a8a52ef919b89a4c16d7b38816da6c13d838e 100644 (file)
@@ -117,7 +117,7 @@ option(ENABLE_GUIDES     "Build Guides" ON)
 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_ZLIB       "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)
@@ -213,12 +213,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)
@@ -277,8 +291,8 @@ elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
 endif()
 
 # Zlib compression
-if(ENABLE_Z)
-       set(PACKAGELIST Z ${PACKAGELIST})
+if(ENABLE_ZLIB)
+       set(PACKAGELIST ZLIB ${PACKAGELIST})
 endif()
 
 # Lua 5.1 dissectors
@@ -367,6 +381,7 @@ if(ENABLE_PLUGINS)
                plugins/ethercat
                plugins/giop
                plugins/gryphon
+               plugins/interlink
                plugins/irda
                plugins/m2m
                plugins/mate
@@ -642,6 +657,7 @@ if(BUILD_wireshark)
        )
        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()
@@ -663,6 +679,7 @@ if(BUILD_tshark)
        )
        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()
@@ -678,6 +695,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()
@@ -691,6 +709,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()
@@ -710,6 +729,7 @@ if(BUILD_randpkt)
                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()
@@ -728,6 +748,7 @@ if(BUILD_text2pcap)
        )
        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()
@@ -744,6 +765,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()
@@ -760,6 +782,7 @@ if(BUILD_capinfos)
                ${WTAP_PLUGIN_SOURCES}
        )
        add_executable(capinfos ${capinfos_FILES})
+       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()
@@ -777,6 +800,7 @@ if(BUILD_editcap)
        )
        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()
@@ -811,6 +835,7 @@ 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()