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)" ON)
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)
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\"
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(DISABLE_WERROR OR ENABLE_EXTRA_GCC_CHECKS)
165 remove_definitions( -Werror )
168 if(CMAKE_COMPILER_IS_GNUCC)
169 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
171 add_definitions( -D_U_=\"\" )
175 # Same for linker flags, but it looks like it's do-it-yourself here
176 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
178 #The minimum package list
179 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
183 set(PACKAGELIST GTK2 ${PACKAGELIST})
188 set(PACKAGELIST SMI ${PACKAGELIST})
193 set(PACKAGELIST GCRYPT ${PACKAGELIST})
196 # GNU SSL/TLS support
198 set(PACKAGELIST GNUTLS ${PACKAGELIST})
201 # Regular expressions lib
203 set(PACKAGELIST PCRE ${PACKAGELIST})
208 set(PACKAGELIST KERBEROS ${PACKAGELIST})
213 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
217 # Prefer c-ares over adns
218 if(ENABLE_CARES) # C Asynchronouse resolver
219 set(PACKAGELIST CARES ${PACKAGELIST})
220 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
221 set(PACKAGELIST ADNS ${PACKAGELIST})
226 set(PACKAGELIST Z ${PACKAGELIST})
231 set(PACKAGELIST LUA ${PACKAGELIST})
234 # GeoIP address resolving
236 set(PACKAGELIST GEOIP ${PACKAGELIST})
241 set(PACKAGELIST CAP ${PACKAGELIST})
245 set(PACKAGELIST PYTHON ${PACKAGELIST})
248 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
250 #Let's loop the package list
251 foreach(PACKAGE ${PACKAGELIST})
252 find_package(${PACKAGE} REQUIRED)
253 message(${PACKAGE}_FOUND)
254 if (${PACKAGE}_FOUND)
255 set(HAVE_LIB${PACKAGE} 1)
256 include_directories(${${PACKAGE}_INCLUDE_DIRS})
257 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
258 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
266 set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${VERSION}")
274 # HAVE_HEIMDAL_KERBEROS
275 set(HAVE_MIT_KERBEROS 1)
276 set(HAVE_KEYTYPE_ARCFOUR_56 1)
291 include(ConfigureChecks.cmake)
293 #Big or little endian ?
294 include(TestBigEndian)
295 test_big_endian(WORDS_BIGENDIAN)
298 set(CPACK_PACKAGE_NAME wireshark)
299 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
300 set(CPACK_PACKAGE_VENDOR "wireshark")
301 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
302 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
303 set(CPACK_PACKAGE_VERSION_MAJOR "1")
304 set(CPACK_PACKAGE_VERSION_MINOR "3")
305 set(CPACK_PACKAGE_VERSION_PATCH "2")
306 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
308 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
309 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
310 set(CPACK_GENERATOR "TGZ")
311 set(CPACK_SOURCE_GENERATOR "TGZ")
313 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
317 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
335 # It seems this stuff doesn't build with autofoo either...
337 # set(PLUGIN_SRC_DIRS
343 set(PLUGIN_SRC_DIRS )
346 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
347 add_subdirectory( ${PLUGIN_DIR} )
350 add_subdirectory( codecs )
351 add_subdirectory( epan )
352 add_subdirectory( gtk )
353 add_subdirectory( tools/lemon )
354 add_subdirectory( wiretap )
355 add_subdirectory( wsutil )
359 set(WS_VAR_IMPORT "extern")
363 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
364 set(HAVE_OS_X_FRAMEWORKS 1)
365 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
366 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
370 add_definitions(-D_NEED_VAR_IMPORT_)
371 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
373 # Disable deprecation
375 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
379 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
381 include(FeatureSummary)
382 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
383 PRINT_ENABLED_FEATURES()
384 PRINT_DISABLED_FEATURES()
397 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
398 ${CMAKE_CURRENT_SOURCE_DIR}
400 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
403 register_tap_files(tshark-tap-register.c
409 COMMAND ${PYTHON_EXECUTABLE}
410 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
411 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
414 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
415 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
420 capture-pcap-util-unix.c
426 capture-wpcap.c capture_wpcap_packet.c
430 set(WTAP_PLUGIN_SOURCES
436 set(WIRESHARK_COMMON_SRC
496 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
516 # wireshark-filter.html
522 # $(wireshark_optional_objects)
534 ${KERBEROS_LIBRARIES}
551 ${PORTAUDIO_LIBRARIES}
553 ${APPLE_CORE_SERVICES_LIBRARY}
554 ${APPLE_COCOA_LIBRARY}
572 ${WIRESHARK_COMMON_SRC}
574 add_executable(wireshark ${wireshark_FILES})
575 target_link_libraries(wireshark ${wireshark_LIBS})
576 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
582 ${APPLE_COCOA_LIBRARY}
588 tshark-tap-register.c
591 ${WIRESHARK_COMMON_SRC}
593 add_executable(tshark ${tshark_FILES})
594 target_link_libraries(tshark ${tshark_LIBS})
595 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
601 ${APPLE_COCOA_LIBRARY}
604 ${WIRESHARK_COMMON_SRC}
607 add_executable(rawshark ${rawshark_FILES})
608 target_link_libraries(rawshark ${rawshark_LIBS})
609 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
620 add_executable(dftest ${dftest_FILES})
621 target_link_libraries(dftest ${dftest_LIBS})
622 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
639 add_executable(randpkt ${randpkt_FILES})
640 target_link_libraries(randpkt ${randpkt_LIBS})
641 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
653 add_lex_files(text2pcap_FILES
656 add_executable(text2pcap ${text2pcap_FILES})
657 target_link_libraries(text2pcap ${text2pcap_LIBS})
658 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
671 add_executable(mergecap ${mergecap_FILES})
672 target_link_libraries(mergecap ${mergecap_LIBS})
673 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
680 ${APPLE_COCOA_LIBRARY}
684 ${WTAP_PLUGIN_SOURCES}
686 add_executable(capinfos ${capinfos_FILES})
687 target_link_libraries(capinfos ${capinfos_LIBS})
688 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
698 epan/crypt/crypt-md5.c
700 ${WTAP_PLUGIN_SOURCES}
702 add_executable(editcap ${editcap_FILES})
703 target_link_libraries(editcap ${editcap_LIBS})
704 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
719 ${APPLE_COCOA_LIBRARY}
725 capture_stop_conditions.c
736 add_executable(dumpcap ${dumpcap_FILES})
737 target_link_libraries(dumpcap ${dumpcap_LIBS})
738 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
744 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
745 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
746 < ${CMAKE_SOURCE_DIR}/AUTHORS
749 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
750 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
751 ${CMAKE_SOURCE_DIR}/AUTHORS
758 # todo: Add manpages and onlinedocs and generate them
765 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
771 DIRECTORY_PERMISSIONS
772 OWNER_EXECUTE OWNER_WRITE OWNER_READ
773 GROUP_EXECUTE GROUP_READ
774 WORLD_EXECUTE WORLD_READ
776 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
777 PATTERN ".svn" EXCLUDE
778 PATTERN "Makefile.*" EXCLUDE
779 PATTERN "faq.py" EXCLUDE