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