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)
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)
67 option(DISABLE_WERROR "Do not treat Warnings as errors" OFF)
68 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" ON)
69 option(ENABLE_AIRPCAP "Enable Airpcap support" ON)
71 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
72 option(ENABLE_PLUGINS "Build with plugins" ON)
74 option(ENABLE_ADNS "Build with adns support" ON)
75 option(ENABLE_PCRE "Build with pcre support" ON)
76 option(ENABLE_PORTAUDIO "Build with portaudio support" ON)
77 option(ENABLE_Z "Build with zlib compression support" ON)
78 # todo wslua currently seems to be broken
79 option(ENABLE_LUA "Build with lua dissector support" ON)
80 option(ENABLE_PYTHON "Build with python dissector support" ON)
81 option(ENABLE_SMI "Build with smi snmp support" ON)
82 option(ENABLE_GNUTLS "Build with GNU TLS support" ON)
83 option(ENABLE_GCRYPT "Build with GNU crypto support" ON)
84 option(ENABLE_GEOIP "Build with GeoIP support" ON)
85 option(ENABLE_CAP "Build with posix capabilities support" ON)
86 option(ENABLE_CARES "Build with c_ares support" ON)
87 # todo Mostly hardcoded
88 option(ENABLE_KERBEROS "Build with Kerberos support" ON)
97 -Wdeclaration-after-statement
106 set(WIRESHARK_EXTRA_C_FLAGS
110 -Wno-overlength-strings
111 -fstrict-overflow -Wstrict-overflow=4
113 -Wunsafe-loop-optimizations
126 # packet-ncp2222.inc prevents this from going into all warnings
129 -Wmissing-declarations
130 # Problem with packet-afs.c
132 # More cleanup needed for this on LP64
136 if(ENABLE_EXTRA_GCC_CHECKS)
137 set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
142 -DPACKAGE=\"wireshark\"
146 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
147 include(CheckCCompilerFlag)
149 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
150 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
151 set(F WS_C_FLAG_${C})
152 set(${F} ${THIS_FLAG})
153 set(V WS_C_FLAG_VALID${C})
154 check_c_compiler_flag(${${F}} ${V})
156 add_definitions(${${F}})
158 math(EXPR C "${C} + 1")
161 if(DISABLE_WERROR OR ENABLE_EXTRA_GCC_CHECKS)
162 remove_definitions( -Werror )
165 if(CMAKE_COMPILER_IS_GNUCC)
166 add_definitions( -D_U_=__attribute__\(\(unused\)\) )
168 add_definitions( -D_U_=\"\" )
172 # Same for linker flags, but it looks like it's do-it-yourself here
173 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
175 #The minimum package list
176 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
180 set(PACKAGELIST GTK2 ${PACKAGELIST})
185 set(PACKAGELIST SMI ${PACKAGELIST})
190 set(PACKAGELIST GCRYPT ${PACKAGELIST})
193 # GNU SSL/TLS support
195 set(PACKAGELIST GNUTLS ${PACKAGELIST})
198 # Regular expressions lib
200 set(PACKAGELIST PCRE ${PACKAGELIST})
205 set(PACKAGELIST KERBEROS ${PACKAGELIST})
210 set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
214 # Prefer c-ares over adns
215 if(ENABLE_CARES) # C Asynchronouse resolver
216 set(PACKAGELIST CARES ${PACKAGELIST})
217 elseif(ENABLE_ADNS) # Gnu asynchronous DNS
218 set(PACKAGELIST ADNS ${PACKAGELIST})
223 set(PACKAGELIST Z ${PACKAGELIST})
228 set(PACKAGELIST LUA ${PACKAGELIST})
231 # GeoIP address resolving
233 set(PACKAGELIST GEOIP ${PACKAGELIST})
238 set(PACKAGELIST CAP ${PACKAGELIST})
242 set(PACKAGELIST PYTHON ${PACKAGELIST})
245 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
247 #Let's loop the package list
248 foreach(PACKAGE ${PACKAGELIST})
249 find_package(${PACKAGE} REQUIRED)
250 message(${PACKAGE}_FOUND)
251 if (${PACKAGE}_FOUND)
252 set(HAVE_LIB${PACKAGE} 1)
253 include_directories(${${PACKAGE}_INCLUDE_DIRS})
254 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
255 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)
288 include(ConfigureChecks.cmake)
290 #Big or little endian ?
291 include(TestBigEndian)
292 test_big_endian(WORDS_BIGENDIAN)
295 set(CPACK_PACKAGE_NAME wireshark)
296 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
297 set(CPACK_PACKAGE_VENDOR "wireshark")
298 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
299 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
300 set(CPACK_PACKAGE_VERSION_MAJOR "1")
301 set(CPACK_PACKAGE_VERSION_MINOR "3")
302 set(CPACK_PACKAGE_VERSION_PATCH "1")
303 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
305 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
306 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
307 set(CPACK_GENERATOR "TGZ")
308 set(CPACK_SOURCE_GENERATOR "TGZ")
310 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
314 set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
332 # It seems this stuff doesn't build with autofoo either...
334 # set(PLUGIN_SRC_DIRS
340 set(PLUGIN_SRC_DIRS )
343 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
344 add_subdirectory( ${PLUGIN_DIR} )
349 set(WS_VAR_IMPORT "extern")
353 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
354 set(HAVE_OS_X_FRAMEWORKS 1)
355 FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
356 FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
360 add_definitions(-D_NEED_VAR_IMPORT_)
361 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
363 # Disable deprecation
365 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
370 add_subdirectory( codecs )
371 add_subdirectory( epan )
372 add_subdirectory( gtk )
373 add_subdirectory( wiretap )
374 add_subdirectory( wsutil )
376 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
378 include(FeatureSummary)
379 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
380 PRINT_ENABLED_FEATURES()
381 PRINT_DISABLED_FEATURES()
394 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
395 ${CMAKE_CURRENT_SOURCE_DIR}
397 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
400 # Create the necessary tools
405 # Do we need something here on any platform?
407 add_executable(lemon ${lemon_FILES})
408 target_link_libraries(lemon ${lemon_LIBS})
412 OUTPUT tshark-tap-register.c
414 ${CMAKE_SOURCE_DIR}/tools/make-tapreg-dotc
415 tshark-tap-register.c
416 ${CMAKE_CURRENT_SOURCE_DIR}
419 ${CMAKE_SOURCE_DIR}/tools/make-tapreg-dotc
425 COMMAND ${PYTHON_EXECUTABLE}
426 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
427 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
430 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
431 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
436 capture-pcap-util-unix.c
442 capture-wpcap.c capture_wpcap_packet.c
446 set(WTAP_PLUGIN_SOURCES
452 set(WIRESHARK_COMMON_SRC
512 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
532 # wireshark-filter.html
538 # $(wireshark_optional_objects)
550 ${KERBEROS_LIBRARIES}
567 ${PORTAUDIO_LIBRARIES}
569 ${APPLE_CORE_SERVICES_LIBRARY}
570 ${APPLE_COCOA_LIBRARY}
588 ${WIRESHARK_COMMON_SRC}
590 add_executable(wireshark ${wireshark_FILES})
591 target_link_libraries(wireshark ${wireshark_LIBS})
592 install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
598 ${APPLE_COCOA_LIBRARY}
604 tshark-tap-register.c
607 ${WIRESHARK_COMMON_SRC}
609 add_executable(tshark ${tshark_FILES})
610 target_link_libraries(tshark ${tshark_LIBS})
611 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
617 ${APPLE_COCOA_LIBRARY}
620 ${WIRESHARK_COMMON_SRC}
623 add_executable(rawshark ${rawshark_FILES})
624 target_link_libraries(rawshark ${rawshark_LIBS})
625 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
636 add_executable(dftest ${dftest_FILES})
637 target_link_libraries(dftest ${dftest_LIBS})
638 install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
655 add_executable(randpkt ${randpkt_FILES})
656 target_link_libraries(randpkt ${randpkt_LIBS})
657 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
669 add_lex_files(text2pcap_FILES
672 add_executable(text2pcap ${text2pcap_FILES})
673 target_link_libraries(text2pcap ${text2pcap_LIBS})
674 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})
696 ${APPLE_COCOA_LIBRARY}
700 ${WTAP_PLUGIN_SOURCES}
702 add_executable(capinfos ${capinfos_FILES})
703 target_link_libraries(capinfos ${capinfos_LIBS})
704 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
714 epan/crypt/crypt-md5.c
716 ${WTAP_PLUGIN_SOURCES}
718 add_executable(editcap ${editcap_FILES})
719 target_link_libraries(editcap ${editcap_LIBS})
720 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
735 ${APPLE_COCOA_LIBRARY}
741 capture_stop_conditions.c
752 add_executable(dumpcap ${dumpcap_FILES})
753 target_link_libraries(dumpcap ${dumpcap_LIBS})
754 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
760 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
761 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
762 < ${CMAKE_SOURCE_DIR}/AUTHORS
765 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
766 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
767 ${CMAKE_SOURCE_DIR}/AUTHORS
774 # todo: Add manpages and onlinedocs and generate them
781 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
787 DIRECTORY_PERMISSIONS
788 OWNER_EXECUTE OWNER_WRITE OWNER_READ
789 GROUP_EXECUTE GROUP_READ
790 WORLD_EXECUTE WORLD_READ
792 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
793 PATTERN ".svn" EXCLUDE
794 PATTERN "Makefile.*" EXCLUDE
795 PATTERN "faq.py" EXCLUDE