LATER... ei_kerberos_kdc_session_key ...
[wireshark-sm.git] / extcap / CMakeLists.txt
blobe1132ac4f933478378f11ec909ddd02279c4b7f4
1 # CMakeLists.txt
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
10 if(EXTCAP_ANDROIDDUMP_LIBPCAP)
11         set(ANDROIDDUMP_USE_LIBPCAP 1)
12 endif()
14 if(LIBSSH_FOUND)
15         include(CMakePushCheckState)
16         cmake_push_check_state()
17         set(CMAKE_REQUIRED_INCLUDES ${LIBSSH_INCLUDE_DIRS})
18         set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LIBRARIES})
19         check_function_exists(ssh_userauth_agent LIBSSH_USERAUTH_AGENT_FOUND)
20         cmake_pop_check_state()
21 endif()
23 # Ensure "run/extcap" exists
24 # add_custom_command(OUTPUT "${DATAFILE_DIR}/extcap"
25 #       COMMAND ${CMAKE_COMMAND} -E make_directory
26 #               "${DATAFILE_DIR}/extcap"
27 # )
28 # list(APPEND copy_data_files_depends "${DATAFILE_DIR}/extcap")
31 macro(set_extcap_executable_properties _executable)
32         set_target_properties(${_executable} PROPERTIES
33                 LINK_FLAGS "${WS_LINK_FLAGS}"
34                 FOLDER "Executables/Extcaps"
35                 INSTALL_RPATH "${EXTCAP_INSTALL_RPATH}"
36         )
37         if(MSVC)
38                 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
39         endif()
41         set(PROGLIST ${PROGLIST} ${_executable})
43         if(CMAKE_CONFIGURATION_TYPES)
44                 set_target_properties(${_executable} PROPERTIES
45                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/wireshark
46                         RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/run/Debug/extcap/wireshark
47                         RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/run/Release/extcap/wireshark
48                         RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/run/MinSizeRel/extcap/wireshark
49                         RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/run/RelWithDebInfo/extcap/wireshark
50                 )
51         else()
52                 set_target_properties(${_executable} PROPERTIES
53                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/wireshark
54                 )
55                 if(ENABLE_APPLICATION_BUNDLE)
56                         if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
57                                 # Xcode
58                                 set_target_properties(${_executable} PROPERTIES
59                                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/MacOS/extcap
60                                 )
61                         else()
62                                 set_target_properties(${_executable} PROPERTIES
63                                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/extcap
64                                 )
65                                 # Create a convenience link from run/<name> to its respective
66                                 # target in the application bundle.
67                                 add_custom_target(${_executable}-symlink
68                                         COMMAND ln -s -f
69                                                 Wireshark.app/Contents/MacOS/extcap/${_executable}
70                                                 ${CMAKE_BINARY_DIR}/run/${_executable}
71                                 )
72                                 add_dependencies(${_executable} ${_executable}-symlink)
73                         endif()
74                 endif()
75         endif()
77         if (MINGW)
78                 set_target_properties(${_executable} PROPERTIES
79                         LINK_OPTIONS -municode
80                 )
81         endif()
82 endmacro()
84 macro(set_extlog_executable_properties _executable)
85         set_target_properties(${_executable} PROPERTIES
86                 LINK_FLAGS "${WS_LINK_FLAGS}"
87                 FOLDER "Executables/Extcaps"
88                 INSTALL_RPATH "${EXTCAP_INSTALL_RPATH}"
89         )
90         if(MSVC)
91                 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
92         endif()
94         set(PROGLIST ${PROGLIST} ${_executable})
96         if(CMAKE_CONFIGURATION_TYPES)
97                 set_target_properties(${_executable} PROPERTIES
98                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/stratoshark
99                         RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/run/Debug/extcap/stratoshark
100                         RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/run/Release/extcap/stratoshark
101                         RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/run/MinSizeRel/extcap/stratoshark
102                         RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/run/RelWithDebInfo/extcap/stratoshark
103                 )
104         else()
105                 set_target_properties(${_executable} PROPERTIES
106                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/stratoshark
107                 )
108                 if(ENABLE_APPLICATION_BUNDLE)
109                         if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
110                                 # Xcode
111                                 set_target_properties(${_executable} PROPERTIES
112                                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/$<CONFIG>/Stratoshark.app/Contents/MacOS/extcap
113                                 )
114                         else()
115                                 set_target_properties(${_executable} PROPERTIES
116                                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/MacOS/extcap
117                                 )
118                                 # Create a convenience link from run/<name> to its respective
119                                 # target in the application bundle.
120                                 add_custom_target(${_executable}-symlink
121                                         COMMAND ln -s -f
122                                                 Stratoshark.app/Contents/MacOS/extcap/${_executable}
123                                                 ${CMAKE_BINARY_DIR}/run/${_executable}
124                                 )
125                                 add_dependencies(${_executable} ${_executable}-symlink)
126                         endif()
127                 endif()
128         endif()
129 endmacro()
131 add_custom_target(extcaps)
133 add_library(extcap-base OBJECT extcap-base.c)
134 if(LIBSSH_FOUND)
135         add_library(ssh-base OBJECT ssh-base.c)
136         target_include_directories(ssh-base SYSTEM
137                 PRIVATE
138                         ${LIBSSH_INCLUDE_DIRS}
139         )
140 endif()
142 if(BUILD_androiddump)
143         if(EXTCAP_ANDROIDDUMP_LIBPCAP)
144                 if(HAVE_LIBPCAP)
145                         set(androiddump_LIBS
146                                 ui
147                                 wiretap
148                                 wsutil
149                                 ${WIN_WS2_32_LIBRARY}
150                                 $<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
151                         )
152                 else()
153                         message(FATAL_ERROR "You are trying to build androiddump with libpcap but do not have it")
154                 endif()
155         else()
156                 set(androiddump_LIBS
157                         ui
158                         wiretap
159                         wsutil
160                         ${CMAKE_DL_LIBS}
161                         ${WIN_WS2_32_LIBRARY}
162                 )
163         endif()
164         set(androiddump_FILES
165                 $<TARGET_OBJECTS:cli_main>
166                 $<TARGET_OBJECTS:extcap-base>
167                 androiddump.c
168         )
170         set_executable_resources(androiddump "Androiddump")
171         add_executable(androiddump ${androiddump_FILES})
172         set_extcap_executable_properties(androiddump)
173         target_link_libraries(androiddump ${androiddump_LIBS})
174         install(TARGETS androiddump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
175         add_dependencies(extcaps androiddump)
176 endif()
178 if(BUILD_sshdump AND LIBSSH_FOUND)
179         set(sshdump_LIBS
180                 wsutil
181                 ${CMAKE_DL_LIBS}
182                 ${WIN_WS2_32_LIBRARY}
183                 ${LIBSSH_LIBRARIES}
184         )
185         set(sshdump_FILES
186                 $<TARGET_OBJECTS:cli_main>
187                 $<TARGET_OBJECTS:extcap-base>
188                 $<TARGET_OBJECTS:ssh-base>
189                 sshdump.c
190         )
192         set_executable_resources(sshdump "Sshdump")
193         add_executable(sshdump ${sshdump_FILES})
194         set_extcap_executable_properties(sshdump)
195         target_link_libraries(sshdump ${sshdump_LIBS})
196         target_include_directories(sshdump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
197         install(TARGETS sshdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
198         add_dependencies(extcaps sshdump)
199 elseif (BUILD_sshdump)
200         #message( WARNING "Cannot find libssh, cannot build sshdump" )
201 endif()
203 if(BUILD_ciscodump AND LIBSSH_FOUND)
204         set(ciscodump_LIBS
205                 writecap
206                 wsutil
207                 ${CMAKE_DL_LIBS}
208                 ${WIN_WS2_32_LIBRARY}
209                 ${LIBSSH_LIBRARIES}
210         )
211         set(ciscodump_FILES
212                 $<TARGET_OBJECTS:cli_main>
213                 $<TARGET_OBJECTS:extcap-base>
214                 $<TARGET_OBJECTS:ssh-base>
215                 ciscodump.c
216         )
218         set_executable_resources(ciscodump "Ciscodump")
219         add_executable(ciscodump ${ciscodump_FILES})
220         set_extcap_executable_properties(ciscodump)
221         target_link_libraries(ciscodump ${ciscodump_LIBS})
222         target_include_directories(ciscodump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
223         install(TARGETS ciscodump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
224         add_dependencies(extcaps ciscodump)
225 elseif (BUILD_ciscodump)
226         #message( WARNING "Cannot find libssh, cannot build ciscodump" )
227 endif()
229 if(BUILD_wifidump AND LIBSSH_FOUND)
230         set(wifidump_LIBS
231                 writecap
232                 wsutil
233                 ${CMAKE_DL_LIBS}
234                 ${WIN_WS2_32_LIBRARY}
235                 ${LIBSSH_LIBRARIES}
236         )
237         set(wifidump_FILES
238                 $<TARGET_OBJECTS:cli_main>
239                 $<TARGET_OBJECTS:extcap-base>
240                 $<TARGET_OBJECTS:ssh-base>
241                 wifidump.c
242         )
244         set_executable_resources(wifidump "Wifidump")
245         add_executable(wifidump ${wifidump_FILES})
246         set_extcap_executable_properties(wifidump)
247         target_link_libraries(wifidump ${wifidump_LIBS})
248         target_include_directories(wifidump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
249         install(TARGETS wifidump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
250         add_dependencies(extcaps wifidump)
251 elseif (BUILD_wifidump)
252         #message( WARNING "Cannot find libssh, cannot build wifidump" )
253 endif()
255 if(BUILD_dpauxmon AND HAVE_LIBNL3)
256         set(dpauxmon_LIBS
257                 wsutil
258                 writecap
259                 ${GLIB2_LIBRARIES}
260                 ${CMAKE_DL_LIBS}
261                 ${NL_LIBRARIES}
262         )
263         set(dpauxmon_FILES
264                 $<TARGET_OBJECTS:extcap-base>
265                 dpauxmon.c
266         )
268         set_executable_resources(dpauxmon "dpauxmon")
269         add_executable(dpauxmon ${dpauxmon_FILES})
270         set_extcap_executable_properties(dpauxmon)
271         target_link_libraries(dpauxmon ${dpauxmon_LIBS})
272         target_include_directories(dpauxmon SYSTEM PRIVATE ${NL_INCLUDE_DIRS})
273         install(TARGETS dpauxmon RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
274         add_dependencies(extcaps dpauxmon)
275 elseif (BUILD_dpauxmon)
276         #message( WARNING "Cannot find libnl3, cannot build dpauxmon" )
277 endif()
279 if(BUILD_udpdump)
280         set(udpdump_LIBS
281                 wsutil
282                 ${CMAKE_DL_LIBS}
283                 ${WIN_WS2_32_LIBRARY}
284                 wsutil
285                 writecap
286         )
287         set(udpdump_FILES
288                 $<TARGET_OBJECTS:cli_main>
289                 $<TARGET_OBJECTS:extcap-base>
290                 udpdump.c
291         )
293         set_executable_resources(udpdump "udpdump")
294         add_executable(udpdump ${udpdump_FILES})
295         set_extcap_executable_properties(udpdump)
296         target_link_libraries(udpdump ${udpdump_LIBS})
297         install(TARGETS udpdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
298         add_dependencies(extcaps udpdump)
299 endif()
301 if(BUILD_randpktdump)
302         set(randpktdump_LIBS
303                 randpkt_core
304                 wiretap
305                 wsutil
306                 ${CMAKE_DL_LIBS}
307                 ${WIN_WS2_32_LIBRARY}
308         )
309         set(randpktdump_FILES
310                 $<TARGET_OBJECTS:cli_main>
311                 $<TARGET_OBJECTS:extcap-base>
312                 randpktdump.c
313         )
315         set_executable_resources(randpktdump "randpktdump")
316         add_executable(randpktdump ${randpktdump_FILES})
317         set_extcap_executable_properties(randpktdump)
318         target_link_libraries(randpktdump ${randpktdump_LIBS})
319         install(TARGETS randpktdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
320         add_dependencies(extcaps randpktdump)
321 endif()
324 if(BUILD_etwdump AND WIN32)
325         set(etwdump_LIBS
326                 wiretap
327                 wsutil
328                 tdh
329                 wevtapi
330                 rpcrt4
331                 ${CMAKE_DL_LIBS}
332                 ${WIN_WS2_32_LIBRARY}
333         )
334         set(etwdump_FILES
335                 $<TARGET_OBJECTS:cli_main>
336                 $<TARGET_OBJECTS:extcap-base>
337                 etwdump.c
338                 etl.c
339                 etw_message.c
340                 etw_ndiscap.c
341         )
343         set_executable_resources(etwdump "etwdump")
344         add_executable(etwdump ${etwdump_FILES})
345         set_extcap_executable_properties(etwdump)
346         target_link_libraries(etwdump ${etwdump_LIBS})
347         install(TARGETS etwdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
348         add_dependencies(extcaps etwdump)
349 endif()
351 if(BUILD_sdjournal AND SYSTEMD_FOUND)
352         set(sdjournal_LIBS
353                 writecap
354                 wsutil
355                 ${CMAKE_DL_LIBS}
356                 ${SYSTEMD_LIBRARIES}
357         )
358         set(sdjournal_FILES
359                 $<TARGET_OBJECTS:extcap-base>
360                 sdjournal.c
361         )
363         set_executable_resources(sdjournal "sdjournal")
364         add_executable(sdjournal ${sdjournal_FILES})
365         set_extcap_executable_properties(sdjournal)
366         target_link_libraries(sdjournal ${sdjournal_LIBS})
367         target_include_directories(sdjournal SYSTEM PRIVATE ${SYSTEMD_INCLUDE_DIRS})
368         install(TARGETS sdjournal RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
369         add_dependencies(extcaps sdjournal)
370 endif()
372 if(BUILD_falcodump AND SINSP_FOUND)
373         set(falcodump_LIBS
374                 wsutil
375                 ${SINSP_LINK_LIBRARIES}
376                 ${CMAKE_DL_LIBS}
377                 ${GCRYPT_LIBRARIES}
378         )
379         set(falcodump_FILES
380                 $<TARGET_OBJECTS:extcap-base>
381                 falcodump.cpp
382         )
384         set_executable_resources(falcodump "falcodump")
385         add_executable(falcodump ${falcodump_FILES})
386         set_extlog_executable_properties(falcodump)
387         target_link_libraries(falcodump ${falcodump_LIBS})
388         target_include_directories(falcodump SYSTEM PRIVATE ${SINSP_INCLUDE_DIRS})
389         if(WIN32)
390                 # libsinsp/dumper.h includes libscap/scap_savefile_api.h, which includes
391                 # libscap/scap_zlib.h.
392                 target_include_directories(falcodump SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
393         endif()
394         install(TARGETS falcodump RUNTIME DESTINATION ${LOG_EXTCAP_INSTALL_LIBDIR})
395         add_dependencies(extcaps falcodump)
397 endif()
400 # Editor modelines  -  https://www.wireshark.org/tools/modelines.html
402 # Local variables:
403 # c-basic-offset: 8
404 # tab-width: 8
405 # indent-tabs-mode: t
406 # End:
408 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
409 # :indentSize=8:tabSize=8:noTabs=false: