Add CMake version.h dependency
[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(nghttp2)
35 add_subdirectory(wmem)
36 if (HAVE_LIBLUA)
37         add_subdirectory(wslua)
38 endif()
39
40 include_directories(
41         ${CMAKE_CURRENT_BINARY_DIR}
42         ${CMAKE_CURRENT_SOURCE_DIR}
43 )
44
45 set(COMPRESS_FILES
46         compress/lzxpress.c
47 )
48 source_group(compress FILES ${COMPRESS_FILES})
49
50 set(LIBWIRESHARK_ASM_FILES
51         asm_utils.c
52 # todo
53 #       !IFDEF NASM
54 #       asm_utils_win32_x86.obj: asm_utils_win32_x86.asm
55 #               $(NASM) -f $(WIRESHARK_TARGET_PLATFORM) -o $@ $?
56 #       !ENDIF
57 #       ...
58 #       !IF defined(NASM) && "$(WIRESHARK_TARGET_PLATFORM)" == "win32"
59 #               asm_utils_win32_x86.obj
60 #       !ELSE
61 #               asm_utils.obj
62 #       !ENDIF
63 )
64
65 add_custom_target(
66         update-sminmpec
67         COMMAND ${PERL_EXECUTABLE}
68                 ${CMAKE_SOURCE_DIR}/tools/make-sminmpec.pl
69         DEPENDS
70                 enterprise-numbers
71                 ${CMAKE_SOURCE_DIR}/tools/make-sminmpec.pl
72 )
73 set_target_properties(update-sminmpec PROPERTIES FOLDER "tools")
74
75 add_custom_command(
76         OUTPUT ps.c
77         COMMAND ${PYTHON_EXECUTABLE}
78                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
79                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
80                 ps.c
81         DEPENDS
82                 ${CMAKE_SOURCE_DIR}/tools/rdps.py
83                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
84 )
85
86 set(LIBWIRESHARK_FILES
87         addr_and_mask.c
88         addr_resolv.c
89         address_types.c
90         afn.c
91         aftypes.c
92         app_mem_usage.c
93         asn1.c
94         capture_dissectors.c
95         charsets.c
96         circuit.c
97         color_filters.c
98         column.c
99         column-utils.c
100         conversation.c
101         conversation_table.c
102         crc10-tvb.c
103         crc16-tvb.c
104         crc32-tvb.c
105         crc6-tvb.c
106         crc8-tvb.c
107         decode_as.c
108         disabled_protos.c
109         dissector_filters.c
110         dvb_chartbl.c
111         dwarf.c
112         epan.c
113         ex-opt.c
114         except.c
115         expert.c
116         exported_pdu.c
117         plugin_if.c
118         filter_expressions.c
119         follow.c
120         frame_data.c
121         frame_data_sequence.c
122         funnel.c
123         g_int64_hash_routines.c
124         gcp.c
125         geoip_db.c
126         golay.c
127         guid-utils.c
128         in_cksum.c
129         ipproto.c
130         ipv4.c
131         next_tvb.c
132         oids.c
133         osi-utils.c
134         oui.c
135         packet-range.c
136         packet.c
137         print.c
138         print_stream.c
139         prefs.c
140         proto.c
141         proto_data.c
142         ps.c
143         range.c
144         reassemble.c
145         reedsolomon.c
146         req_resp_hdrs.c
147         rtd_table.c
148         show_exception.c
149         sminmpec.c
150         srt_table.c
151         stat_tap_ui.c
152         stats_tree.c
153         strutil.c
154         stream.c
155         t35.c
156         tap.c
157         timestamp.c
158         timestats.c
159         tfs.c
160         to_str.c
161         tvbparse.c
162         tvbuff.c
163         tvbuff_base64.c
164         tvbuff_composite.c
165         tvbuff_real.c
166         tvbuff_subset.c
167         tvbuff_zlib.c
168         uat.c
169         value_string.c
170         xdlc.c
171         ${CMAKE_SOURCE_DIR}/ws_version_info.c
172 )
173
174 set(LIBWIRESHARK_CLEAN_FILES
175         ${LIBWIRESHARK_FILES}
176 )
177
178 add_lex_files(LIBWIRESHARK_FILES
179         diam_dict.l
180         dtd_parse.l
181         dtd_preparse.l
182         radius_dict.l
183         uat_load.l
184 )
185
186 add_lemon_files(LIBWIRESHARK_FILES
187         dtd_grammar.lemon
188 )
189
190 set(epan_LIBS
191         wiretap
192         wsutil
193         ${GLIB2_LIBRARIES}
194         ${PCAP_LIBRARIES}
195         ${CARES_LIBRARIES}
196         ${KERBEROS_LIBRARIES}
197         ${GEOIP_LIBRARIES}
198         ${GCRYPT_LIBRARIES}
199         ${GNUTLS_LIBRARIES}
200         ${SMI_LIBRARIES}
201         ${M_LIBRARIES}
202         ${LUA_LIBRARIES}
203         ${WIN_PSAPI_LIBRARY}
204 )
205
206 set(CLEAN_FILES
207         ${LIBWIRESHARK_CLEAN_FILES}
208         ${COMPRESS_FILES}
209         ${LIBWIRESHARK_ASM_FILES}
210 )
211
212 if (WERROR_COMMON_FLAGS)
213         set_source_files_properties(
214                 ${CLEAN_FILES}
215                 PROPERTIES
216                 COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
217         )
218 endif()
219
220 add_library(epan ${LINK_MODE_LIB}
221         ${LIBWIRESHARK_FILES}
222         ${COMPRESS_FILES}
223         ${LIBWIRESHARK_ASM_FILES}
224         $<TARGET_OBJECTS:crypt>
225         $<TARGET_OBJECTS:dfilter>
226         $<TARGET_OBJECTS:dissectors>
227         $<TARGET_OBJECTS:ftypes>
228         $<TARGET_OBJECTS:nghttp2>
229         $<TARGET_OBJECTS:wmem>
230         $<TARGET_OBJECTS:wslua>
231         ${CMAKE_BINARY_DIR}/image/libwireshark.rc
232 )
233
234 add_dependencies(epan version)
235
236 set(FULL_SO_VERSION "0.0.0")
237
238 set_target_properties(epan PROPERTIES COMPILE_DEFINITIONS "WS_BUILD_DLL")
239 set_target_properties(epan PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
240 set_target_properties(epan PROPERTIES VERSION ${FULL_SO_VERSION} SOVERSION 0)
241
242 if(ENABLE_APPLICATION_BUNDLE)
243         set_target_properties(epan PROPERTIES
244                 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
245         )
246 endif()
247
248 ABICHECK(libwireshark)
249
250 set(TOP_LEVEL_HEADERS ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/register.h)
251 file(GLOB CRYPT_HEADERS crypt/*.h)
252 file(GLOB COMPRESS_HEADERS compress/*.h)
253 file(GLOB DFILTER_HEADERS dfilter/*.h ../tools/lemon/cppmagic.h)
254 file(GLOB D_HEADERS dissectors/*.h)
255 file(GLOB FTYPES_HEADERS ftypes/*.h)
256 file(GLOB WMEM_HEADERS wmem/*.h)
257 file(GLOB NGHTTP2_HEADERS nghttp2/*.h)
258
259 add_custom_command(OUTPUT libwireshark.abi.tar.gz
260         COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
261         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
262         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/epan
263         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/crypt
264         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/compress
265         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/dfilter
266         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/dissectors
267         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/ftypes
268         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/wmem
269         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}/nghttp2
270         COMMAND ${ABI_COPY_COMMAND} ${TOP_LEVEL_HEADERS} ${ABICHECK_TMPDIR} ${ABI_COPY_FLAGS}
271         COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/epan ${ABI_COPY_FLAGS}
272         COMMAND ${ABI_COPY_COMMAND} ${CRYPT_HEADERS} ${ABICHECK_TMPDIR}/crypt ${ABI_COPY_FLAGS}
273         COMMAND ${ABI_COPY_COMMAND} ${COMPRESS_HEADERS} ${ABICHECK_TMPDIR}/compress ${ABI_COPY_FLAGS}
274         COMMAND ${ABI_COPY_COMMAND} ${DFILTER_HEADERS} ${ABICHECK_TMPDIR}/dfilter ${ABI_COPY_FLAGS}
275         COMMAND ${ABI_COPY_COMMAND} ${D_HEADERS} ${ABICHECK_TMPDIR}/dissectors ${ABI_COPY_FLAGS}
276         COMMAND ${ABI_COPY_COMMAND} ${FTYPES_HEADERS} ${ABICHECK_TMPDIR}/ftypes ${ABI_COPY_FLAGS}
277         COMMAND ${ABI_COPY_COMMAND} ${WMEM_HEADERS} ${ABICHECK_TMPDIR}/wmem ${ABI_COPY_FLAGS}
278         COMMAND ${ABI_COPY_COMMAND} ${NGHTTP2_HEADERS} ${ABICHECK_TMPDIR}/nghttp2 ${ABI_COPY_FLAGS}
279         COMMAND rm -f ${ABICHECK_TMPDIR}/dissectors/x11-extension-implementation.h
280                 ${ABICHECK_TMPDIR}/dissectors/packet-rtps.h
281                 ${ABICHECK_TMPDIR}/dissectors/x11-glx-render-enum.h
282                 ${ABICHECK_TMPDIR}/dissectors/x11-register-info.h
283                 ${ABICHECK_TMPDIR}/dissectors/packet-idmp.h
284         COMMAND ${ABICHECK_COMMAND}
285         COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwireshark/libwireshark_* ${CMAKE_CURRENT_BINARY_DIR}/libwireshark.abi.tar.gz
286         COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
287 #       COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps ${ABICHECK_TMPDIR}/config.h
288 #               ${ABICHECK_TMPDIR}/epan/* ${ABICHECK_TMPDIR}/crypt/*
289 #               ${ABICHECK_TMPDIR}/epan/* ${ABICHECK_TMPDIR}/compress/*
290 #               ${ABICHECK_TMPDIR}/dfilter/* ${ABICHECK_TMPDIR}/dissectors/*
291 #               ${ABICHECK_TMPDIR}/ftypes/* ${ABICHECK_TMPDIR}/wmem/*
292 #               ${ABICHECK_TMPDIR}/nghttp2/*
293         DEPENDS ${HEADERS}
294                 ${CRYPT_HEADERS} ${COMPRESS_HEADERS} ${DFILTER_HEADERS} ${D_HEADERS}
295                 ${FTYPES_HEADERS} ${WMEM_HEADERS} ${NGHTTP2_HEADERS} epan)
296
297 # By default the name for a library with target name epan will be libepan,
298 # but Ethereal is now named Wireshark
299 set_target_properties(epan PROPERTIES
300         OUTPUT_NAME "wireshark"
301         PREFIX "lib"
302         FOLDER "DLLs"
303 )
304
305 target_link_libraries(epan ${epan_LIBS})
306
307 add_dependencies(epan lemon)
308
309 if(NOT ${ENABLE_STATIC})
310         install(TARGETS epan
311                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
312                 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
313                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
314         )
315 endif()
316
317 add_executable(exntest EXCLUDE_FROM_ALL exntest.c except.c)
318 target_link_libraries(exntest ${GLIB2_LIBRARIES})
319 set_target_properties(exntest PROPERTIES
320         FOLDER "Tests"
321         COMPILE_DEFINITIONS "WS_BUILD_DLL"
322 )
323
324 add_executable(oids_test EXCLUDE_FROM_ALL oids_test.c)
325 target_link_libraries(oids_test epan ${ZLIB_LIBRARIES})
326 set_target_properties(oids_test PROPERTIES
327         FOLDER "Tests"
328         COMPILE_DEFINITIONS "WS_BUILD_DLL"
329 )
330
331 add_executable(reassemble_test EXCLUDE_FROM_ALL reassemble_test.c)
332 target_link_libraries(reassemble_test epan)
333 set_target_properties(reassemble_test PROPERTIES
334         FOLDER "Tests"
335 )
336
337 add_executable(tvbtest EXCLUDE_FROM_ALL tvbtest.c)
338 target_link_libraries(tvbtest epan)
339 set_target_properties(tvbtest PROPERTIES
340         FOLDER "Tests"
341         COMPILE_DEFINITIONS "WS_BUILD_DLL"
342 )
343
344 #
345 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
346 #
347 # Local variables:
348 # c-basic-offset: 8
349 # tab-width: 8
350 # indent-tabs-mode: t
351 # End:
352 #
353 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
354 # :indentSize=8:tabSize=8:noTabs=false:
355 #