HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / epan / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
6 #
7 # SPDX-License-Identifier: GPL-2.0-or-later
8 #
9
10 if (HAVE_HFI_SECTION_INIT)
11         add_definitions(
12                 -DHAVE_HFI_SECTION_INIT
13         )
14 endif()
15
16 include_directories(
17                 ${BROTLI_INCLUDE_DIRS}
18                 ${GLIB2_INCLUDE_DIRS}
19                 ${CARES_INCLUDE_DIRS}
20                 ${GCRYPT_INCLUDE_DIRS}
21                 ${GTHREAD2_INCLUDE_DIRS}
22                 ${GNUTLS_INCLUDE_DIRS}
23                 ${KERBEROS_INCLUDE_DIRS}
24                 ${LUA_INCLUDE_DIRS}
25                 ${LZ4_INCLUDE_DIRS}
26                 ${NGHTTP2_INCLUDE_DIRS}
27                 ${SMI_INCLUDE_DIRS}
28                 ${SNAPPY_INCLUDE_DIRS}
29                 ${ZLIB_INCLUDE_DIRS}
30                 ${LIBXML2_INCLUDE_DIRS}
31 )
32
33 add_definitions(
34                 ${LIBXML2_DEFINITIONS}
35                 ${KERBEROS_DEFINITIONS}
36 )
37
38 add_subdirectory(crypt)
39 add_subdirectory(dfilter)
40 add_subdirectory(dissectors)
41 add_subdirectory(ftypes)
42 add_subdirectory(wmem)
43 if(LUA_FOUND)
44         add_subdirectory(wslua)
45 endif()
46
47 include_directories(
48         ${CMAKE_CURRENT_BINARY_DIR}
49         ${CMAKE_CURRENT_SOURCE_DIR}
50 )
51
52 add_custom_command(
53         OUTPUT ps.c
54         COMMAND ${PYTHON_EXECUTABLE}
55                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
56                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
57                 ps.c
58         DEPENDS
59                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
60                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
61 )
62
63 set(LIBWIRESHARK_PUBLIC_HEADERS
64         addr_and_mask.h
65         addr_resolv.h
66         address.h
67         address_types.h
68         afn.h
69         aftypes.h
70         app_mem_usage.h
71         arcnet_pids.h
72         arptypes.h
73         asn1.h
74         ax25_pids.h
75         bridged_pids.h
76         capture_dissectors.h
77         charsets.h
78         chdlctypes.h
79         color_filters.h
80         column.h
81         column-info.h
82         column-utils.h
83         conversation.h
84         conversation_debug.h
85         conversation_table.h
86         conv_id.h
87         crc10-tvb.h
88         crc16-tvb.h
89         crc32-tvb.h
90         crc6-tvb.h
91         crc8-tvb.h
92         decode_as.h
93         diam_dict.h
94         disabled_protos.h
95         dissector_filters.h
96         dtd.h
97         dtd_parse.h
98         dvb_chartbl.h
99         eap.h
100         eapol_keydes_types.h
101         epan.h
102         epan_dissect.h
103         etypes.h
104         ex-opt.h
105         except.h
106         exceptions.h
107         expert.h
108         export_object.h
109         exported_pdu.h
110         filter_expressions.h
111         follow.h
112         frame_data.h
113         frame_data_sequence.h
114         funnel.h
115         garrayfix.h
116         #geoip_db.h
117         golay.h
118         guid-utils.h
119         iana_charsets.h
120         iax2_codec_type.h
121         in_cksum.h
122         ip_opts.h
123         ipproto.h
124         ipv4.h
125         ipv6.h
126         lapd_sapi.h
127         llcsaps.h
128         maxmind_db.h
129         media_params.h
130         next_tvb.h
131         nlpid.h
132         oids.h
133         osi-utils.h
134         oui.h
135         packet.h
136         packet_info.h
137         params.h
138         plugin_if.h
139         ppptypes.h
140         print.h
141         print_stream.h
142         prefs.h
143         prefs-int.h
144         proto.h
145         proto_data.h
146         ps.h
147         ptvcursor.h
148         range.h
149         reassemble.h
150         reedsolomon.h
151         register.h
152         req_resp_hdrs.h
153         rtd_table.h
154         rtp_pt.h
155         sctpppids.h
156         secrets.h
157         show_exception.h
158         slow_protocol_subtypes.h
159         sminmpec.h
160         srt_table.h
161         stat_tap_ui.h
162         stat_groups.h
163         stats_tree.h
164         stats_tree_priv.h
165         stream.h
166         strutil.h
167         t35.h
168         tap.h
169         tap-voip.h
170         timestamp.h
171         timestats.h
172         tfs.h
173         time_fmt.h
174         to_str.h
175         tvbparse.h
176         tvbuff.h
177         tvbuff-int.h
178         uat.h
179         uat-int.h
180         unit_strings.h
181         value_string.h
182         x264_prt_id.h
183         xdlc.h
184 )
185
186 set(LIBWIRESHARK_HEADER_FILES
187         ${LIBWIRESHARK_PUBLIC_HEADERS}
188 )
189
190 set(LIBWIRESHARK_NONGENERATED_FILES
191         addr_and_mask.c
192         addr_resolv.c
193         address_types.c
194         afn.c
195         aftypes.c
196         app_mem_usage.c
197         asn1.c
198         capture_dissectors.c
199         charsets.c
200         color_filters.c
201         column.c
202         column-utils.c
203         conversation.c
204         conversation_table.c
205         crc10-tvb.c
206         crc16-tvb.c
207         crc32-tvb.c
208         crc6-tvb.c
209         crc8-tvb.c
210         decode_as.c
211         disabled_protos.c
212         dissector_filters.c
213         dvb_chartbl.c
214         epan.c
215         ex-opt.c
216         except.c
217         expert.c
218         export_object.c
219         exported_pdu.c
220         filter_expressions.c
221         follow.c
222         frame_data.c
223         frame_data_sequence.c
224         funnel.c
225         #geoip_db.c
226         golay.c
227         guid-utils.c
228         iana_charsets.c
229         in_cksum.c
230         ipproto.c
231         maxmind_db.c
232         media_params.c
233         next_tvb.c
234         oids.c
235         osi-utils.c
236         packet.c
237         plugin_if.c
238         print.c
239         print_stream.c
240         prefs.c
241         proto.c
242         proto_data.c
243         range.c
244         reassemble.c
245         reedsolomon.c
246         register.c
247         req_resp_hdrs.c
248         rtd_table.c
249         secrets.c
250         sequence_analysis.c
251         show_exception.c
252         srt_table.c
253         stat_tap_ui.c
254         stats_tree.c
255         strutil.c
256         stream.c
257         t35.c
258         tap.c
259         timestamp.c
260         timestats.c
261         tfs.c
262         to_str.c
263         tvbparse.c
264         tvbuff.c
265         tvbuff_base64.c
266         tvbuff_brotli.c
267         tvbuff_composite.c
268         tvbuff_real.c
269         tvbuff_subset.c
270         tvbuff_zlib.c
271         tvbuff_lz77.c
272         tvbuff_lz77huff.c
273         tvbuff_lznt1.c
274         uat.c
275         value_string.c
276         unit_strings.c
277         xdlc.c
278         ${CMAKE_CURRENT_BINARY_DIR}/ps.c
279 )
280
281 set(LIBWIRESHARK_FILES ${LIBWIRESHARK_NONGENERATED_FILES})
282
283 add_lex_files(LEX_FILES LIBWIRESHARK_FILES
284         diam_dict.l
285         dtd_parse.l
286         dtd_preparse.l
287         radius_dict.l
288         uat_load.l
289 )
290
291 add_lemon_files(LEMON_FILES LIBWIRESHARK_FILES
292         dtd_grammar.lemon
293 )
294
295 set_source_files_properties(
296         ${LIBWIRESHARK_FILES}
297         PROPERTIES
298         COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
299 )
300
301 add_library(epan
302         #Included so that Visual Studio can properly put header files in solution
303         ${LIBWIRESHARK_HEADER_FILES}
304
305         ${LIBWIRESHARK_FILES}
306         $<TARGET_OBJECTS:crypt>
307         $<TARGET_OBJECTS:dfilter>
308         $<TARGET_OBJECTS:dissectors>
309         $<TARGET_OBJECTS:dissectors-corba>
310         $<TARGET_OBJECTS:ftypes>
311         $<TARGET_OBJECTS:version_info>
312         $<TARGET_OBJECTS:wmem>
313         $<$<BOOL:${LUA_FOUND}>:$<TARGET_OBJECTS:wslua>>
314         ${CMAKE_BINARY_DIR}/image/libwireshark.rc
315 )
316
317 if(ENABLE_PLUGINS)
318         target_compile_definitions(epan PUBLIC HAVE_PLUGINS)
319 endif()
320
321 set_target_properties(epan PROPERTIES
322         COMPILE_DEFINITIONS "WS_BUILD_DLL"
323         LINK_FLAGS "${WS_LINK_FLAGS}"
324         VERSION "0.0.0" SOVERSION 0
325         INSTALL_RPATH "${LIBRARY_INSTALL_RPATH}"
326         # By default the name for a library with target name epan will be libepan,
327         # but Ethereal is now named Wireshark
328         OUTPUT_NAME "wireshark"
329         PREFIX "lib"
330         FOLDER "DLLs"
331 )
332
333 target_link_libraries(epan
334         PUBLIC
335                 wiretap
336                 wsutil
337                 ${GLIB2_LIBRARIES}
338         PRIVATE
339                 ${BROTLI_LIBRARIES}
340                 ${CARES_LIBRARIES}
341                 ${GCRYPT_LIBRARIES}
342                 ${GIO2_LIBRARIES}
343                 ${GTHREAD2_LIBRARIES}
344                 ${GNUTLS_LIBRARIES}
345                 ${KERBEROS_LIBRARIES}
346                 ${LUA_LIBRARIES}
347                 ${LZ4_LIBRARIES}
348                 ${M_LIBRARIES}
349                 ${NGHTTP2_LIBRARIES}
350                 ${SMI_LIBRARIES}
351                 ${SNAPPY_LIBRARIES}
352                 ${WIN_PSAPI_LIBRARY}
353                 ${LIBXML2_LIBRARIES}
354                 ${ZLIB_LIBRARIES}
355 )
356
357 target_include_directories(epan
358         INTERFACE
359         $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
360         $<INSTALL_INTERFACE:include/wireshark>
361 )
362
363 target_include_directories(epan SYSTEM PUBLIC ${GLIB2_INCLUDE_DIRS})
364
365 add_dependencies(epan lemon)
366
367 install(TARGETS epan
368         EXPORT WiresharkTargets
369         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
370         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
371         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
372 )
373
374 install(FILES ${LIBWIRESHARK_PUBLIC_HEADERS}
375         DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}/epan"
376 )
377
378 add_executable(exntest EXCLUDE_FROM_ALL exntest.c except.c)
379 target_link_libraries(exntest ${GLIB2_LIBRARIES})
380 set_target_properties(exntest PROPERTIES
381         FOLDER "Tests"
382         EXCLUDE_FROM_DEFAULT_BUILD True
383         COMPILE_DEFINITIONS "WS_BUILD_DLL"
384 )
385
386 add_executable(oids_test EXCLUDE_FROM_ALL oids_test.c)
387 target_link_libraries(oids_test epan ${ZLIB_LIBRARIES})
388 set_target_properties(oids_test PROPERTIES
389         FOLDER "Tests"
390         EXCLUDE_FROM_DEFAULT_BUILD True
391         COMPILE_DEFINITIONS "WS_BUILD_DLL"
392 )
393
394 add_executable(reassemble_test EXCLUDE_FROM_ALL reassemble_test.c)
395 target_link_libraries(reassemble_test epan)
396 set_target_properties(reassemble_test PROPERTIES
397         FOLDER "Tests"
398         EXCLUDE_FROM_DEFAULT_BUILD True
399 )
400
401 add_executable(tvbtest EXCLUDE_FROM_ALL tvbtest.c)
402 target_link_libraries(tvbtest epan)
403 set_target_properties(tvbtest PROPERTIES
404         FOLDER "Tests"
405         EXCLUDE_FROM_DEFAULT_BUILD True
406         COMPILE_DEFINITIONS "WS_BUILD_DLL"
407 )
408
409 CHECKAPI(
410         NAME
411           epan
412         SWITCHES
413           --group termoutput:10 --summary-group termoutput --build
414         SOURCES
415           ${LIBWIRESHARK_NONGENERATED_FILES}
416 )
417
418 #
419 # Editor modelines  -  https://www.wireshark.org/tools/modelines.html
420 #
421 # Local variables:
422 # c-basic-offset: 8
423 # tab-width: 8
424 # indent-tabs-mode: t
425 # End:
426 #
427 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
428 # :indentSize=8:tabSize=8:noTabs=false:
429 #