There's no register.h file in the top-level source directory.
[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 include(UseABICheck)
11
12 if (HAVE_HFI_SECTION_INIT)
13         add_definitions(
14                 -DHAVE_HFI_SECTION_INIT
15         )
16 endif()
17
18 add_subdirectory(crypt)
19 add_subdirectory(dfilter)
20 add_subdirectory(dissectors)
21 add_subdirectory(ftypes)
22 add_subdirectory(wmem)
23 if (HAVE_LIBLUA)
24         add_subdirectory(wslua)
25 endif()
26
27 include_directories(
28         ${CMAKE_CURRENT_BINARY_DIR}
29         ${CMAKE_CURRENT_SOURCE_DIR}
30 )
31
32 add_custom_command(
33         OUTPUT ps.c
34         COMMAND ${PYTHON_EXECUTABLE}
35                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
36                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
37                 ps.c
38         DEPENDS
39                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
40                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
41 )
42
43 set(LIBWIRESHARK_PUBLIC_HEADERS
44         addr_and_mask.h
45         addr_resolv.h
46         address.h
47         address_types.h
48         afn.h
49         aftypes.h
50         app_mem_usage.h
51         arcnet_pids.h
52         arptypes.h
53         asn1.h
54         ax25_pids.h
55         bridged_pids.h
56         capture_dissectors.h
57         charsets.h
58         chdlctypes.h
59         color_filters.h
60         column.h
61         column-info.h
62         column-utils.h
63         conversation.h
64         conversation_debug.h
65         conversation_table.h
66         conv_id.h
67         crc10-tvb.h
68         crc16-tvb.h
69         crc32-tvb.h
70         crc6-tvb.h
71         crc8-tvb.h
72         decode_as.h
73         diam_dict.h
74         disabled_protos.h
75         dissector_filters.h
76         dtd.h
77         dtd_parse.h
78         dvb_chartbl.h
79         eap.h
80         eapol_keydes_types.h
81         epan.h
82         epan_dissect.h
83         etypes.h
84         ex-opt.h
85         except.h
86         exceptions.h
87         expert.h
88         export_object.h
89         exported_pdu.h
90         filter_expressions.h
91         follow.h
92         frame_data.h
93         frame_data_sequence.h
94         funnel.h
95         garrayfix.h
96         #geoip_db.h
97         golay.h
98         guid-utils.h
99         iana_charsets.h
100         iax2_codec_type.h
101         in_cksum.h
102         ip_opts.h
103         ipproto.h
104         ipv4.h
105         ipv6.h
106         lapd_sapi.h
107         llcsaps.h
108         maxmind_db.h
109         media_params.h
110         next_tvb.h
111         nlpid.h
112         oids.h
113         osi-utils.h
114         oui.h
115         packet.h
116         packet_info.h
117         params.h
118         plugin_if.h
119         ppptypes.h
120         print.h
121         print_stream.h
122         prefs.h
123         prefs-int.h
124         proto.h
125         proto_data.h
126         ps.h
127         ptvcursor.h
128         range.h
129         reassemble.h
130         reedsolomon.h
131         register.h
132         req_resp_hdrs.h
133         rtd_table.h
134         rtp_pt.h
135         sctpppids.h
136         show_exception.h
137         slow_protocol_subtypes.h
138         sminmpec.h
139         srt_table.h
140         stat_tap_ui.h
141         stat_groups.h
142         stats_tree.h
143         stats_tree_priv.h
144         stream.h
145         strutil.h
146         t35.h
147         tap.h
148         tap-voip.h
149         timestamp.h
150         timestats.h
151         tfs.h
152         time_fmt.h
153         to_str.h
154         tvbparse.h
155         tvbuff.h
156         tvbuff-int.h
157         uat.h
158         uat-int.h
159         unit_strings.h
160         value_string.h
161         x264_prt_id.h
162         xdlc.h
163 )
164
165 set(LIBWIRESHARK_NONGENERATED_FILES
166         addr_and_mask.c
167         addr_resolv.c
168         address_types.c
169         afn.c
170         aftypes.c
171         app_mem_usage.c
172         asn1.c
173         capture_dissectors.c
174         charsets.c
175         color_filters.c
176         column.c
177         column-utils.c
178         conversation.c
179         conversation_table.c
180         crc10-tvb.c
181         crc16-tvb.c
182         crc32-tvb.c
183         crc6-tvb.c
184         crc8-tvb.c
185         decode_as.c
186         disabled_protos.c
187         dissector_filters.c
188         dvb_chartbl.c
189         epan.c
190         ex-opt.c
191         except.c
192         expert.c
193         export_object.c
194         exported_pdu.c
195         filter_expressions.c
196         follow.c
197         frame_data.c
198         frame_data_sequence.c
199         funnel.c
200         #geoip_db.c
201         golay.c
202         guid-utils.c
203         iana_charsets.c
204         in_cksum.c
205         ipproto.c
206         maxmind_db.c
207         media_params.c
208         next_tvb.c
209         oids.c
210         osi-utils.c
211         packet.c
212         plugin_if.c
213         print.c
214         print_stream.c
215         prefs.c
216         proto.c
217         proto_data.c
218         range.c
219         reassemble.c
220         reedsolomon.c
221         register.c
222         req_resp_hdrs.c
223         rtd_table.c
224         sequence_analysis.c
225         show_exception.c
226         srt_table.c
227         stat_tap_ui.c
228         stats_tree.c
229         strutil.c
230         stream.c
231         t35.c
232         tap.c
233         timestamp.c
234         timestats.c
235         tfs.c
236         to_str.c
237         tvbparse.c
238         tvbuff.c
239         tvbuff_base64.c
240         tvbuff_composite.c
241         tvbuff_real.c
242         tvbuff_subset.c
243         tvbuff_zlib.c
244         uat.c
245         value_string.c
246         unit_strings.c
247         xdlc.c
248         ${CMAKE_CURRENT_BINARY_DIR}/ps.c
249         ${CMAKE_SOURCE_DIR}/version_info.c
250 )
251
252 set(LIBWIRESHARK_FILES ${LIBWIRESHARK_NONGENERATED_FILES})
253
254 add_lex_files(LEX_FILES LIBWIRESHARK_FILES
255         diam_dict.l
256         dtd_parse.l
257         dtd_preparse.l
258         radius_dict.l
259         uat_load.l
260 )
261
262 add_lemon_files(LEMON_FILES LIBWIRESHARK_FILES
263         dtd_grammar.lemon
264 )
265
266 set(epan_LIBS
267         wiretap
268         wsutil
269         ${CARES_LIBRARIES}
270         ${GCRYPT_LIBRARIES}
271         #${GEOIP_LIBRARIES}
272         ${GLIB2_LIBRARIES}
273         ${GIO2_LIBRARIES}
274         ${GTHREAD2_LIBRARIES}
275         ${GNUTLS_LIBRARIES}
276         ${KERBEROS_LIBRARIES}
277         ${LUA_LIBRARIES}
278         ${LZ4_LIBRARIES}
279         ${M_LIBRARIES}
280         ${NGHTTP2_LIBRARIES}
281         ${PCAP_LIBRARIES}
282         ${SMI_LIBRARIES}
283         ${SNAPPY_LIBRARIES}
284         ${WIN_PSAPI_LIBRARY}
285         ${LIBXML2_LIBRARIES}
286 )
287
288 set_source_files_properties(
289         ${LIBWIRESHARK_FILES}
290         PROPERTIES
291         COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
292 )
293
294 # Cannot use $<$<BOOL:${HAVE_LIBLUA}>:$<TARGET_OBJECTS:wslua>> as that breaks
295 # with CMake 3.0 (CMake 3.1 is OK)
296 if(HAVE_LIBLUA)
297         set(wslua_sources $<TARGET_OBJECTS:wslua>)
298 else()
299         set(wslua_sources)
300 endif()
301 add_library(epan
302         ${LIBWIRESHARK_FILES}
303         $<TARGET_OBJECTS:crypt>
304         $<TARGET_OBJECTS:dfilter>
305         $<TARGET_OBJECTS:dissectors>
306         $<TARGET_OBJECTS:dissectors-corba>
307         $<TARGET_OBJECTS:ftypes>
308         $<TARGET_OBJECTS:wmem>
309         ${wslua_sources}
310         ${CMAKE_BINARY_DIR}/image/libwireshark.rc
311 )
312
313 add_dependencies(epan version)
314
315 set(FULL_SO_VERSION "0.0.0")
316
317 set_target_properties(epan PROPERTIES
318         COMPILE_DEFINITIONS "WS_BUILD_DLL"
319         LINK_FLAGS "${WS_LINK_FLAGS}"
320         VERSION ${FULL_SO_VERSION} SOVERSION 0
321 )
322
323 if(ENABLE_APPLICATION_BUNDLE)
324         set_target_properties(epan PROPERTIES
325                 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
326         )
327 endif()
328
329 ABICHECK(libwireshark)
330
331 set(TOP_LEVEL_HEADERS ${CMAKE_BINARY_DIR}/config.h)
332 file(GLOB CRYPT_HEADERS crypt/*.h)
333 file(GLOB DFILTER_HEADERS dfilter/*.h ../tools/lemon/cppmagic.h)
334 file(GLOB D_HEADERS dissectors/*.h)
335 file(GLOB FTYPES_HEADERS ftypes/*.h)
336 file(GLOB WMEM_HEADERS wmem/*.h)
337
338 add_custom_command(OUTPUT libwireshark.abi.tar.gz
339         COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
340         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
341         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/epan
342         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/crypt
343         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/dfilter
344         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/dissectors
345         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/ftypes
346         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/wmem
347         COMMAND ${ABI_COPY_COMMAND} ${TOP_LEVEL_HEADERS} ${ABICHECK_TMPDIR} ${ABI_COPY_FLAGS}
348         COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/epan ${ABI_COPY_FLAGS}
349         COMMAND ${ABI_COPY_COMMAND} ${CRYPT_HEADERS} ${ABICHECK_TMPDIR}/crypt ${ABI_COPY_FLAGS}
350         COMMAND ${ABI_COPY_COMMAND} ${DFILTER_HEADERS} ${ABICHECK_TMPDIR}/dfilter ${ABI_COPY_FLAGS}
351         COMMAND ${ABI_COPY_COMMAND} ${D_HEADERS} ${ABICHECK_TMPDIR}/dissectors ${ABI_COPY_FLAGS}
352         COMMAND ${ABI_COPY_COMMAND} ${FTYPES_HEADERS} ${ABICHECK_TMPDIR}/ftypes ${ABI_COPY_FLAGS}
353         COMMAND ${ABI_COPY_COMMAND} ${WMEM_HEADERS} ${ABICHECK_TMPDIR}/wmem ${ABI_COPY_FLAGS}
354         COMMAND rm -f ${ABICHECK_TMPDIR}/dissectors/x11-extension-implementation.h
355                 ${ABICHECK_TMPDIR}/dissectors/packet-rtps.h
356                 ${ABICHECK_TMPDIR}/dissectors/x11-glx-render-enum.h
357                 ${ABICHECK_TMPDIR}/dissectors/x11-register-info.h
358                 ${ABICHECK_TMPDIR}/dissectors/packet-idmp.h
359         COMMAND ${ABICHECK_COMMAND}
360         COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwireshark/libwireshark_* ${CMAKE_CURRENT_BINARY_DIR}/libwireshark.abi.tar.gz
361         COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
362 #       COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps ${ABICHECK_TMPDIR}/config.h
363 #               ${ABICHECK_TMPDIR}/epan/* ${ABICHECK_TMPDIR}/crypt/*
364 #               ${ABICHECK_TMPDIR}/dfilter/* ${ABICHECK_TMPDIR}/dissectors/*
365 #               ${ABICHECK_TMPDIR}/ftypes/* ${ABICHECK_TMPDIR}/wmem/*
366         DEPENDS ${HEADERS}
367                 ${CRYPT_HEADERS} ${DFILTER_HEADERS} ${D_HEADERS}
368                 ${FTYPES_HEADERS} ${WMEM_HEADERS} epan)
369
370 # By default the name for a library with target name epan will be libepan,
371 # but Ethereal is now named Wireshark
372 set_target_properties(epan PROPERTIES
373         OUTPUT_NAME "wireshark"
374         PREFIX "lib"
375         FOLDER "DLLs"
376 )
377
378 target_link_libraries(epan ${epan_LIBS})
379
380 add_dependencies(epan lemon)
381
382 install(TARGETS epan
383         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
384         RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
385         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
386 )
387
388 if(NOT WIN32)
389         install(FILES ${LIBWIRESHARK_PUBLIC_HEADERS}
390                 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${CPACK_PACKAGE_NAME}/epan"
391         )
392 endif()
393
394 add_executable(exntest EXCLUDE_FROM_ALL exntest.c except.c)
395 target_link_libraries(exntest ${GLIB2_LIBRARIES})
396 set_target_properties(exntest PROPERTIES
397         FOLDER "Tests"
398         EXCLUDE_FROM_DEFAULT_BUILD True
399         COMPILE_DEFINITIONS "WS_BUILD_DLL"
400 )
401
402 add_executable(oids_test EXCLUDE_FROM_ALL oids_test.c)
403 target_link_libraries(oids_test epan ${ZLIB_LIBRARIES})
404 set_target_properties(oids_test PROPERTIES
405         FOLDER "Tests"
406         EXCLUDE_FROM_DEFAULT_BUILD True
407         COMPILE_DEFINITIONS "WS_BUILD_DLL"
408 )
409
410 add_executable(reassemble_test EXCLUDE_FROM_ALL reassemble_test.c)
411 target_link_libraries(reassemble_test epan)
412 set_target_properties(reassemble_test PROPERTIES
413         FOLDER "Tests"
414         EXCLUDE_FROM_DEFAULT_BUILD True
415 )
416
417 add_executable(tvbtest EXCLUDE_FROM_ALL tvbtest.c)
418 target_link_libraries(tvbtest epan)
419 set_target_properties(tvbtest PROPERTIES
420         FOLDER "Tests"
421         EXCLUDE_FROM_DEFAULT_BUILD True
422         COMPILE_DEFINITIONS "WS_BUILD_DLL"
423 )
424
425 CHECKAPI(
426         NAME
427           epan
428         SWITCHES
429           -g termoutput -build
430         SOURCES
431           ${LIBWIRESHARK_NONGENERATED_FILES}
432 )
433
434 #
435 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
436 #
437 # Local variables:
438 # c-basic-offset: 8
439 # tab-width: 8
440 # indent-tabs-mode: t
441 # End:
442 #
443 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
444 # :indentSize=8:tabSize=8:noTabs=false:
445 #