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