5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 cmake_minimum_required(VERSION 2.6)
28 #Where to find local cmake scripts
29 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
32 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
34 # Disable this later. Alternative: "make VERBOSE=1"
35 set(CMAKE_VERBOSE_MAKEFILE ON)
37 set(BUILD_SHARED_LIBS ON)
39 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
40 include(CMakeInstallDirs)
46 ${CMAKE_SOURCE_DIR}/epan
47 ${CMAKE_SOURCE_DIR}/tools/lemon
48 ${CMAKE_SOURCE_DIR}/wiretap
51 #Where to put libraries
52 if(NOT LIBRARY_OUTPUT_PATH)
53 set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
54 "Single output directory for building all libraries.")
57 option(BUILD_wireshark "Build the GUI version of Wireshark" ON)
58 option(BUILD_tshark "Build tshark" ON)
59 option(BUILD_rawshark "Build rawshark" ON)
60 option(BUILD_dumpcap "Build dumpcap" ON)
61 option(BUILD_text2pcap "Build text2pcap" ON)
62 option(BUILD_mergecap "Build mergecap" ON)
63 option(BUILD_editcap "Build editcap" ON)
64 option(BUILD_capinfos "Build capinfos" ON)
65 option(BUILD_randpkt "Build randpkt" ON)
66 option(BUILD_dftest "Build dftest" ON)
68 option(DISABLE_WERROR "Do not treat Warnings as errors" OFF)
69 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" ON)
70 option(ENABLE_AIRPCAP "Enable Airpcap support" ON)
72 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
73 option(ENABLE_PLUGINS "Build with plugins" ON)
75 option(ENABLE_ADNS "Build with adns support" ON)
76 option(ENABLE_PCRE "Build with pcre support" ON)
77 option(ENABLE_PORTAUDIO "Build with portaudio support" ON)
78 option(ENABLE_Z "Build with zlib compression support" ON)
79 # todo wslua currently seems to be broken
80 option(ENABLE_LUA "Build with lua dissector support" OFF)
81 option(ENABLE_PYTHON "Build with python dissector support" ON)
82 option(ENABLE_SMI "Build with smi snmp support" ON)
83 option(ENABLE_GNUTLS "Build with GNU TLS support" ON)
84 option(ENABLE_GCRYPT "Build with GNU crypto support" ON)
85 option(ENABLE_GEOIP "Build with GeoIP support" ON)
86 option(ENABLE_CAP "Build with posix capabilities support" ON)
87 option(ENABLE_CARES "Build with c_ares support" ON)
88 # todo Mostly hardcoded
89 option(ENABLE_KERBEROS "Build with Kerberos support" ON)
93 # todo Workaround for problem described below
100 -Wdeclaration-after-statement
109 set(WIRESHARK_EXTRA_C_FLAGS
113 -Wno-overlength-strings
114 -fstrict-overflow -Wstrict-overflow=4
116 -Wunsafe-loop-optimizations
129 # packet-ncp2222.inc prevents this from going into all warnings
132 -Wmissing-declarations
133 # Problem with packet-afs.c
135 # More cleanup needed for this on LP64
139 if(ENABLE_EXTRA_GCC_CHECKS)
140 set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
145 -DPACKAGE=\"wireshark\"
150 # This doesn't actually work because of some cache magic in
151 # CHECK_C_SOURCE_COMPILES
152 include(CheckCCompilerFlag)
153 foreach(WS_C_FLAG ${WIRESHARK_C_FLAGS})
154 message(STATUS "Flag pre: ${WS_C_FLAG}")
155 check_c_compiler_flag(${WS_C_FLAG} WS_C_FLAG_VALID)
156 if (${WS_C_FLAG_VALID})
157 add_definitions(${WS_C_FLAG})
159 message(STATUS "Flag post ${WS_C_FLAG}: ${WS_C_FLAG_VALID}")
160 #set(WS_C_FLAG_VALID "" CACHE INTERNAL "Dummy" )
163 if(DISABLE_WERROR OR ENABLE_EXTRA_GCC_CHECKS)
164 remove_definitions( -Werror )
167 if(CMAKE_COMPILER_IS_GNUCC)
168 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
170 add_definitions( -D_U_=\"\" )
174 # Same for linker flags, but it looks like it's do-it-yourself here
175 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
177 #The minimum package list
178 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
182 set(PACKAGELIST GTK2 ${PACKAGELIST})
187 set(PACKAGELIST SMI ${PACKAGELIST})
192 set(PACKAGELIST GCRYPT ${PACKAGELIST})
195 # GNU SSL/TLS support
197 set(PACKAGELIST GNUTLS ${PACKAGELIST})
200 # Regular expressions lib
202 set(PACKAGELIST PCRE ${PACKAGELIST})
207 set(PACKAGELIST KERBEROS ${PACKAGELIST})
212 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
216 # Prefer c-ares over adns
217 if(ENABLE_CARES) # C Asynchronouse resolver
218 set(PACKAGELIST CARES ${PACKAGELIST})
219 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
220 set(PACKAGELIST ADNS ${PACKAGELIST})
225 set(PACKAGELIST Z ${PACKAGELIST})
230 set(PACKAGELIST LUA ${PACKAGELIST})
233 # GeoIP address resolving
235 set(PACKAGELIST GEOIP ${PACKAGELIST})
240 set(PACKAGELIST CAP ${PACKAGELIST})
244 set(PACKAGELIST PYTHON ${PACKAGELIST})
247 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
249 #Let's loop the package list
250 foreach(PACKAGE ${PACKAGELIST})
251 find_package(${PACKAGE} REQUIRED)
252 message(${PACKAGE}_FOUND)
253 if (${PACKAGE}_FOUND)
254 set(HAVE_LIB${PACKAGE} 1)
255 include_directories(${${PACKAGE}_INCLUDE_DIRS})
256 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
257 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
263 set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${VERSION}")
271 # HAVE_HEIMDAL_KERBEROS
272 set(HAVE_MIT_KERBEROS 1)
273 set(HAVE_KEYTYPE_ARCFOUR_56 1)
289 set(CPACK_PACKAGE_NAME wireshark)
290 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
291 set(CPACK_PACKAGE_VENDOR "wireshark")
292 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
293 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
294 set(CPACK_PACKAGE_VERSION_MAJOR "1")
295 set(CPACK_PACKAGE_VERSION_MINOR "3")
296 set(CPACK_PACKAGE_VERSION_PATCH "0")
297 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
299 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
300 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
301 set(CPACK_GENERATOR "TGZ")
302 set(CPACK_SOURCE_GENERATOR "TGZ")
304 include(ConfigureChecks.cmake)
306 #Big or little endian ?
307 include(TestBigEndian)
308 test_big_endian(WORDS_BIGENDIAN)
310 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
314 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
334 set(PLUGIN_SRC_DIRS )
337 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
338 add_subdirectory( ${PLUGIN_DIR} )
343 set(WS_VAR_IMPORT "extern")
347 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
348 set(HAVE_OS_X_FRAMEWORKS 1)
349 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
350 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
354 add_definitions(-D_NEED_VAR_IMPORT_)
355 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
357 # Disable deprecation
359 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
364 add_subdirectory( codecs )
365 add_subdirectory( epan )
366 add_subdirectory( gtk )
367 add_subdirectory( wiretap )
368 add_subdirectory( wsutil )
371 add_subdirectory( plugins )
374 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
385 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
386 COMMAND ${PERL} ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
387 ${CMAKE_CURRENT_SOURCE_DIR}
389 SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/svnversion.h GENERATED)
391 # Create the necessary tools
396 # Do we need something here on any platform?
398 add_executable(lemon ${lemon_FILES})
399 target_link_libraries(lemon ${lemon_LIBS})
403 OUTPUT tshark-tap-register.c
405 ${CMAKE_SOURCE_DIR}/make-tapreg-dotc
406 tshark-tap-register.c
407 ${CMAKE_CURRENT_SOURCE_DIR}
410 ${CMAKE_SOURCE_DIR}/make-tapreg-dotc
416 COMMAND ${PYTHON_EXECUTABLE}
417 ${CMAKE_CURRENT_SOURCE_DIR}/rdps.py
418 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
421 ${CMAKE_CURRENT_SOURCE_DIR}/rdps.py
422 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
427 capture-pcap-util-unix.c
433 capture-wpcap.c capture_wpcap_packet.c
437 set(WTAP_PLUGIN_SOURCES
443 set(WIRESHARK_COMMON_SRC
523 # wireshark-filter.html
529 # $(wireshark_optional_objects)
544 ${KERBEROS_LIBRARIES}
561 ${PORTAUDIO_LIBRARIES}
563 ${APPLE_CORE_SERVICES_LIBRARY}
564 ${APPLE_COCOA_LIBRARY}
582 ${WIRESHARK_COMMON_SRC}
584 add_executable(wireshark ${wireshark_FILES})
585 target_link_libraries(wireshark ${wireshark_LIBS})
586 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
592 ${APPLE_COCOA_LIBRARY}
598 tshark-tap-register.c
601 ${WIRESHARK_COMMON_SRC}
603 add_executable(tshark ${tshark_FILES})
604 target_link_libraries(tshark ${tshark_LIBS})
605 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
611 ${APPLE_COCOA_LIBRARY}
614 ${WIRESHARK_COMMON_SRC}
617 add_executable(rawshark ${rawshark_FILES})
618 target_link_libraries(rawshark ${rawshark_LIBS})
619 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
630 add_executable(dftest ${dftest_FILES})
631 target_link_libraries(dftest ${dftest_LIBS})
632 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
651 add_executable(randpkt ${randpkt_FILES})
652 target_link_libraries(randpkt ${randpkt_LIBS})
653 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
667 add_lex_files(text2pcap_FILES
670 add_executable(text2pcap ${text2pcap_FILES})
671 target_link_libraries(text2pcap ${text2pcap_LIBS})
672 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
687 add_executable(mergecap ${mergecap_FILES})
688 target_link_libraries(mergecap ${mergecap_LIBS})
689 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
698 ${APPLE_COCOA_LIBRARY}
702 ${WTAP_PLUGIN_SOURCES}
704 add_executable(capinfos ${capinfos_FILES})
705 target_link_libraries(capinfos ${capinfos_LIBS})
706 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
718 epan/crypt/crypt-md5.c
720 ${WTAP_PLUGIN_SOURCES}
722 add_executable(editcap ${editcap_FILES})
723 target_link_libraries(editcap ${editcap_LIBS})
724 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
741 ${APPLE_COCOA_LIBRARY}
747 capture_stop_conditions.c
758 add_executable(dumpcap ${dumpcap_FILES})
759 target_link_libraries(dumpcap ${dumpcap_LIBS})
760 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
767 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
774 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
775 PATTERN ".svn" EXCLUDE
776 PATTERN "Makefile.*" EXCLUDE
777 PATTERN "faq.py" EXCLUDE