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)
31 INCLUDE(UseMakeDissectorReg)
32 INCLUDE(UseMakeTapReg)
34 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
36 # Disable this later. Alternative: "make VERBOSE=1"
37 set(CMAKE_VERBOSE_MAKEFILE ON)
39 set(BUILD_SHARED_LIBS ON)
41 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
42 include(CMakeInstallDirs)
47 ${CMAKE_SOURCE_DIR}/epan
48 ${CMAKE_SOURCE_DIR}/tools/lemon
49 ${CMAKE_SOURCE_DIR}/wiretap
52 #Where to put libraries
53 if(NOT LIBRARY_OUTPUT_PATH)
54 set(LIBRARY_OUTPUT_PATH ${Wireshark_BINARY_DIR}/lib CACHE INTERNAL
55 "Single output directory for building all libraries.")
58 option(BUILD_wireshark "Build the GUI version of Wireshark" ON)
59 option(BUILD_tshark "Build tshark" ON)
60 option(BUILD_rawshark "Build rawshark" ON)
61 option(BUILD_dumpcap "Build dumpcap" ON)
62 option(BUILD_text2pcap "Build text2pcap" ON)
63 option(BUILD_mergecap "Build mergecap" ON)
64 option(BUILD_editcap "Build editcap" ON)
65 option(BUILD_capinfos "Build capinfos" ON)
66 option(BUILD_randpkt "Build randpkt" ON)
67 option(BUILD_dftest "Build dftest" ON)
68 option(AUTOGEN_dcerpc "Autogenerate dcerpc dissectors" OFF)
69 option(AUTOGEN_pidl "Autogenerate pidl dissectors" OFF)
71 option(DISABLE_WERROR "Do not treat Warnings as errors" OFF)
72 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" OFF)
73 option(ENABLE_AIRPCAP "Enable Airpcap support" ON)
75 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
76 option(ENABLE_PLUGINS "Build with plugins" ON)
78 option(ENABLE_ADNS "Build with adns support" ON)
79 option(ENABLE_PCRE "Build with pcre support" ON)
80 option(ENABLE_PORTAUDIO "Build with portaudio support" ON)
81 option(ENABLE_Z "Build with zlib compression support" ON)
82 option(ENABLE_LUA "Build with lua dissector support" ON)
83 option(ENABLE_PYTHON "Build with python dissector support" ON)
84 option(ENABLE_SMI "Build with smi snmp support" ON)
85 option(ENABLE_GNUTLS "Build with GNU TLS support" ON)
86 option(ENABLE_GCRYPT "Build with GNU crypto support" ON)
87 option(ENABLE_GEOIP "Build with GeoIP support" ON)
88 option(ENABLE_CAP "Build with posix capabilities support" ON)
89 option(ENABLE_CARES "Build with c_ares support" ON)
90 # todo Mostly hardcoded
91 option(ENABLE_KERBEROS "Build with Kerberos support" ON)
99 -Wdeclaration-after-statement
108 set(WIRESHARK_EXTRA_C_FLAGS
112 -Wno-overlength-strings
113 -fstrict-overflow -Wstrict-overflow=4
115 -Wunsafe-loop-optimizations
130 # packet-ncp2222.inc prevents this from going into all warnings
133 -Wmissing-declarations
134 # Problem with packet-afs.c
136 # More cleanup needed for this on LP64
140 if(ENABLE_EXTRA_GCC_CHECKS)
141 set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
146 -DPACKAGE=\"wireshark\"
150 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
151 include(CheckCCompilerFlag)
153 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
154 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
155 set(F WS_C_FLAG_${C})
156 set(${F} ${THIS_FLAG})
157 set(V WS_C_FLAG_VALID${C})
158 check_c_compiler_flag(${${F}} ${V})
160 add_definitions(${${F}})
162 math(EXPR C "${C} + 1")
165 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
166 check_c_compiler_flag(-Werror WERROR)
171 if(CMAKE_COMPILER_IS_GNUCC)
172 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
174 add_definitions( -D_U_=\"\" )
178 # Same for linker flags, but it looks like it's do-it-yourself here
179 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
180 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
181 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
182 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
185 #The minimum package list
186 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
190 set(PACKAGELIST GTK2 ${PACKAGELIST})
195 set(PACKAGELIST SMI ${PACKAGELIST})
200 set(PACKAGELIST GCRYPT ${PACKAGELIST})
203 # GNU SSL/TLS support
205 set(PACKAGELIST GNUTLS ${PACKAGELIST})
208 # Regular expressions lib
210 set(PACKAGELIST PCRE ${PACKAGELIST})
215 set(PACKAGELIST KERBEROS ${PACKAGELIST})
220 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
224 # Prefer c-ares over adns
225 if(ENABLE_CARES) # C Asynchronouse resolver
226 set(PACKAGELIST CARES ${PACKAGELIST})
227 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
228 set(PACKAGELIST ADNS ${PACKAGELIST})
233 set(PACKAGELIST Z ${PACKAGELIST})
238 set(PACKAGELIST LUA ${PACKAGELIST})
241 # GeoIP address resolving
243 set(PACKAGELIST GEOIP ${PACKAGELIST})
248 set(PACKAGELIST CAP ${PACKAGELIST})
252 set(PACKAGELIST PYTHON ${PACKAGELIST})
255 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
257 #Let's loop the package list
258 foreach(PACKAGE ${PACKAGELIST})
259 find_package(${PACKAGE} REQUIRED)
260 message(${PACKAGE}_FOUND)
261 if (${PACKAGE}_FOUND)
262 set(HAVE_LIB${PACKAGE} 1)
263 include_directories(${${PACKAGE}_INCLUDE_DIRS})
264 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
265 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
273 set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
281 # HAVE_HEIMDAL_KERBEROS
282 set(HAVE_MIT_KERBEROS 1)
283 set(HAVE_KEYTYPE_ARCFOUR_56 1)
298 include(ConfigureChecks.cmake)
300 #Big or little endian ?
301 include(TestBigEndian)
302 test_big_endian(WORDS_BIGENDIAN)
305 set(CPACK_PACKAGE_NAME wireshark)
306 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
307 set(CPACK_PACKAGE_VENDOR "wireshark")
308 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
309 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
310 set(CPACK_PACKAGE_VERSION_MAJOR "1")
311 set(CPACK_PACKAGE_VERSION_MINOR "3")
312 set(CPACK_PACKAGE_VERSION_PATCH "2")
313 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
315 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
316 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
317 set(CPACK_GENERATOR "TGZ")
318 set(CPACK_SOURCE_GENERATOR "TGZ")
320 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
324 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
342 # It seems this stuff doesn't build with autofoo either...
344 # set(PLUGIN_SRC_DIRS
350 set(PLUGIN_SRC_DIRS )
353 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
354 add_subdirectory( ${PLUGIN_DIR} )
357 add_subdirectory( codecs )
358 add_subdirectory( epan )
359 add_subdirectory( gtk )
360 add_subdirectory( tools/lemon )
361 add_subdirectory( wiretap )
362 add_subdirectory( wsutil )
366 set(WS_VAR_IMPORT "extern")
370 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
371 set(HAVE_OS_X_FRAMEWORKS 1)
372 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
373 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
377 add_definitions(-D_NEED_VAR_IMPORT_)
378 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
380 # Disable deprecation
382 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
386 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
388 include(FeatureSummary)
389 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
390 PRINT_ENABLED_FEATURES()
391 PRINT_DISABLED_FEATURES()
404 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
405 ${CMAKE_CURRENT_SOURCE_DIR}
407 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
410 register_tap_files(tshark-tap-register.c
416 COMMAND ${PYTHON_EXECUTABLE}
417 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
418 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
421 ${CMAKE_CURRENT_SOURCE_DIR}/tools/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
503 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
505 ${CMAKE_BINARY_DIR}/capinfos.html
509 ${CMAKE_BINARY_DIR}/dumpcap.html
510 ${CMAKE_BINARY_DIR}/editcap.html
511 ${CMAKE_BINARY_DIR}/idl2wrs.html
514 ${CMAKE_BINARY_DIR}/mergecap.html
515 ${CMAKE_BINARY_DIR}/rawshark.html
518 ${CMAKE_BINARY_DIR}/text2pcap.html
519 ${CMAKE_BINARY_DIR}/tshark.html
520 ${CMAKE_BINARY_DIR}/wireshark-filter.html
521 ${CMAKE_BINARY_DIR}/wireshark.html
526 # $(wireshark_optional_objects)
538 ${KERBEROS_LIBRARIES}
555 ${PORTAUDIO_LIBRARIES}
557 ${APPLE_CORE_SERVICES_LIBRARY}
558 ${APPLE_COCOA_LIBRARY}
576 ${WIRESHARK_COMMON_SRC}
578 add_executable(wireshark ${wireshark_FILES})
579 target_link_libraries(wireshark ${wireshark_LIBS})
580 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
586 ${APPLE_COCOA_LIBRARY}
592 tshark-tap-register.c
595 ${WIRESHARK_COMMON_SRC}
597 add_executable(tshark ${tshark_FILES})
598 target_link_libraries(tshark ${tshark_LIBS})
599 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
605 ${APPLE_COCOA_LIBRARY}
608 ${WIRESHARK_COMMON_SRC}
611 add_executable(rawshark ${rawshark_FILES})
612 target_link_libraries(rawshark ${rawshark_LIBS})
613 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
624 add_executable(dftest ${dftest_FILES})
625 target_link_libraries(dftest ${dftest_LIBS})
626 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
643 add_executable(randpkt ${randpkt_FILES})
644 target_link_libraries(randpkt ${randpkt_LIBS})
645 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
657 set(text2pcap_CLEAN_FILES
660 add_lex_files(text2pcap_FILES
663 add_executable(text2pcap ${text2pcap_FILES})
664 target_link_libraries(text2pcap ${text2pcap_LIBS})
665 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
678 add_executable(mergecap ${mergecap_FILES})
679 target_link_libraries(mergecap ${mergecap_LIBS})
680 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
687 ${APPLE_COCOA_LIBRARY}
691 ${WTAP_PLUGIN_SOURCES}
693 add_executable(capinfos ${capinfos_FILES})
694 target_link_libraries(capinfos ${capinfos_LIBS})
695 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
705 epan/crypt/crypt-md5.c
707 ${WTAP_PLUGIN_SOURCES}
709 add_executable(editcap ${editcap_FILES})
710 target_link_libraries(editcap ${editcap_LIBS})
711 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
726 ${APPLE_COCOA_LIBRARY}
732 capture_stop_conditions.c
743 add_executable(dumpcap ${dumpcap_FILES})
744 target_link_libraries(dumpcap ${dumpcap_LIBS})
745 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
751 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
752 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
753 < ${CMAKE_SOURCE_DIR}/AUTHORS
756 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
757 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
758 ${CMAKE_SOURCE_DIR}/AUTHORS
762 OUTPUT AUTHORS-SHORT-FORMAT
765 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
766 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
768 > AUTHORS-SHORT-FORMAT
770 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
774 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
775 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
777 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
781 OUTPUT wireshark-filter.pod
785 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
786 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
787 > wireshark-filter.pod
789 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
790 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
796 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
797 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
798 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
799 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
800 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
801 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
802 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
803 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
804 pod2manhtml( wireshark 1 )
805 pod2manhtml( wireshark-filter 4 )
820 wireshark-filter.html
824 ${CMAKE_BINARY_DIR}/capinfos.1
825 ${CMAKE_BINARY_DIR}/dumpcap.1
826 ${CMAKE_BINARY_DIR}/editcap.1
827 ${CMAKE_BINARY_DIR}/idl2wrs.1
828 ${CMAKE_BINARY_DIR}/mergecap.1
829 ${CMAKE_BINARY_DIR}/rawshark.1
830 ${CMAKE_BINARY_DIR}/text2pcap.1
831 ${CMAKE_BINARY_DIR}/tshark.1
832 ${CMAKE_BINARY_DIR}/wireshark.1
836 ${CMAKE_BINARY_DIR}/wireshark-filter.4
845 ${text2pcap_CLEAN_FILES}
853 set_source_files_properties(
856 COMPILE_FLAGS -Werror
864 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
871 ${CMAKE_INSTALL_MANDIR}/man1
878 ${CMAKE_INSTALL_MANDIR}/man4
884 DIRECTORY_PERMISSIONS
885 OWNER_EXECUTE OWNER_WRITE OWNER_READ
886 GROUP_EXECUTE GROUP_READ
887 WORLD_EXECUTE WORLD_READ
889 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
890 PATTERN ".svn" EXCLUDE
891 PATTERN "Makefile.*" EXCLUDE
892 PATTERN "faq.py" EXCLUDE