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")
30 macro(set_common_executable_properties _executable _application)
31 set_target_properties(${_executable} PROPERTIES
32 LINK_FLAGS "${WS_LINK_FLAGS}"
33 FOLDER "Executables/Extcaps"
34 INSTALL_RPATH "${EXTCAP_INSTALL_RPATH}"
37 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
40 set(PROGLIST ${PROGLIST} ${_executable})
42 string(TOLOWER ${_application} _application_lower)
43 if(CMAKE_CONFIGURATION_TYPES)
44 set_target_properties(${_executable} PROPERTIES
45 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/${_application_lower}
46 RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/run/Debug/extcap/${_application_lower}
47 RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/run/Release/extcap/${_application_lower}
48 RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/run/MinSizeRel/extcap/${_application_lower}
49 RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/run/RelWithDebInfo/extcap/${_application_lower}
52 set_target_properties(${_executable} PROPERTIES
53 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap/${_application_lower}
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>/${_application}.app/Contents/MacOS/extcap
62 set_target_properties(${_executable} PROPERTIES
63 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/${_application}.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 ${_application}.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
83 unset(_application_lower)
86 macro(set_extcap_executable_properties _executable)
87 set_common_executable_properties(${_executable} Wireshark)
90 macro(set_extlog_executable_properties _executable)
91 set_common_executable_properties(${_executable} Stratoshark)
94 add_custom_target(extcaps)
96 add_library(extcap-base OBJECT extcap-base.c)
98 add_library(ssh-base OBJECT ssh-base.c)
99 target_include_directories(ssh-base SYSTEM
101 ${LIBSSH_INCLUDE_DIRS}
105 if(BUILD_androiddump)
106 if(EXTCAP_ANDROIDDUMP_LIBPCAP)
112 ${WIN_WS2_32_LIBRARY}
113 $<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
116 message(FATAL_ERROR "You are trying to build androiddump with libpcap but do not have it")
124 ${WIN_WS2_32_LIBRARY}
127 set(androiddump_FILES
128 $<TARGET_OBJECTS:cli_main>
129 $<TARGET_OBJECTS:extcap-base>
133 set_executable_resources(androiddump "Androiddump")
134 add_executable(androiddump ${androiddump_FILES})
135 set_extcap_executable_properties(androiddump)
136 target_link_libraries(androiddump ${androiddump_LIBS})
137 install(TARGETS androiddump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
138 add_dependencies(extcaps androiddump)
141 if(BUILD_sshdump AND LIBSSH_FOUND)
145 ${WIN_WS2_32_LIBRARY}
149 $<TARGET_OBJECTS:cli_main>
150 $<TARGET_OBJECTS:extcap-base>
151 $<TARGET_OBJECTS:ssh-base>
155 set_executable_resources(sshdump "Sshdump")
156 add_executable(sshdump ${sshdump_FILES})
157 set_extcap_executable_properties(sshdump)
158 target_link_libraries(sshdump ${sshdump_LIBS})
159 target_include_directories(sshdump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
160 install(TARGETS sshdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
161 add_dependencies(extcaps sshdump)
162 elseif (BUILD_sshdump)
163 #message( WARNING "Cannot find libssh, cannot build sshdump" )
166 if(BUILD_ciscodump AND LIBSSH_FOUND)
171 ${WIN_WS2_32_LIBRARY}
175 $<TARGET_OBJECTS:cli_main>
176 $<TARGET_OBJECTS:extcap-base>
177 $<TARGET_OBJECTS:ssh-base>
181 set_executable_resources(ciscodump "Ciscodump")
182 add_executable(ciscodump ${ciscodump_FILES})
183 set_extcap_executable_properties(ciscodump)
184 target_link_libraries(ciscodump ${ciscodump_LIBS})
185 target_include_directories(ciscodump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
186 install(TARGETS ciscodump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
187 add_dependencies(extcaps ciscodump)
188 elseif (BUILD_ciscodump)
189 #message( WARNING "Cannot find libssh, cannot build ciscodump" )
192 if(BUILD_wifidump AND LIBSSH_FOUND)
197 ${WIN_WS2_32_LIBRARY}
201 $<TARGET_OBJECTS:cli_main>
202 $<TARGET_OBJECTS:extcap-base>
203 $<TARGET_OBJECTS:ssh-base>
207 set_executable_resources(wifidump "Wifidump")
208 add_executable(wifidump ${wifidump_FILES})
209 set_extcap_executable_properties(wifidump)
210 target_link_libraries(wifidump ${wifidump_LIBS})
211 target_include_directories(wifidump SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
212 install(TARGETS wifidump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
213 add_dependencies(extcaps wifidump)
214 elseif (BUILD_wifidump)
215 #message( WARNING "Cannot find libssh, cannot build wifidump" )
218 if(BUILD_dpauxmon AND HAVE_LIBNL3)
227 $<TARGET_OBJECTS:extcap-base>
231 set_executable_resources(dpauxmon "dpauxmon")
232 add_executable(dpauxmon ${dpauxmon_FILES})
233 set_extcap_executable_properties(dpauxmon)
234 target_link_libraries(dpauxmon ${dpauxmon_LIBS})
235 target_include_directories(dpauxmon SYSTEM PRIVATE ${NL_INCLUDE_DIRS})
236 install(TARGETS dpauxmon RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
237 add_dependencies(extcaps dpauxmon)
238 elseif (BUILD_dpauxmon)
239 #message( WARNING "Cannot find libnl3, cannot build dpauxmon" )
246 ${WIN_WS2_32_LIBRARY}
251 $<TARGET_OBJECTS:cli_main>
252 $<TARGET_OBJECTS:extcap-base>
256 set_executable_resources(udpdump "udpdump")
257 add_executable(udpdump ${udpdump_FILES})
258 set_extcap_executable_properties(udpdump)
259 target_link_libraries(udpdump ${udpdump_LIBS})
260 install(TARGETS udpdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
261 add_dependencies(extcaps udpdump)
264 if(BUILD_randpktdump)
270 ${WIN_WS2_32_LIBRARY}
272 set(randpktdump_FILES
273 $<TARGET_OBJECTS:cli_main>
274 $<TARGET_OBJECTS:extcap-base>
278 set_executable_resources(randpktdump "randpktdump")
279 add_executable(randpktdump ${randpktdump_FILES})
280 set_extcap_executable_properties(randpktdump)
281 target_link_libraries(randpktdump ${randpktdump_LIBS})
282 install(TARGETS randpktdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
283 add_dependencies(extcaps randpktdump)
287 if(BUILD_etwdump AND WIN32)
295 ${WIN_WS2_32_LIBRARY}
298 $<TARGET_OBJECTS:cli_main>
299 $<TARGET_OBJECTS:extcap-base>
306 set_executable_resources(etwdump "etwdump")
307 add_executable(etwdump ${etwdump_FILES})
308 set_extcap_executable_properties(etwdump)
309 target_link_libraries(etwdump ${etwdump_LIBS})
310 install(TARGETS etwdump RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
311 add_dependencies(extcaps etwdump)
314 if(BUILD_sdjournal AND SYSTEMD_FOUND)
322 $<TARGET_OBJECTS:extcap-base>
326 set_executable_resources(sdjournal "sdjournal")
327 add_executable(sdjournal ${sdjournal_FILES})
328 set_extcap_executable_properties(sdjournal)
329 target_link_libraries(sdjournal ${sdjournal_LIBS})
330 target_include_directories(sdjournal SYSTEM PRIVATE ${SYSTEMD_INCLUDE_DIRS})
331 install(TARGETS sdjournal RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
332 add_dependencies(extcaps sdjournal)
335 if(BUILD_falcodump AND SINSP_FOUND)
338 ${SINSP_LINK_LIBRARIES}
343 $<TARGET_OBJECTS:extcap-base>
347 set_executable_resources(falcodump "falcodump")
348 add_executable(falcodump ${falcodump_FILES})
349 set_extlog_executable_properties(falcodump)
350 target_link_libraries(falcodump ${falcodump_LIBS})
351 target_include_directories(falcodump SYSTEM PRIVATE ${SINSP_INCLUDE_DIRS})
353 # libsinsp/dumper.h includes libscap/scap_savefile_api.h, which includes
354 # libscap/scap_zlib.h.
355 target_include_directories(falcodump SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
357 install(TARGETS falcodump RUNTIME DESTINATION ${LOG_EXTCAP_INSTALL_LIBDIR})
358 add_dependencies(extcaps falcodump)
361 if(BUILD_sshdig AND LIBSSH_FOUND)
365 ${WIN_WS2_32_LIBRARY}
369 $<TARGET_OBJECTS:cli_main>
370 $<TARGET_OBJECTS:extcap-base>
371 $<TARGET_OBJECTS:ssh-base>
375 set_executable_resources(sshdig "Sshdig")
376 add_executable(sshdig ${sshdig_FILES})
377 set_extlog_executable_properties(sshdig)
378 target_link_libraries(sshdig ${sshdig_LIBS})
379 target_include_directories(sshdig SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
380 install(TARGETS sshdig RUNTIME DESTINATION ${EXTCAP_INSTALL_LIBDIR})
381 add_dependencies(extcaps sshdig)
382 elseif (BUILD_sshdig)
383 #message( WARNING "Cannot find libssh, cannot build sshdig" )
387 # Editor modelines - https://www.wireshark.org/tools/modelines.html
392 # indent-tabs-mode: t
395 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
396 # :indentSize=8:tabSize=8:noTabs=false: