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)
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()
23 # Ensure "run/extcap" exists
24 # add_custom_command(OUTPUT "${DATAFILE_DIR}/extcap"
25 # COMMAND ${CMAKE_COMMAND} -E make_directory
26 # "${DATAFILE_DIR}/extcap"
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}"
38 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
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
52 set_target_properties(${_executable} PROPERTIES
53 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/wireshark
55 if(ENABLE_APPLICATION_BUNDLE)
56 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
58 set_target_properties(${_executable} PROPERTIES
59 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/MacOS/extcap
62 set_target_properties(${_executable} PROPERTIES
63 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/extcap
65 # Create a convenience link from run/<name> to its respective
66 # target in the application bundle.
67 add_custom_target(${_executable}-symlink
69 Wireshark.app/Contents/MacOS/extcap/${_executable}
70 ${CMAKE_BINARY_DIR}/run/${_executable}
72 add_dependencies(${_executable} ${_executable}-symlink)
78 set_target_properties(${_executable} PROPERTIES
79 LINK_OPTIONS -municode
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}"
91 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
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
105 set_target_properties(${_executable} PROPERTIES
106 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/stratoshark
108 if(ENABLE_APPLICATION_BUNDLE)
109 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
111 set_target_properties(${_executable} PROPERTIES
112 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/$<CONFIG>/Stratoshark.app/Contents/MacOS/extcap
115 set_target_properties(${_executable} PROPERTIES
116 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/MacOS/extcap
118 # Create a convenience link from run/<name> to its respective
119 # target in the application bundle.
120 add_custom_target(${_executable}-symlink
122 Stratoshark.app/Contents/MacOS/extcap/${_executable}
123 ${CMAKE_BINARY_DIR}/run/${_executable}
125 add_dependencies(${_executable} ${_executable}-symlink)
131 add_custom_target(extcaps)
133 add_library(extcap-base OBJECT extcap-base.c)
135 add_library(ssh-base OBJECT ssh-base.c)
136 target_include_directories(ssh-base SYSTEM
138 ${LIBSSH_INCLUDE_DIRS}
142 if(BUILD_androiddump)
143 if(EXTCAP_ANDROIDDUMP_LIBPCAP)
149 ${WIN_WS2_32_LIBRARY}
150 $<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
153 message(FATAL_ERROR "You are trying to build androiddump with libpcap but do not have it")
161 ${WIN_WS2_32_LIBRARY}
164 set(androiddump_FILES
165 $<TARGET_OBJECTS:cli_main>
166 $<TARGET_OBJECTS:extcap-base>
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)
178 if(BUILD_sshdump AND LIBSSH_FOUND)
182 ${WIN_WS2_32_LIBRARY}
186 $<TARGET_OBJECTS:cli_main>
187 $<TARGET_OBJECTS:extcap-base>
188 $<TARGET_OBJECTS:ssh-base>
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" )
203 if(BUILD_ciscodump AND LIBSSH_FOUND)
208 ${WIN_WS2_32_LIBRARY}
212 $<TARGET_OBJECTS:cli_main>
213 $<TARGET_OBJECTS:extcap-base>
214 $<TARGET_OBJECTS:ssh-base>
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" )
229 if(BUILD_wifidump AND LIBSSH_FOUND)
234 ${WIN_WS2_32_LIBRARY}
238 $<TARGET_OBJECTS:cli_main>
239 $<TARGET_OBJECTS:extcap-base>
240 $<TARGET_OBJECTS:ssh-base>
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" )
255 if(BUILD_dpauxmon AND HAVE_LIBNL3)
264 $<TARGET_OBJECTS:extcap-base>
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" )
283 ${WIN_WS2_32_LIBRARY}
288 $<TARGET_OBJECTS:cli_main>
289 $<TARGET_OBJECTS:extcap-base>
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)
301 if(BUILD_randpktdump)
307 ${WIN_WS2_32_LIBRARY}
309 set(randpktdump_FILES
310 $<TARGET_OBJECTS:cli_main>
311 $<TARGET_OBJECTS:extcap-base>
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)
324 if(BUILD_etwdump AND WIN32)
332 ${WIN_WS2_32_LIBRARY}
335 $<TARGET_OBJECTS:cli_main>
336 $<TARGET_OBJECTS:extcap-base>
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)
351 if(BUILD_sdjournal AND SYSTEMD_FOUND)
359 $<TARGET_OBJECTS:extcap-base>
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)
372 if(BUILD_falcodump AND SINSP_FOUND)
375 ${SINSP_LINK_LIBRARIES}
380 $<TARGET_OBJECTS:extcap-base>
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})
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})
394 install(TARGETS falcodump RUNTIME DESTINATION ${LOG_EXTCAP_INSTALL_LIBDIR})
395 add_dependencies(extcaps falcodump)
400 # Editor modelines - https://www.wireshark.org/tools/modelines.html
405 # indent-tabs-mode: t
408 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
409 # :indentSize=8:tabSize=8:noTabs=false: