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 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
40 include(CMakeInstallDirs)
45 ${CMAKE_SOURCE_DIR}/epan
46 ${CMAKE_SOURCE_DIR}/tools/lemon
47 ${CMAKE_SOURCE_DIR}/wiretap
50 #Where to put libraries
51 if(NOT LIBRARY_OUTPUT_PATH)
52 set(LIBRARY_OUTPUT_PATH ${Wireshark_BINARY_DIR}/lib CACHE INTERNAL
53 "Single output directory for building all libraries.")
56 option(BUILD_wireshark "Build the GUI version of Wireshark" ON)
57 option(BUILD_tshark "Build tshark" ON)
58 option(BUILD_rawshark "Build rawshark" ON)
59 option(BUILD_dumpcap "Build dumpcap" ON)
60 option(BUILD_text2pcap "Build text2pcap" ON)
61 option(BUILD_mergecap "Build mergecap" ON)
62 option(BUILD_editcap "Build editcap" ON)
63 option(BUILD_capinfos "Build capinfos" ON)
64 option(BUILD_randpkt "Build randpkt" ON)
65 option(BUILD_dftest "Build dftest" ON)
66 option(AUTOGEN_dcerpc "Autogenerate dcerpc dissectors" OFF)
67 option(AUTOGEN_pidl "Autogenerate pidl dissectors" OFF)
69 option(DISABLE_WERROR "Do not treat Warnings as errors" OFF)
70 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" OFF)
71 option(ENABLE_AIRPCAP "Enable Airpcap support" ON)
72 option(ENABLE_STATIC "Build a static version of Wireshark (not yet working)" OFF)
73 option(ENABLE_PLUGINS "Build with plugins" ON)
75 option(ENABLE_GUIDES "Build Guides (not yet implemented)" OFF)
77 option(ENABLE_ADNS "Build with adns support" ON)
78 option(ENABLE_PCRE "Build with pcre support" ON)
79 option(ENABLE_PORTAUDIO "Build with portaudio support" ON)
80 option(ENABLE_Z "Build with zlib compression support" ON)
81 option(ENABLE_LUA "Build with lua dissector support" ON)
82 option(ENABLE_PYTHON "Build with python dissector support" ON)
83 option(ENABLE_SMI "Build with smi snmp support" ON)
84 option(ENABLE_GNUTLS "Build with GNU TLS support" ON)
85 option(ENABLE_GCRYPT "Build with GNU crypto support" ON)
86 option(ENABLE_GEOIP "Build with GeoIP support" ON)
87 option(ENABLE_CAP "Build with posix capabilities support" ON)
88 option(ENABLE_CARES "Build with c_ares support" ON)
89 # todo Mostly hardcoded
90 option(ENABLE_KERBEROS "Build with Kerberos support" ON)
98 -Wdeclaration-after-statement
107 set(WIRESHARK_EXTRA_C_FLAGS
111 -Wno-overlength-strings
112 -fstrict-overflow -Wstrict-overflow=4
114 -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) # This overrides -Werror
140 set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
145 -DPACKAGE=\"wireshark\"
149 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
150 include(CheckCCompilerFlag)
152 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
153 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
154 set(F WS_C_FLAG_${C})
155 set(${F} ${THIS_FLAG})
156 set(V WS_C_FLAG_VALID${C})
157 check_c_compiler_flag(${${F}} ${V})
159 add_definitions(${${F}})
161 math(EXPR C "${C} + 1")
164 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
165 check_c_compiler_flag(-Werror WERROR)
170 if(CMAKE_COMPILER_IS_GNUCC)
171 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
173 add_definitions( -D_U_=\"\" )
177 # Same for linker flags, but it looks like it's do-it-yourself here
178 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
179 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
180 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
181 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
184 set(LINK_MODE_LIB STATIC)
185 set(LINK_MODE_MODULE STATIC)
187 set(LINK_MODE_LIB SHARED)
188 set(LINK_MODE_MODULE MODULE)
191 #The minimum package list
192 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
196 set(PACKAGELIST GTK2 ${PACKAGELIST})
201 set(PACKAGELIST SMI ${PACKAGELIST})
206 set(PACKAGELIST GCRYPT ${PACKAGELIST})
209 # GNU SSL/TLS support
211 set(PACKAGELIST GNUTLS ${PACKAGELIST})
214 # Regular expressions lib
216 set(PACKAGELIST PCRE ${PACKAGELIST})
221 set(PACKAGELIST KERBEROS ${PACKAGELIST})
226 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
230 # Prefer c-ares over adns
231 if(ENABLE_CARES) # C Asynchronouse resolver
232 set(PACKAGELIST CARES ${PACKAGELIST})
233 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
234 set(PACKAGELIST ADNS ${PACKAGELIST})
239 set(PACKAGELIST Z ${PACKAGELIST})
244 set(PACKAGELIST LUA ${PACKAGELIST})
247 # GeoIP address resolving
249 set(PACKAGELIST GEOIP ${PACKAGELIST})
254 set(PACKAGELIST CAP ${PACKAGELIST})
258 set(PACKAGELIST PYTHON ${PACKAGELIST})
261 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
263 #Let's loop the package list
264 foreach(PACKAGE ${PACKAGELIST})
265 find_package(${PACKAGE} REQUIRED)
266 message(${PACKAGE}_FOUND)
267 if (${PACKAGE}_FOUND)
268 set(HAVE_LIB${PACKAGE} 1)
269 include_directories(${${PACKAGE}_INCLUDE_DIRS})
270 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
271 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
279 set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
287 # HAVE_HEIMDAL_KERBEROS
288 set(HAVE_MIT_KERBEROS 1)
289 set(HAVE_KEYTYPE_ARCFOUR_56 1)
304 include(ConfigureChecks.cmake)
306 #Big or little endian ?
307 include(TestBigEndian)
308 test_big_endian(WORDS_BIGENDIAN)
311 set(CPACK_PACKAGE_NAME wireshark)
312 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
313 set(CPACK_PACKAGE_VENDOR "wireshark")
314 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
315 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
316 set(CPACK_PACKAGE_VERSION_MAJOR "1")
317 set(CPACK_PACKAGE_VERSION_MINOR "3")
318 set(CPACK_PACKAGE_VERSION_PATCH "3")
319 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
321 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
322 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
323 set(CPACK_GENERATOR "TGZ")
324 set(CPACK_SOURCE_GENERATOR "TGZ")
326 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
330 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
348 # It seems this stuff doesn't build with autofoo either...
350 # set(PLUGIN_SRC_DIRS
356 set(PLUGIN_SRC_DIRS )
359 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
360 add_subdirectory( ${PLUGIN_DIR} )
363 add_subdirectory( codecs )
364 add_subdirectory( epan )
365 add_subdirectory( gtk )
366 add_subdirectory( tools/lemon )
367 add_subdirectory( wiretap )
368 add_subdirectory( wsutil )
372 # add_subdirectory( docbook )
377 set(WS_VAR_IMPORT "extern")
381 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
382 set(HAVE_OS_X_FRAMEWORKS 1)
383 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
384 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
388 add_definitions(-D_NEED_VAR_IMPORT_)
389 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
391 # Disable deprecation
393 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
397 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
399 include(FeatureSummary)
400 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
401 PRINT_ENABLED_FEATURES()
402 PRINT_DISABLED_FEATURES()
415 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
416 ${CMAKE_CURRENT_SOURCE_DIR}
418 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
421 register_tap_files(tshark-tap-register.c
427 COMMAND ${PYTHON_EXECUTABLE}
428 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
429 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
432 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
433 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
438 capture-pcap-util-unix.c
444 capture-wpcap.c capture_wpcap_packet.c
448 set(WTAP_PLUGIN_SOURCES
454 set(WIRESHARK_COMMON_SRC
515 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
517 ${CMAKE_BINARY_DIR}/capinfos.html
521 ${CMAKE_BINARY_DIR}/dumpcap.html
522 ${CMAKE_BINARY_DIR}/editcap.html
523 ${CMAKE_BINARY_DIR}/idl2wrs.html
526 ${CMAKE_BINARY_DIR}/mergecap.html
527 ${CMAKE_BINARY_DIR}/rawshark.html
530 ${CMAKE_BINARY_DIR}/text2pcap.html
531 ${CMAKE_BINARY_DIR}/tshark.html
532 ${CMAKE_BINARY_DIR}/wireshark-filter.html
533 ${CMAKE_BINARY_DIR}/wireshark.html
538 # @GETOPT_O@ # wsgetopt.c
539 # @INET_ATON_LO@ # epan/inet_aton.c
540 # @INET_NTOP_LO@ # inet_ntop.c
541 # @INET_PTON_LO@ # inet_pton.c
543 # @SOCKET_LIBS@ # -lsocket
544 # @SSL_LIBS@ # -lcrypto
545 # @STRERROR_O@ # strerror.c
546 # @STRNCASECMP_O@ # strncasecmp.c
547 # @STRPTIME_O@ # strptime.c
549 # $(plugin_ldadd) # in case of static
554 ${KERBEROS_LIBRARIES}
570 ${PORTAUDIO_LIBRARIES}
572 ${APPLE_CORE_SERVICES_LIBRARY}
573 ${APPLE_COCOA_LIBRARY}
591 ${WIRESHARK_COMMON_SRC}
593 add_executable(wireshark ${wireshark_FILES})
594 target_link_libraries(wireshark ${wireshark_LIBS})
595 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
601 ${APPLE_COCOA_LIBRARY}
607 tshark-tap-register.c
610 ${WIRESHARK_COMMON_SRC}
612 add_executable(tshark ${tshark_FILES})
613 target_link_libraries(tshark ${tshark_LIBS})
614 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
620 ${APPLE_COCOA_LIBRARY}
623 ${WIRESHARK_COMMON_SRC}
626 add_executable(rawshark ${rawshark_FILES})
627 target_link_libraries(rawshark ${rawshark_LIBS})
628 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
639 add_executable(dftest ${dftest_FILES})
640 target_link_libraries(dftest ${dftest_LIBS})
641 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
658 add_executable(randpkt ${randpkt_FILES})
659 target_link_libraries(randpkt ${randpkt_LIBS})
660 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
672 set(text2pcap_CLEAN_FILES
675 add_lex_files(text2pcap_FILES
678 add_executable(text2pcap ${text2pcap_FILES})
679 target_link_libraries(text2pcap ${text2pcap_LIBS})
680 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
693 add_executable(mergecap ${mergecap_FILES})
694 target_link_libraries(mergecap ${mergecap_LIBS})
695 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
702 ${APPLE_COCOA_LIBRARY}
706 ${WTAP_PLUGIN_SOURCES}
708 add_executable(capinfos ${capinfos_FILES})
709 target_link_libraries(capinfos ${capinfos_LIBS})
710 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
720 epan/crypt/crypt-md5.c
722 ${WTAP_PLUGIN_SOURCES}
724 add_executable(editcap ${editcap_FILES})
725 target_link_libraries(editcap ${editcap_LIBS})
726 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
740 ${APPLE_COCOA_LIBRARY}
746 capture_stop_conditions.c
757 add_executable(dumpcap ${dumpcap_FILES})
758 target_link_libraries(dumpcap ${dumpcap_LIBS})
759 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
765 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
766 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
767 < ${CMAKE_SOURCE_DIR}/AUTHORS
770 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
771 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
772 ${CMAKE_SOURCE_DIR}/AUTHORS
776 OUTPUT AUTHORS-SHORT-FORMAT
779 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
780 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
782 > AUTHORS-SHORT-FORMAT
784 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
788 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
789 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
791 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
795 OUTPUT wireshark-filter.pod
799 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
800 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
801 > wireshark-filter.pod
803 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
804 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
810 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
811 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
812 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
813 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
814 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
815 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
816 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
817 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
818 pod2manhtml( wireshark 1 )
819 pod2manhtml( wireshark-filter 4 )
834 wireshark-filter.html
838 ${CMAKE_BINARY_DIR}/capinfos.1
839 ${CMAKE_BINARY_DIR}/dumpcap.1
840 ${CMAKE_BINARY_DIR}/editcap.1
841 ${CMAKE_BINARY_DIR}/idl2wrs.1
842 ${CMAKE_BINARY_DIR}/mergecap.1
843 ${CMAKE_BINARY_DIR}/rawshark.1
844 ${CMAKE_BINARY_DIR}/text2pcap.1
845 ${CMAKE_BINARY_DIR}/tshark.1
846 ${CMAKE_BINARY_DIR}/wireshark.1
850 ${CMAKE_BINARY_DIR}/wireshark-filter.4
859 ${text2pcap_CLEAN_FILES}
867 set_source_files_properties(
870 COMPILE_FLAGS -Werror
878 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
885 ${CMAKE_INSTALL_MANDIR}/man1
892 ${CMAKE_INSTALL_MANDIR}/man4
898 DIRECTORY_PERMISSIONS
899 OWNER_EXECUTE OWNER_WRITE OWNER_READ
900 GROUP_EXECUTE GROUP_READ
901 WORLD_EXECUTE WORLD_READ
903 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
904 PATTERN ".svn" EXCLUDE
905 PATTERN "Makefile.*" EXCLUDE
906 PATTERN "faq.py" EXCLUDE