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)
34 #Where to find local cmake scripts
35 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
38 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
40 # Disable this later. Alternative: "make VERBOSE=1"
41 set(CMAKE_VERBOSE_MAKEFILE ON)
43 set(BUILD_SHARED_LIBS ON)
45 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
46 include(CMakeInstallDirs)
51 # ${CMAKE_SOURCE_DIR}/include
52 ${CMAKE_SOURCE_DIR}/wiretap
53 ${CMAKE_SOURCE_DIR}/wsutil
56 #Where to put libraries
57 if(NOT LIBRARY_OUTPUT_PATH)
58 set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
59 "Single output directory for building all libraries.")
62 option(BUILD_wireshark "Build the GUI version of Wireshark" ON)
63 option(BUILD_tshark "Build tshark" ON)
64 option(BUILD_rawshark "Build rawshark" ON)
65 option(BUILD_dumpcap "Build dumpcap" ON)
66 option(BUILD_text2pcap "Build text2pcap" ON)
67 option(BUILD_mergecap "Build mergecap" ON)
68 option(BUILD_editcap "Build editcap" ON)
69 option(BUILD_capinfos "Build capinfos" ON)
70 option(BUILD_randpkt "Build randpkt" ON)
71 option(BUILD_dftest "Build dftest" ON)
72 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
73 option(ENABLE_ADNS "Build with adns support" ON)
74 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)
76 if(ENABLE_EXTRA_GCC_CHECKS)
77 set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
78 -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
81 if(CMAKE_COMPILER_IS_GNUCC)
84 -D_U_=__attribute__\(\(unused\)\)
85 -Wall -Wpointer-arith -W
86 ${WIRESHARK_EXTRA_GCC_FLAGS}
89 add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
92 #The minimum package list
94 set(PACKAGELIST WSWIN32 LEX YACC Perl ${PACKAGELIST})
96 set(PACKAGELIST GLIB2 PCAP LEX YACC Perl ${PACKAGELIST})
101 set(PACKAGELIST GTK2 ${PACKAGELIST})
104 #Gnu asynchronous DNS
106 set(PACKAGELIST ADNS ${PACKAGELIST})
110 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
112 #Let's loop the package list
113 foreach(PACKAGE ${PACKAGELIST})
114 find_package(${PACKAGE} REQUIRED)
115 message(${PACKAGE}_FOUND)
116 if (${PACKAGE}_FOUND)
117 set(HAVE_LIB${PACKAGE} "1")
118 include_directories(${${PACKAGE}_INCLUDE_DIRS})
119 message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
120 foreach(PROG ${PROGLIST})
121 # set(${PROG}_LIBS ${${PROG}_LIBS} ${${PACKAGE}_LIBRARIES})
123 message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
128 set(CPACK_PACKAGE_NAME wireshark)
129 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
130 set(CPACK_PACKAGE_VENDOR "wireshark")
131 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
132 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
133 set(CPACK_PACKAGE_VERSION_MAJOR "1")
134 set(CPACK_PACKAGE_VERSION_MINOR "3")
135 set(CPACK_PACKAGE_VERSION_PATCH "0")
136 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
138 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
139 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
140 set(CPACK_GENERATOR "TGZ")
141 set(CPACK_SOURCE_GENERATOR "TGZ")
143 include(ConfigureChecks.cmake)
145 #Big or little endian ?
146 include(TestBigEndian)
147 test_big_endian(WORDS_BIGENDIAN)
149 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
153 set(WS_VAR_IMPORT "extern")
157 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
158 set(HAVE_OS_X_FRAMEWORKS 1)
162 add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
163 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
165 # Disable deprecation
167 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
172 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
181 OUTPUT ${CMAKE_BINARY_DIR}/svnversion.h
182 COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/make-version.pl
186 SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/svnversion.h GENERATED)
188 # Create the necessary tools
193 # Do we need something here on any platform?
195 add_executable(lemon ${lemon_FILES})
196 target_link_libraries(lemon ${lemon_LIBS})
197 # but don't install them
201 capture-pcap-util-unix.c
207 capture-wpcap.c capture_wpcap_packet.c
240 add_lex_files(text2pcap_FILES
243 add_executable(text2pcap ${text2pcap_FILES})
244 target_link_libraries(text2pcap ${text2pcap_LIBS})
245 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
259 add_executable(mergecap ${mergecap_FILES})
260 target_link_libraries(mergecap ${mergecap_LIBS})
261 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
273 add_executable(capinfos ${capinfos_FILES})
274 target_link_libraries(capinfos ${capinfos_LIBS})
275 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
286 epan/crypt/crypt-md5.c
289 add_executable(editcap ${editcap_FILES})
290 target_link_libraries(editcap ${editcap_LIBS})
291 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
305 capture_stop_conditions.c
316 add_executable(dumpcap ${dumpcap_FILES})
317 target_link_libraries(dumpcap ${dumpcap_LIBS})
318 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})