CMake: Cleanup unnecessary linking with shared libraries

This commit is contained in:
João Valverde 2023-01-30 20:27:06 +00:00
parent 2855c8ec46
commit b07ab25a1c
12 changed files with 43 additions and 33 deletions

View File

@ -2591,6 +2591,7 @@ if(BUILD_wireshark AND QT_FOUND)
wiretap
epan
version_info
summary
${QT_LIBRARIES}
${APPLE_APPLICATION_SERVICES_LIBRARY}
${APPLE_APPKIT_LIBRARY}
@ -2696,6 +2697,7 @@ if(BUILD_logray AND QT_FOUND)
wiretap
epan
version_info
summary
${QT_LIBRARIES}
${APPLE_APPLICATION_SERVICES_LIBRARY}
${APPLE_APPKIT_LIBRARY}
@ -2854,6 +2856,7 @@ if(BUILD_tshark)
caputils
wiretap
epan
wsutil
version_info
${APPLE_CORE_FOUNDATION_LIBRARY}
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
@ -2935,7 +2938,6 @@ if(BUILD_sharkd)
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
${WIN_WS2_32_LIBRARY}
${SPEEXDSP_LIBRARIES}
${M_LIBRARIES}
)
set(sharkd_FILES
#
@ -2978,9 +2980,6 @@ if(BUILD_randpkt)
ui
wiretap
wsutil
${M_LIBRARIES}
${CARES_LIBRARIES}
${ZLIB_LIBRARIES}
)
set(randpkt_FILES
$<TARGET_OBJECTS:cli_main>
@ -3006,7 +3005,6 @@ if(BUILD_text2pcap)
ui
epan
version_info
${M_LIBRARIES}
${ZLIB_LIBRARIES}
)
set(text2pcap_FILES
@ -3137,7 +3135,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
version_info
pcap::pcap
${CAP_LIBRARIES}
${GTHREAD2_LIBRARIES}
${ZLIB_LIBRARIES}
${APPLE_CORE_FOUNDATION_LIBRARY}
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}

View File

