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)
27 set(CMAKE_BACKWARDS_COMPATIBILITY 2.6)
29 # set(PROJECT_VERSION "1.3.4-rc5")
30 # set(PROJECT_VERSION "1.3.4rc5")
31 # set(PROJECT_VERSION "1.3.4")
32 # If not set, copy over Wireshark version from configure.in AC_INIT
33 if(NOT PROJECT_VERSION)
35 ${CMAKE_SOURCE_DIR}/configure.in
37 REGEX "\\(wireshark, .*\\)"
39 string(REGEX REPLACE ".*\\(wireshark, (.*)\\).*"
45 string(REGEX REPLACE "([0-9]+)\\..*"
50 string(REGEX REPLACE ".*\\.([0-9]+)\\..*"
55 string(REGEX REPLACE ".*\\..*\\.([0-9]+).*"
60 string(REGEX REPLACE ".*\\..*\\.[0-9]+(.*)"
62 PROJECT_VERSION_EXTENSION
65 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
67 #Where to find local cmake scripts
68 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
70 INCLUDE(UseMakeDissectorReg)
71 INCLUDE(UseMakeTapReg)
73 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
75 # Disable this later. Alternative: "make VERBOSE=1"
76 set(CMAKE_VERBOSE_MAKEFILE ON)
78 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
79 include(CMakeInstallDirs)
84 ${CMAKE_SOURCE_DIR}/epan
85 ${CMAKE_SOURCE_DIR}/tools/lemon
86 ${CMAKE_SOURCE_DIR}/wiretap
89 #Where to put libraries
90 if(NOT LIBRARY_OUTPUT_PATH)
91 set(LIBRARY_OUTPUT_PATH ${Wireshark_BINARY_DIR}/lib CACHE INTERNAL
92 "Single output directory for building all libraries.")
95 option(BUILD_wireshark "Build the GUI version of Wireshark" ON)
96 option(BUILD_tshark "Build tshark" ON)
97 option(BUILD_rawshark "Build rawshark" ON)
98 option(BUILD_dumpcap "Build dumpcap" ON)
99 option(BUILD_text2pcap "Build text2pcap" ON)
100 option(BUILD_mergecap "Build mergecap" ON)
101 option(BUILD_editcap "Build editcap" ON)
102 option(BUILD_capinfos "Build capinfos" ON)
103 option(BUILD_randpkt "Build randpkt" ON)
104 option(BUILD_dftest "Build dftest" ON)
105 option(AUTOGEN_dcerpc "Autogenerate dcerpc dissectors" OFF)
106 option(AUTOGEN_pidl "Autogenerate pidl dissectors" OFF)
108 option(DISABLE_WERROR "Do not treat Warnings as errors" OFF)
109 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" OFF)
110 option(ENABLE_AIRPCAP "Enable Airpcap support" ON)
112 option(ENABLE_STATIC "Build a static version of Wireshark (not yet working)" OFF)
113 option(ENABLE_PLUGINS "Build with plugins" ON)
115 option(ENABLE_GUIDES "Build Guides" ON)
117 option(ENABLE_ADNS "Build with adns support" ON)
118 option(ENABLE_PCRE "Build with pcre support" ON)
119 option(ENABLE_PORTAUDIO "Build with portaudio support" ON)
120 option(ENABLE_ZLIB "Build with zlib compression support" ON)
121 option(ENABLE_LUA "Build with lua dissector support" ON)
122 option(ENABLE_PYTHON "Build with python dissector support" ON)
123 option(ENABLE_SMI "Build with smi snmp support" ON)
124 option(ENABLE_GNUTLS "Build with GNU TLS support" ON)
125 option(ENABLE_GCRYPT "Build with GNU crypto support" ON)
126 option(ENABLE_GEOIP "Build with GeoIP support" ON)
127 option(ENABLE_CAP "Build with posix capabilities support" ON)
128 option(ENABLE_CARES "Build with c_ares support" ON)
129 # todo Mostly hardcoded
130 option(ENABLE_KERBEROS "Build with Kerberos support" ON)
133 set(WIRESHARK_C_FLAGS
138 -Wdeclaration-after-statement
147 set(WIRESHARK_EXTRA_C_FLAGS
151 -Wno-overlength-strings
152 -fstrict-overflow -Wstrict-overflow=4
154 -Wunsafe-loop-optimizations
169 # packet-ncp2222.inc prevents this from going into all warnings
172 -Wmissing-declarations
173 # Problem with packet-afs.c
175 # More cleanup needed for this on LP64
179 if(ENABLE_EXTRA_GCC_CHECKS) # This overrides -Werror
180 set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
185 -DPACKAGE=\"wireshark\"
189 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
190 include(CheckCCompilerFlag)
192 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
193 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
194 set(F WS_C_FLAG_${C})
195 set(${F} ${THIS_FLAG})
196 set(V WS_C_FLAG_VALID${C})
197 check_c_compiler_flag(${${F}} ${V})
199 add_definitions(${${F}})
201 math(EXPR C "${C} + 1")
204 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
205 check_c_compiler_flag(-Werror WERROR)
210 if(CMAKE_COMPILER_IS_GNUCC)
211 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
213 add_definitions( -D_U_=\"\" )
216 set(WIRESHARK_LD_FLAGS
223 include(CheckCLinkerFlag)
225 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
226 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
227 set(F WS_LD_FLAG_${C})
228 set(${F} ${THIS_FLAG})
229 set(V WS_LD_FLAG_VALID${C})
230 check_c_linker_flag(${${F}} ${V})
232 set(WS_LINK_FLAGS ${WS_LINK_FLAGS} ${${F}})
234 math(EXPR C "${C} + 1")
238 set(LINK_MODE_LIB STATIC)
239 set(LINK_MODE_MODULE STATIC)
241 set(LINK_MODE_LIB SHARED)
242 set(LINK_MODE_MODULE MODULE)
245 #The minimum package list
246 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
250 set(PACKAGELIST GTK2 ${PACKAGELIST})
251 set(GTK2_OPTIONS COMPONENTS gtk)
252 set(GTK2_DEBUG false)
257 set(PACKAGELIST SMI ${PACKAGELIST})
262 set(PACKAGELIST GCRYPT ${PACKAGELIST})
265 # GNU SSL/TLS support
267 set(PACKAGELIST GNUTLS ${PACKAGELIST})
270 # Regular expressions lib
272 set(PACKAGELIST PCRE ${PACKAGELIST})
277 set(PACKAGELIST KERBEROS ${PACKAGELIST})
282 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
286 # Prefer c-ares over adns
287 if(ENABLE_CARES) # C Asynchronouse resolver
288 set(PACKAGELIST CARES ${PACKAGELIST})
289 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
290 set(PACKAGELIST ADNS ${PACKAGELIST})
295 set(PACKAGELIST ZLIB ${PACKAGELIST})
300 set(PACKAGELIST LUA ${PACKAGELIST})
303 # GeoIP address resolving
305 set(PACKAGELIST GEOIP ${PACKAGELIST})
310 set(PACKAGELIST CAP ${PACKAGELIST})
314 set(PACKAGELIST PYTHON ${PACKAGELIST})
317 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
319 #Let's loop the package list
320 foreach(PACKAGE ${PACKAGELIST})
321 if(${PACKAGE}_OPTIONS)
322 find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
324 find_package(${PACKAGE} REQUIRED)
326 message(${PACKAGE}_FOUND)
327 if (${PACKAGE}_FOUND)
328 set(HAVE_LIB${PACKAGE} 1)
329 include_directories(${${PACKAGE}_INCLUDE_DIRS})
330 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
331 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
338 include(CPackConfig.txt)
342 set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
350 # HAVE_HEIMDAL_KERBEROS
351 set(HAVE_MIT_KERBEROS 1)
352 set(HAVE_KEYTYPE_ARCFOUR_56 1)
367 include(ConfigureChecks.cmake)
369 #Big or little endian ?
370 include(TestBigEndian)
371 test_big_endian(WORDS_BIGENDIAN)
373 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
377 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
396 # It seems this stuff doesn't build with autofoo either...
398 # set(PLUGIN_SRC_DIRS
404 set(PLUGIN_SRC_DIRS )
407 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
408 add_subdirectory( ${PLUGIN_DIR} )
411 add_subdirectory( codecs )
412 add_subdirectory( epan )
413 add_subdirectory( gtk )
414 add_subdirectory( tools/lemon )
415 add_subdirectory( wiretap )
416 add_subdirectory( wsutil )
419 # FIXME: Disabling the build via option currently doesn't work
420 # add_subdirectory( docbook )
427 set(WS_VAR_IMPORT "extern")
431 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
432 set(HAVE_OS_X_FRAMEWORKS 1)
433 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
434 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
438 add_definitions(-D_NEED_VAR_IMPORT_)
439 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
441 # Disable deprecation
443 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
447 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
449 include(FeatureSummary)
450 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
451 PRINT_ENABLED_FEATURES()
452 PRINT_DISABLED_FEATURES()
465 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
466 ${CMAKE_CURRENT_SOURCE_DIR}
468 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
474 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
475 ${CMAKE_CURRENT_SOURCE_DIR}
477 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
480 register_tap_files(tshark-tap-register.c
486 COMMAND ${PYTHON_EXECUTABLE}
487 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
488 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
491 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
492 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
497 capture-pcap-util-unix.c
503 capture-wpcap.c capture_wpcap_packet.c
507 set(WTAP_PLUGIN_SOURCES
513 set(SHARK_COMMON_CAPTURE_SRC
519 set(WIRESHARK_COMMON_SRC
579 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
581 ${CMAKE_BINARY_DIR}/capinfos.html
585 ${CMAKE_BINARY_DIR}/dumpcap.html
586 ${CMAKE_BINARY_DIR}/editcap.html
587 ${CMAKE_BINARY_DIR}/idl2wrs.html
590 ${CMAKE_BINARY_DIR}/mergecap.html
591 ${CMAKE_BINARY_DIR}/rawshark.html
594 ${CMAKE_BINARY_DIR}/text2pcap.html
595 ${CMAKE_BINARY_DIR}/tshark.html
596 ${CMAKE_BINARY_DIR}/wireshark-filter.html
597 ${CMAKE_BINARY_DIR}/wireshark.html
602 # @GETOPT_O@ # wsgetopt.c
603 # @INET_ATON_LO@ # epan/inet_aton.c
604 # @INET_NTOP_LO@ # inet_ntop.c
605 # @INET_PTON_LO@ # inet_pton.c
607 # @SOCKET_LIBS@ # -lsocket
608 # @SSL_LIBS@ # -lcrypto
609 # @STRERROR_O@ # strerror.c
610 # @STRNCASECMP_O@ # strncasecmp.c
611 # @STRPTIME_O@ # strptime.c
613 # $(plugin_ldadd) # in case of static
618 ${KERBEROS_LIBRARIES}
634 ${PORTAUDIO_LIBRARIES}
636 ${APPLE_CORE_SERVICES_LIBRARY}
637 ${APPLE_COCOA_LIBRARY}
655 ${SHARK_COMMON_CAPTURE_SRC}
656 ${WIRESHARK_COMMON_SRC}
658 add_executable(wireshark ${wireshark_FILES})
659 add_dependencies(wireshark svnversion)
660 set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
661 target_link_libraries(wireshark ${wireshark_LIBS})
662 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
668 ${APPLE_COCOA_LIBRARY}
674 tshark-tap-register.c
677 ${SHARK_COMMON_CAPTURE_SRC}
678 ${WIRESHARK_COMMON_SRC}
680 add_executable(tshark ${tshark_FILES})
681 add_dependencies(tshark svnversion)
682 set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
683 target_link_libraries(tshark ${tshark_LIBS})
684 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
690 ${APPLE_COCOA_LIBRARY}
693 ${WIRESHARK_COMMON_SRC}
696 add_executable(rawshark ${rawshark_FILES})
697 add_dependencies(rawshark svnversion)
698 set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
699 target_link_libraries(rawshark ${rawshark_LIBS})
700 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
711 add_executable(dftest ${dftest_FILES})
712 set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
713 target_link_libraries(dftest ${dftest_LIBS})
714 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
731 add_executable(randpkt ${randpkt_FILES})
732 set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
733 target_link_libraries(randpkt ${randpkt_LIBS})
734 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
746 add_lex_files(text2pcap_FILES
749 add_executable(text2pcap ${text2pcap_FILES})
750 add_dependencies(text2pcap svnversion)
751 set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
752 target_link_libraries(text2pcap ${text2pcap_LIBS})
753 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
766 add_executable(mergecap ${mergecap_FILES})
767 add_dependencies(mergecap svnversion)
768 set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
769 target_link_libraries(mergecap ${mergecap_LIBS})
770 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
778 ${APPLE_COCOA_LIBRARY}
782 ${WTAP_PLUGIN_SOURCES}
784 add_executable(capinfos ${capinfos_FILES})
785 set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
786 target_link_libraries(capinfos ${capinfos_LIBS})
787 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
797 epan/crypt/crypt-md5.c
799 ${WTAP_PLUGIN_SOURCES}
801 add_executable(editcap ${editcap_FILES})
802 add_dependencies(editcap svnversion)
803 set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
804 target_link_libraries(editcap ${editcap_LIBS})
805 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
819 ${APPLE_COCOA_LIBRARY}
825 capture_stop_conditions.c
836 add_executable(dumpcap ${dumpcap_FILES})
837 add_dependencies(dumpcap svnversion)
838 set_target_properties(dumpcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
839 target_link_libraries(dumpcap ${dumpcap_LIBS})
840 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
846 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
847 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
848 < ${CMAKE_SOURCE_DIR}/AUTHORS
851 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
852 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
853 ${CMAKE_SOURCE_DIR}/AUTHORS
857 OUTPUT AUTHORS-SHORT-FORMAT
860 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
861 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
863 > AUTHORS-SHORT-FORMAT
865 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
869 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
870 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
872 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
876 OUTPUT wireshark-filter.pod
880 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
881 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
882 > wireshark-filter.pod
884 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
885 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
889 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
890 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
891 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
892 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
893 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
894 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
895 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
896 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
897 pod2manhtml( wireshark 1 )
898 pod2manhtml( wireshark-filter 4 )
913 wireshark-filter.html
917 ${CMAKE_BINARY_DIR}/capinfos.1
918 ${CMAKE_BINARY_DIR}/dumpcap.1
919 ${CMAKE_BINARY_DIR}/editcap.1
920 ${CMAKE_BINARY_DIR}/idl2wrs.1
921 ${CMAKE_BINARY_DIR}/mergecap.1
922 ${CMAKE_BINARY_DIR}/rawshark.1
923 ${CMAKE_BINARY_DIR}/text2pcap.1
924 ${CMAKE_BINARY_DIR}/tshark.1
925 ${CMAKE_BINARY_DIR}/wireshark.1
929 ${CMAKE_BINARY_DIR}/wireshark-filter.4
946 set_source_files_properties(
949 COMPILE_FLAGS -Werror
957 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
964 ${CMAKE_INSTALL_MANDIR}/man1
971 ${CMAKE_INSTALL_MANDIR}/man4
977 DIRECTORY_PERMISSIONS
978 OWNER_EXECUTE OWNER_WRITE OWNER_READ
979 GROUP_EXECUTE GROUP_READ
980 WORLD_EXECUTE WORLD_READ
982 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
983 PATTERN ".svn" EXCLUDE
984 PATTERN "Makefile.*" EXCLUDE
985 PATTERN "faq.py" EXCLUDE