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 set(dumpcap_LIBS wiretap)
28 #Where to find local cmake scripts
29 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
31 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
33 # Disable this later. Alternative: "make VERBOSE=1"
34 set(CMAKE_VERBOSE_MAKEFILE ON)
36 set(BUILD_SHARED_LIBS ON)
38 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
39 include(CMakeInstallDirs)
44 ${CMAKE_SOURCE_DIR}/include
45 ${CMAKE_SOURCE_DIR}/wiretap
48 #Where to put libraries
49 if(NOT LIBRARY_OUTPUT_PATH)
50 set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
51 "Single output directory for building all libraries.")
52 endif(NOT LIBRARY_OUTPUT_PATH)
54 option(BUILD_WIRESHARK "Build the GUI version of Wireshark" ON)
55 option(BUILD_TSHARK "Build tshark" ON)
56 option(BUILD_DUMPCAP "Build dumpcap" ON)
57 option(ENABLE_STATIC "Build a static version of Wireshark" OFF)
58 option(ENABLE_ADNS "Build with adns support" ON)
59 option(ENABLE_DBUS "Build with D-Bus support" OFF)
60 option(ENABLE_DBUS_TEST "Build with D-Bus unitest support" OFF)
61 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)
63 if(ENABLE_EXTRA_GCC_CHECKS)
64 set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
65 -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
66 endif(ENABLE_EXTRA_GCC_CHECKS)
68 if(CMAKE_COMPILER_IS_GNUCC)
71 -D_U_=\"__attribute__\(\(unused\)\)\"
72 -Wall -Wpointer-arith -W
73 ${WIRESHARK_EXTRA_GCC_FLAGS}
75 else(CMAKE_COMPILER_IS_GNUCC)
76 add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
77 endif(CMAKE_COMPILER_IS_GNUCC)
79 if(BUILD_WIRESHARK OR BUILD_TSHARK OR BUILD_DUMPCAP)
81 endif(BUILD_WIRESHARK OR BUILD_TSHARK OR BUILD_DUMPCAP)
83 #The minimum package list
84 set(PACKAGELIST GLIB2 ZLIB PCAP ${PACKAGELIST})
88 set(PACKAGELIST GTK2 ${PACKAGELIST})
89 endif(BUILD_WIRESHARK)
93 set(PACKAGELIST ADNS ${PACKAGELIST})
99 set(PACKAGELIST DBUS DBUSGLIB ${PACKAGELIST})
101 set(dumpcap_LIBS ${dumpcap_LIBS} capdbus)
104 #Let's loop the package list
105 foreach(PACKAGE ${PACKAGELIST})
106 find_package(${PACKAGE} REQUIRED)
107 message(${PACKAGE}_FOUND)
108 if (${PACKAGE}_FOUND)
109 set(HAVE_LIB${PACKAGE} "1")
110 include_directories(${${PACKAGE}_INCLUDE_DIRS})
111 message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
112 set(dumpcap_LIBS ${dumpcap_LIBS} ${${PACKAGE}_LIBRARIES})
113 message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
114 endif (${PACKAGE}_FOUND)
118 set(CPACK_PACKAGE_NAME wireshark)
119 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
120 set(CPACK_PACKAGE_VENDOR "wireshark")
121 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
122 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
123 set(CPACK_PACKAGE_VERSION_MAJOR "0")
124 set(CPACK_PACKAGE_VERSION_MINOR "99")
125 set(CPACK_PACKAGE_VERSION_PATCH "4")
126 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
128 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
129 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
130 set(CPACK_GENERATOR "TGZ")
131 set(CPACK_SOURCE_GENERATOR "TGZ")
133 #check system for includes
134 include(CheckIncludeFile)
135 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
136 check_include_file("arpa/nameser.h" HAVE_ARPA_NAMESER_H)
137 check_include_file("direct.h" HAVE_DIRECT_H)
138 check_include_file("dirent.h" HAVE_DIRENT_H)
139 check_include_file("dlfcn.h" HAVE_DLFCN_H)
140 check_include_file("fcntl.h" HAVE_FCNTL_H)
141 check_include_file("getopt.h" NEED_GETOPT_H)
142 check_include_file("g_ascii_strtoull.h" NEED_G_ASCII_STRTOULL_H)
143 check_include_file("inet/aton.h" NEED_INET_ATON_H)
144 check_include_file("inttypes.h" HAVE_INTTYPES_H)
145 check_include_file("lauxlib.h" HAVE_LAUXLIB_H)
146 check_include_file("memory.h" HAVE_MEMORY_H)
147 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
148 check_include_file("netdb.h" HAVE_NETDB_H)
149 check_include_file("portaudio.h" HAVE_PORTAUDIO_H)
150 check_include_file("stdarg.h" HAVE_STDARG_H)
151 check_include_file("stddef.h" HAVE_STDDEF_H)
152 check_include_file("stdint.h" HAVE_STDINT_H)
153 check_include_file("stdlib.h" HAVE_STDLIB_H)
154 check_include_file("strerror.h" NEED_STRERROR_H)
155 check_include_file("strings.h" HAVE_STRINGS_H)
156 check_include_file("string.h" HAVE_STRING_H)
157 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
158 check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
159 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
160 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
161 check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
162 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
163 check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
164 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
165 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
166 check_include_file("unistd.h" HAVE_UNISTD_H)
169 include(CheckFunctionExists)
170 check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2)
171 check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER)
172 check_function_exists("iconv" HAVE_ICONV)
173 check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO)
174 check_function_exists("issetugid" HAVE_ISSETUGID)
175 check_function_exists("mmap" HAVE_MMAP)
176 check_function_exists("mprotect" HAVE_MPROTECT)
177 check_function_exists("sysconf" HAVE_SYSCONF)
179 #Big or little endian ?
180 include(TestBigEndian)
181 test_big_endian(WORDS_BIGENDIAN)
183 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
186 include(Check64BitFormat)
188 check_64bit_format(ll FORMAT_64BIT)
189 check_64bit_format(L FORMAT_64BIT)
190 check_64bit_format(q FORMAT_64BIT)
191 check_64bit_format(I64 FORMAT_64BIT)
194 message(FATAL " 64 bit format missing")
195 endif(NOT FORMAT_64BIT)
197 set(PRIX64 "${FORMAT_64BIT}X")
198 set(PRIx64 "${FORMAT_64BIT}x")
199 set(PRId64 "${FORMAT_64BIT}d")
200 set(PRIo64 "${FORMAT_64BIT}o")
201 set(PRIu64 "${FORMAT_64BIT}u")
205 set(WS_VAR_IMPORT "extern")
209 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
210 set(HAVE_OS_X_FRAMEWORKS 1)
214 add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
215 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
219 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
221 link_directories(wiretap)
226 set(DUMPCAP_PLATFORM_SRC
227 capture-pcap-util-unix.c
234 capture_stop_conditions.c
243 ${DUMPCAP_PLATFORM_SRC}
246 add_executable(dumpcap ${DUMPCAP_FILES})
247 target_link_libraries(dumpcap ${dumpcap_LIBS})
248 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})