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.
27 cmake_minimum_required(VERSION 2.6)
34 #Where to find local cmake scripts
35 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
37 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
39 # Disable this later. Alternative: "make VERBOSE=1"
40 set(CMAKE_VERBOSE_MAKEFILE ON)
42 set(BUILD_SHARED_LIBS ON)
44 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
45 include(CMakeInstallDirs)
50 ${CMAKE_SOURCE_DIR}/include
51 ${CMAKE_SOURCE_DIR}/wiretap
52 ${CMAKE_SOURCE_DIR}/wsutil
55 #Where to put libraries
56 if(NOT LIBRARY_OUTPUT_PATH)
57 set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
58 "Single output directory for building all libraries.")
59 endif(NOT LIBRARY_OUTPUT_PATH)
61 option(BUILD_WIRESHARK "Build the GUI version of Wireshark" ON)
62 option(BUILD_TSHARK "Build tshark" ON)
63 option(BUILD_RAWSHARK "Build rawshark" ON)
64 option(BUILD_dumpcap "Build dumpcap" ON)
65 option(BUILD_text2pcap "Build text2pcap" ON)
66 option(BUILD_mergecap "Build mergecap" ON)
67 option(BUILD_editcap "Build editcap" ON)
68 option(BUILD_capinfos "Build capinfos" ON)
69 option(BUILD_dftest "Build dftest" ON)
70 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
71 option(ENABLE_ADNS "Build with adns support" ON)
72 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)
74 if(ENABLE_EXTRA_GCC_CHECKS)
75 set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
76 -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
77 endif(ENABLE_EXTRA_GCC_CHECKS)
79 if(CMAKE_COMPILER_IS_GNUCC)
82 -D_U_=__attribute__\(\(unused\)\)
83 -Wall -Wpointer-arith -W
84 ${WIRESHARK_EXTRA_GCC_FLAGS}
86 else(CMAKE_COMPILER_IS_GNUCC)
87 add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
88 endif(CMAKE_COMPILER_IS_GNUCC)
90 #The minimum package list
91 set(PACKAGELIST GLIB2 ZLIB PCAP LEX YACC Perl ${PACKAGELIST})
95 set(PACKAGELIST GTK2 ${PACKAGELIST})
96 endif(BUILD_WIRESHARK)
100 set(PACKAGELIST ADNS ${PACKAGELIST})
104 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
106 #Let's loop the package list
107 foreach(PACKAGE ${PACKAGELIST})
108 find_package(${PACKAGE} REQUIRED)
109 message(${PACKAGE}_FOUND)
110 if (${PACKAGE}_FOUND)
111 set(HAVE_LIB${PACKAGE} "1")
112 include_directories(${${PACKAGE}_INCLUDE_DIRS})
113 message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
114 foreach(PROG ${PROGLIST})
115 # set(${PROG}_LIBS ${${PROG}_LIBS} ${${PACKAGE}_LIBRARIES})
117 message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
118 endif (${PACKAGE}_FOUND)
124 set(CPACK_PACKAGE_NAME wireshark)
125 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
126 set(CPACK_PACKAGE_VENDOR "wireshark")
127 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
128 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
129 set(CPACK_PACKAGE_VERSION_MAJOR "1")
130 set(CPACK_PACKAGE_VERSION_MINOR "3")
131 set(CPACK_PACKAGE_VERSION_PATCH "0")
132 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
134 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
135 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
136 set(CPACK_GENERATOR "TGZ")
137 set(CPACK_SOURCE_GENERATOR "TGZ")
139 #check system for includes
140 include(CheckIncludeFile)
141 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
142 check_include_file("arpa/nameser.h" HAVE_ARPA_NAMESER_H)
143 check_include_file("direct.h" HAVE_DIRECT_H)
144 check_include_file("dirent.h" HAVE_DIRENT_H)
145 check_include_file("dlfcn.h" HAVE_DLFCN_H)
146 check_include_file("fcntl.h" HAVE_FCNTL_H)
147 check_include_file("getopt.h" NEED_GETOPT_H)
148 check_include_file("grp.h" HAVE_GRP_H)
149 check_include_file("g_ascii_strtoull.h" NEED_G_ASCII_STRTOULL_H)
150 check_include_file("inet/aton.h" NEED_INET_ATON_H)
151 check_include_file("inttypes.h" HAVE_INTTYPES_H)
152 check_include_file("lauxlib.h" HAVE_LAUXLIB_H)
153 check_include_file("memory.h" HAVE_MEMORY_H)
154 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
155 check_include_file("netdb.h" HAVE_NETDB_H)
156 check_include_file("portaudio.h" HAVE_PORTAUDIO_H)
157 check_include_file("pwd.h" HAVE_PWD_H)
158 check_include_file("stdarg.h" HAVE_STDARG_H)
159 check_include_file("stddef.h" HAVE_STDDEF_H)
160 check_include_file("stdint.h" HAVE_STDINT_H)
161 check_include_file("stdlib.h" HAVE_STDLIB_H)
162 check_include_file("strerror.h" NEED_STRERROR_H)
163 check_include_file("strings.h" HAVE_STRINGS_H)
164 check_include_file("string.h" HAVE_STRING_H)
165 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
166 check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
167 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
168 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
169 check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
170 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
171 check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
172 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
173 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
174 check_include_file("unistd.h" HAVE_UNISTD_H)
177 include(CheckFunctionExists)
178 check_function_exists("chown" HAVE_CHOWN)
179 check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2)
180 check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER)
181 check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO)
182 check_function_exists("issetugid" HAVE_ISSETUGID)
183 check_function_exists("mmap" HAVE_MMAP)
184 check_function_exists("mprotect" HAVE_MPROTECT)
185 check_function_exists("sysconf" HAVE_SYSCONF)
187 #Big or little endian ?
188 include(TestBigEndian)
189 test_big_endian(WORDS_BIGENDIAN)
191 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
194 include(Check64BitFormat)
196 check_64bit_format(ll FORMAT_64BIT)
197 check_64bit_format(L FORMAT_64BIT)
198 check_64bit_format(q FORMAT_64BIT)
199 check_64bit_format(I64 FORMAT_64BIT)
202 message(FATAL " 64 bit format missing")
203 endif(NOT FORMAT_64BIT)
205 set(PRIX64 "${FORMAT_64BIT}X")
206 set(PRIx64 "${FORMAT_64BIT}x")
207 set(PRId64 "${FORMAT_64BIT}d")
208 set(PRIo64 "${FORMAT_64BIT}o")
209 set(PRIu64 "${FORMAT_64BIT}u")
213 set(WS_VAR_IMPORT "extern")
217 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
218 set(HAVE_OS_X_FRAMEWORKS 1)
222 add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
223 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
227 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
235 OUTPUT ${CMAKE_BINARY_DIR}/svnversion.h
236 COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/make-version.pl
240 SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/svnversion.h GENERATED)
244 capture-pcap-util-unix.c
250 endif(BUILD_WIRESHARK)
258 endif(BUILD_RAWSHARK)
269 add_lex_files(text2pcap_FILES
272 add_executable(text2pcap ${text2pcap_FILES})
273 target_link_libraries(text2pcap ${text2pcap_LIBS})
274 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
275 endif(BUILD_text2pcap)
288 add_executable(mergecap ${mergecap_FILES})
289 target_link_libraries(mergecap ${mergecap_LIBS})
290 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
291 endif(BUILD_mergecap)
302 add_executable(capinfos ${capinfos_FILES})
303 target_link_libraries(capinfos ${capinfos_LIBS})
304 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
305 endif(BUILD_capinfos)
315 epan/crypt/crypt-md5.c
318 add_executable(editcap ${editcap_FILES})
319 target_link_libraries(editcap ${editcap_LIBS})
320 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
342 capture_stop_conditions.c
353 add_executable(dumpcap ${dumpcap_FILES})
354 target_link_libraries(dumpcap ${dumpcap_LIBS})
355 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})