aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 2de0e59dbd406ed00e99b3152904e1ab8f7a4fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# CMakeLists.txt
#
# $Id$
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
# Copyright 1998 Gerald Combs
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#

project(wireshark C)

cmake_minimum_required(VERSION 2.6)

subdirs(
#	epan
	wiretap
	wsutil
)

#Where to find local cmake scripts
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
INCLUDE(UseLemon)

# Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG

# Disable this later. Alternative: "make VERBOSE=1"
set(CMAKE_VERBOSE_MAKEFILE ON)

set(BUILD_SHARED_LIBS ON)

#Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
include(CMakeInstallDirs)

include_directories(
	${CMAKE_BINARY_DIR}
	${CMAKE_SOURCE_DIR}
#	${CMAKE_SOURCE_DIR}/include
	${CMAKE_SOURCE_DIR}/wiretap
	${CMAKE_SOURCE_DIR}/wsutil
)

#Where to put libraries
if(NOT LIBRARY_OUTPUT_PATH)
	set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
		   "Single output directory for building all libraries.")
endif()

option(BUILD_wireshark   "Build the GUI version of Wireshark" ON)
option(BUILD_tshark      "Build tshark" ON)
option(BUILD_rawshark    "Build rawshark" ON)
option(BUILD_dumpcap     "Build dumpcap" ON)
option(BUILD_text2pcap   "Build text2pcap" ON)
option(BUILD_mergecap    "Build mergecap" ON)
option(BUILD_editcap     "Build editcap" ON)
option(BUILD_capinfos    "Build capinfos" ON)
option(BUILD_randpkt     "Build randpkt" ON)
option(BUILD_dftest      "Build dftest" ON)
option(ENABLE_STATIC     "Build a static version of Wireshark" OFF)
option(ENABLE_ADNS       "Build with adns support" ON)
option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)

if(ENABLE_EXTRA_GCC_CHECKS)
	set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
		  -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
endif()

if(CMAKE_COMPILER_IS_GNUCC)
	add_definitions(
		-DHAVE_CONFIG_H
		-D_U_=__attribute__\(\(unused\)\)
		-Wall -Wpointer-arith -W
		${WIRESHARK_EXTRA_GCC_FLAGS}
	)
else()
	add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
endif()

#The minimum package list
if(WIN32)
	set(PACKAGELIST WSWIN32 LEX YACC Perl ${PACKAGELIST})
else()
	set(PACKAGELIST GLIB2 PCAP LEX YACC Perl ${PACKAGELIST})
endif()

#Build the gui ?
if(BUILD_wireshark)
	set(PACKAGELIST GTK2 ${PACKAGELIST})
endif()

#Gnu asynchronous DNS
if(ENABLE_ADNS)
	set(PACKAGELIST ADNS ${PACKAGELIST})
	set(HAVE_GNU_ADNS 1)
endif()

set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)

#Let's loop the package list
foreach(PACKAGE ${PACKAGELIST})
	find_package(${PACKAGE} REQUIRED)
	message(${PACKAGE}_FOUND)
	if (${PACKAGE}_FOUND)
		set(HAVE_LIB${PACKAGE} "1")
		include_directories(${${PACKAGE}_INCLUDE_DIRS})
		message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
		foreach(PROG ${PROGLIST})
#		set(${PROG}_LIBS ${${PROG}_LIBS} ${${PACKAGE}_LIBRARIES})
		endforeach()
		message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
	endif()
endforeach()

#packaging
set(CPACK_PACKAGE_NAME wireshark)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
set(CPACK_PACKAGE_VENDOR "wireshark")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "3")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")

include(ConfigureChecks.cmake)

#Big or little endian ?
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")

#Platform specific
if(UNIX)
	set(WS_VAR_IMPORT "extern")
endif()

if(APPLE)
#TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
	set(HAVE_OS_X_FRAMEWORKS 1)
endif()

if(WIN32)
	add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
	set(WS_VAR_IMPORT "__declspec(dllimport) extern")

	# Disable deprecation
	if(MSVC80 OR MSVC90)
		add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
	endif()
endif()


configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)

link_directories(
	wiretap
	wsutil
	epan
)

ADD_CUSTOM_COMMAND(
	OUTPUT ${CMAKE_BINARY_DIR}/svnversion.h
	COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/make-version.pl
	ARGS
	${CMAKE_SOURCE_DIR}
)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/svnversion.h GENERATED)

# Create the necessary tools
set(lemon_FILES
	tools/lemon/lemon.c
)
set(lemon_LIBS
	# Do we need something here on any platform?
)
add_executable(lemon ${lemon_FILES})
target_link_libraries(lemon ${lemon_LIBS})
# but don't install them

if(UNIX)
	set(PLATFORM_SRC
		capture-pcap-util-unix.c
	)
endif()

if(WIN32)
	set(PLATFORM_SRC
		capture-wpcap.c capture_wpcap_packet.c
	)
endif()

if(BUILD_wireshark)
# todo
endif()

if(BUILD_tshark)
# todo
endif()

if(BUILD_rawshark)
# todo
endif()

if(BUILD_randpkt)
# todo
endif()

if(BUILD_dftest)
# todo
endif()

if(BUILD_text2pcap)
	set(text2pcap_LIBS
		wiretap
		wsutil
		${GLIB2_LIBRARIES}
	)
	set(text2pcap_FILES
		text2pcap.c
	)
	add_lex_files(text2pcap_FILES
		text2pcap-scanner.l
	)
	add_executable(text2pcap ${text2pcap_FILES})
	target_link_libraries(text2pcap ${text2pcap_LIBS})
	install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if(BUILD_mergecap)
	set(mergecap_LIBS
		wiretap
		wsutil
		${GLIB2_LIBRARIES}
	)
	set(mergecap_FILES
		mergecap.c
		merge.c
		svnversion.h
	)
	add_executable(mergecap ${mergecap_FILES})
	target_link_libraries(mergecap ${mergecap_LIBS})
	install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if(BUILD_capinfos)
	set(capinfos_LIBS
		wiretap
		wsutil
		${GLIB2_LIBRARIES}
	)
	set(capinfos_FILES
		capinfos.c
	)
	add_executable(capinfos ${capinfos_FILES})
	target_link_libraries(capinfos ${capinfos_LIBS})
	install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if(BUILD_editcap)
	set(editcap_LIBS
		wiretap
		wsutil
		${GLIB2_LIBRARIES}
	)
	set(editcap_FILES
		editcap.c
		epan/crypt/crypt-md5.c
		epan/nstime.c
	)
	add_executable(editcap ${editcap_FILES})
	target_link_libraries(editcap ${editcap_LIBS})
	install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if(BUILD_dumpcap)
	set(dumpcap_LIBS
		wiretap
		wsutil
		${GLIB2_LIBRARIES}
		${PCAP_LIBRARIES}
	)
	set(dumpcap_FILES
		svnversion.h
		capture_opts.c
		capture-pcap-util.c
		capture_stop_conditions.c
		clopts_common.c
		conditions.c
		dumpcap.c
		pcapio.c
		ringbuffer.c
		sync_pipe_write.c
		tempfile.c
		version_info.c
		${PLATFORM_SRC}
	)
	add_executable(dumpcap ${dumpcap_FILES})
	target_link_libraries(dumpcap ${dumpcap_LIBS})
	install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()