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_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)
61 if(ENABLE_EXTRA_GCC_CHECKS)
62 set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
63 -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
64 endif(ENABLE_EXTRA_GCC_CHECKS)
66 if(CMAKE_COMPILER_IS_GNUCC)
69 -D_U_=\"__attribute__\(\(unused\)\)\"
70 -Wall -Wpointer-arith -W
71 ${WIRESHARK_EXTRA_GCC_FLAGS}
73 else(CMAKE_COMPILER_IS_GNUCC)
74 add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
75 endif(CMAKE_COMPILER_IS_GNUCC)
80 #The minimum package list
81 set(PACKAGELIST GLIB2 ZLIB PCAP ${PACKAGELIST})
85 set(PACKAGELIST GTK2 ${PACKAGELIST})
86 endif(BUILD_WIRESHARK)
90 set(PACKAGELIST ADNS ${PACKAGELIST})
94 #Let's loop the package list
95 foreach(PACKAGE ${PACKAGELIST})
96 find_package(${PACKAGE} REQUIRED)
97 message(${PACKAGE}_FOUND)
99 set(HAVE_LIB${PACKAGE} "1")
100 include_directories(${${PACKAGE}_INCLUDE_DIRS})
101 message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
102 set(dumpcap_LIBS ${dumpcap_LIBS} ${${PACKAGE}_LIBRARIES})
103 message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
104 endif (${PACKAGE}_FOUND)
110 set(CPACK_PACKAGE_NAME wireshark)
111 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
112 set(CPACK_PACKAGE_VENDOR "wireshark")
113 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
114 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
115 set(CPACK_PACKAGE_VERSION_MAJOR "0")
116 set(CPACK_PACKAGE_VERSION_MINOR "99")
117 set(CPACK_PACKAGE_VERSION_PATCH "4")
118 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
120 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
121 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
122 set(CPACK_GENERATOR "TGZ")
123 set(CPACK_SOURCE_GENERATOR "TGZ")
125 #check system for includes
126 include(CheckIncludeFile)
127 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
128 check_include_file("arpa/nameser.h" HAVE_ARPA_NAMESER_H)
129 check_include_file("direct.h" HAVE_DIRECT_H)
130 check_include_file("dirent.h" HAVE_DIRENT_H)
131 check_include_file("dlfcn.h" HAVE_DLFCN_H)
132 check_include_file("fcntl.h" HAVE_FCNTL_H)
133 check_include_file("getopt.h" NEED_GETOPT_H)
134 check_include_file("g_ascii_strtoull.h" NEED_G_ASCII_STRTOULL_H)
135 check_include_file("inet/aton.h" NEED_INET_ATON_H)
136 check_include_file("inttypes.h" HAVE_INTTYPES_H)
137 check_include_file("lauxlib.h" HAVE_LAUXLIB_H)
138 check_include_file("memory.h" HAVE_MEMORY_H)
139 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
140 check_include_file("netdb.h" HAVE_NETDB_H)
141 check_include_file("portaudio.h" HAVE_PORTAUDIO_H)
142 check_include_file("stdarg.h" HAVE_STDARG_H)
143 check_include_file("stddef.h" HAVE_STDDEF_H)
144 check_include_file("stdint.h" HAVE_STDINT_H)
145 check_include_file("stdlib.h" HAVE_STDLIB_H)
146 check_include_file("strerror.h" NEED_STRERROR_H)
147 check_include_file("strings.h" HAVE_STRINGS_H)
148 check_include_file("string.h" HAVE_STRING_H)
149 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
150 check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
151 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
152 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
153 check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
154 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
155 check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
156 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
157 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
158 check_include_file("unistd.h" HAVE_UNISTD_H)
161 include(CheckFunctionExists)
162 check_function_exists("chown" HAVE_CHOWN)
163 check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2)
164 check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER)
165 check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO)
166 check_function_exists("issetugid" HAVE_ISSETUGID)
167 check_function_exists("mmap" HAVE_MMAP)
168 check_function_exists("mprotect" HAVE_MPROTECT)
169 check_function_exists("sysconf" HAVE_SYSCONF)
171 #Big or little endian ?
172 include(TestBigEndian)
173 test_big_endian(WORDS_BIGENDIAN)
175 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
178 include(Check64BitFormat)
180 check_64bit_format(ll FORMAT_64BIT)
181 check_64bit_format(L FORMAT_64BIT)
182 check_64bit_format(q FORMAT_64BIT)
183 check_64bit_format(I64 FORMAT_64BIT)
186 message(FATAL " 64 bit format missing")
187 endif(NOT FORMAT_64BIT)
189 set(PRIX64 "${FORMAT_64BIT}X")
190 set(PRIx64 "${FORMAT_64BIT}x")
191 set(PRId64 "${FORMAT_64BIT}d")
192 set(PRIo64 "${FORMAT_64BIT}o")
193 set(PRIu64 "${FORMAT_64BIT}u")
197 set(WS_VAR_IMPORT "extern")
201 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
202 set(HAVE_OS_X_FRAMEWORKS 1)
206 add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
207 set(WS_VAR_IMPORT "__declspec(dllimport) extern")
211 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
213 link_directories(wiretap)
218 set(DUMPCAP_PLATFORM_SRC
219 capture-pcap-util-unix.c
226 capture_stop_conditions.c
235 ${DUMPCAP_PLATFORM_SRC}
238 add_executable(dumpcap ${DUMPCAP_FILES})
239 target_link_libraries(dumpcap ${dumpcap_LIBS})
240 install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})