@ -48,12 +48,15 @@ add_library(caputils STATIC
target_link_libraries(caputils
PUBLIC
wsutil
$<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
PRIVATE
wsutil
${NL_LIBRARIES}
${WIN_IPHLPAPI_LIBRARY}
)
if(WIN32)
target_link_libraries(caputils PRIVATE ${GMODULE2_LIBRARIES})
endif()
target_include_directories(caputils SYSTEM
PRIVATE

View File

@ -323,16 +323,15 @@ endif()
target_link_libraries(epan
PUBLIC
wiretap
wsutil
${GLIB2_LIBRARIES}
PRIVATE
wiretap
${BROTLI_LIBRARIES}
${CARES_LIBRARIES}
${GCRYPT_LIBRARIES}
${GIO2_LIBRARIES}
${GNUTLS_LIBRARIES}
${GTHREAD2_LIBRARIES}
${KERBEROS_LIBRARIES}
${LIBXML2_LIBRARIES}
${LUA_LIBRARIES}
@ -366,7 +365,6 @@ target_include_directories(epan
${GCRYPT_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${GTHREAD2_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${LUA_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
@ -404,7 +402,7 @@ set_target_properties(exntest PROPERTIES
)
add_executable(oids_test EXCLUDE_FROM_ALL oids_test.c)
target_link_libraries(oids_test epan ${ZLIB_LIBRARIES})
target_link_libraries(oids_test epan)
set_target_properties(oids_test PROPERTIES
FOLDER "Tests"
EXCLUDE_FROM_DEFAULT_BUILD True

View File

@ -220,7 +220,7 @@ void epan_register_plugin(const epan_plugin *plug _U_)
int epan_plugins_supported(void)
{
#ifdef HAVE_PLUGINS
return g_module_supported() ? 0 : 1;
return plugins_supported() ? 0 : 1;
#else
return -1;
#endif

View File

@ -136,7 +136,6 @@ if(BUILD_androiddump)
ui
wiretap
wsutil
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
${WIN_WS2_32_LIBRARY}
)
@ -236,6 +235,7 @@ if(BUILD_dpauxmon AND HAVE_LIBNL3)
set(dpauxmon_LIBS
wsutil
writecap
${GLIB2_LIBRARIES}
${CMAKE_DL_LIBS}
${NL_LIBRARIES}
)
@ -282,7 +282,6 @@ if(BUILD_randpktdump)
randpkt_core
wiretap
wsutil
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
${WIN_WS2_32_LIBRARY}
)
@ -308,7 +307,6 @@ if(BUILD_etwdump AND WIN32)
tdh
wevtapi
rpcrt4
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
${WIN_WS2_32_LIBRARY}
)
@ -331,13 +329,10 @@ endif()
if(BUILD_sdjournal AND SYSTEMD_FOUND)
set(sdjournal_LIBS
wiretap
writecap
wsutil
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
${SYSTEMD_LIBRARIES}
${GCRYPT_LIBRARIES}
)
set(sdjournal_FILES
$<TARGET_OBJECTS:extcap-base>

View File

@ -40,7 +40,6 @@ set(NONGENERATED_UI_SRC
service_response_time.c
software_update.c
ssl_key_export.c
summary.c
tap_export_pdu.c
tap-iax2-analysis.c
tap-rtp-analysis.c
@ -80,17 +79,28 @@ add_library(ui STATIC ${UI_SRC})
target_link_libraries(ui
PRIVATE
caputils
wsutil
)
target_include_directories(ui
SYSTEM PRIVATE
${PCAP_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
)
add_library(summary STATIC summary.c)
target_link_libraries(summary
PRIVATE
wiretap
epan
wsutil
${GCRYPT_LIBRARIES}
)
target_include_directories(ui
target_include_directories(summary
SYSTEM PRIVATE
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
)
add_library(version_info STATIC version_info.c)

View File

@ -490,7 +490,7 @@ get_runtime_version_info(gather_feature_func gather_runtime)
}
#ifdef HAVE_PLUGINS
if (g_module_supported()) {
if (plugins_supported()) {
g_string_append(str, ", binary plugins supported");
}
#endif

View File

@ -185,6 +185,7 @@ endif()
target_link_libraries(wiretap
PUBLIC
wsutil
${GLIB2_LIBRARIES}
PRIVATE
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}

View File

@ -49,7 +49,7 @@ int
wtap_plugins_supported(void)
{
#ifdef HAVE_PLUGINS
return g_module_supported() ? 0 : 1;
return plugins_supported() ? 0 : 1;
#else
return -1;
#endif

View File

@ -302,27 +302,26 @@ if(MSVC)
endif()
target_link_libraries(wsutil
# *Lots* of our targets that link with wsutil also link with
# GLib and GModule. Mark them PUBLIC so that dependent targets
# don't have to link them directly.
PUBLIC
${GLIB2_LIBRARIES}
${GMODULE2_LIBRARIES}
PRIVATE
${GMODULE2_LIBRARIES}
${APPLE_CORE_FOUNDATION_LIBRARY}
${CMAKE_DL_LIBS}
${GCRYPT_LIBRARIES}
${GNUTLS_LIBRARIES}
${PCRE2_LIBRARIES}
${M_LIBRARIES}
${WIN_IPHLPAPI_LIBRARY}
${WIN_WS2_32_LIBRARY}
)
target_include_directories(wsutil
SYSTEM PRIVATE
target_include_directories(wsutil SYSTEM
PUBLIC
${GLIB2_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
PRIVATE
${GMODULE2_INCLUDE_DIRS}
${PCRE2_INCLUDE_DIRS}
)

View File

@ -300,6 +300,12 @@ plugins_cleanup(plugins_t *plugins)
g_hash_table_destroy((GHashTable *)plugins);
}
gboolean
plugins_supported(void)
{
return g_module_supported();
}
/*
* Editor modelines
*

View File

@ -12,7 +12,6 @@
#define __PLUGINS_H__
#include <wireshark.h>
#include <gmodule.h>
#ifdef __cplusplus
extern "C" {
@ -42,6 +41,8 @@ WS_DLL_PUBLIC int plugins_get_count(void);
WS_DLL_PUBLIC void plugins_cleanup(plugins_t *plugins);
WS_DLL_PUBLIC gboolean plugins_supported(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */