CMake: Adjust wsutil includes and linking.

Mark wsutil's includes SYSTEM PRIVATE. This exposed a lot of targets
that were indirectly picking up include paths via the wsutil target, so
add direct includes where needed. The G.722 and G.726 codecs were
implicilty including tiffio.h; find it explicitly instead.

Mark some of wsutil's libraries PRIVATE, but leave commonly-used ones
PUBLIC.

Ping #17477.
This commit is contained in:
Gerald Combs 2021-07-13 11:02:52 -07:00 committed by Wireshark GitLab Utility
parent 9ae60d8483
commit ff60fcf92d
7 changed files with 46 additions and 26 deletions

View File

@ -78,7 +78,7 @@ if (ENABLE_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO/IPO is enabled")
else()
message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
endif()
else()
message(STATUS "LTO/IPO is not enabled")
@ -1248,6 +1248,8 @@ ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
ws_find_package(SBC ENABLE_SBC HAVE_SBC)
# SpanDSP codec
find_package(TIFF QUIET)
ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
@ -1402,10 +1404,11 @@ endif()
# Platform-specific additional libraries.
#
if(WIN32)
set(WIN_COMCTL32_LIBRARY comctl32.lib)
set(WIN_IPHLPAPI_LIBRARY iphlpapi.lib)
set(WIN_PSAPI_LIBRARY psapi.lib)
set(WIN_WS2_32_LIBRARY ws2_32.lib)
set(WIN_COMCTL32_LIBRARY comctl32.lib )
set(WIN_VERSION_LIBRARY version.lib)
set(WIN_WS2_32_LIBRARY ws2_32.lib)
endif()
if(APPLE)
@ -2780,6 +2783,7 @@ if(BUILD_capinfos)
add_executable(capinfos ${capinfos_FILES})
set_extra_executable_properties(capinfos "Executables")
target_link_libraries(capinfos ${capinfos_LIBS})
target_include_directories(capinfos SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
@ -2820,6 +2824,7 @@ if(BUILD_editcap)
add_executable(editcap ${editcap_FILES})
set_extra_executable_properties(editcap "Executables")
target_link_libraries(editcap ${editcap_LIBS})
target_include_directories(editcap SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

View File

@ -52,6 +52,7 @@ target_link_libraries(caputils
$<$<BOOL:${PCAP_FOUND}>:pcap::pcap>
PRIVATE
${NL_LIBRARIES}
${WIN_IPHLPAPI_LIBRARY}
)
target_include_directories(caputils SYSTEM
@ -59,10 +60,6 @@ target_include_directories(caputils SYSTEM
${NL_INCLUDE_DIRS}
)
if(WIN32)
target_link_libraries(caputils PRIVATE "iphlpapi.lib")
endif(WIN32)
set_target_properties(caputils PROPERTIES
LINK_FLAGS "${WS_LINK_FLAGS}"
FOLDER "Libs")

View File

@ -337,6 +337,7 @@ target_link_libraries(epan
${SMI_LIBRARIES}
${SNAPPY_LIBRARIES}
${WIN_PSAPI_LIBRARY}
${WIN_WS2_32_LIBRARY}
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}
)
@ -351,6 +352,7 @@ target_include_directories(epan
SYSTEM PRIVATE
${BROTLI_INCLUDE_DIRS}
${CARES_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${GTHREAD2_INCLUDE_DIRS}

View File

@ -38,7 +38,11 @@ target_include_directories(g722 PRIVATE ${CMAKE_SOURCE_DIR}/codecs)
target_link_libraries(g722 wsutil ${SPANDSP_LIBRARIES})
target_include_directories(g722 SYSTEM PRIVATE ${SPANDSP_INCLUDE_DIRS})
target_include_directories(g722
SYSTEM PRIVATE
${SPANDSP_INCLUDE_DIRS}
${TIFF_INCLUDE_DIR}
)
install_plugin(g722 codecs)

View File

@ -38,7 +38,11 @@ target_include_directories(g726 PRIVATE ${CMAKE_SOURCE_DIR}/codecs)
target_link_libraries(g726 wsutil ${SPANDSP_LIBRARIES})
target_include_directories(g726 SYSTEM PRIVATE ${SPANDSP_INCLUDE_DIRS})
target_include_directories(g726
SYSTEM PRIVATE
${SPANDSP_INCLUDE_DIRS}
${TIFF_INCLUDE_DIR}
)
install_plugin(g726 codecs)

View File

@ -80,10 +80,17 @@ set_source_files_properties(
add_library(ui STATIC ${UI_SRC})
target_link_libraries(ui wsutil caputils)
target_include_directories(ui SYSTEM
target_link_libraries(ui
PRIVATE
caputils
wsutil
${GCRYPT_LIBRARIES}
)
target_include_directories(ui
SYSTEM PRIVATE
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
)

View File

@ -264,23 +264,24 @@ 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
${CMAKE_DL_LIBS}
${APPLE_CORE_FOUNDATION_LIBRARY}
${GMODULE2_LIBRARIES}
${GLIB2_LIBRARIES}
${GCRYPT_LIBRARIES}
${WIN_WS2_32_LIBRARY}
${GNUTLS_LIBRARIES}
${M_LIBRARIES}
${GLIB2_LIBRARIES}
${GMODULE2_LIBRARIES}
PRIVATE
${APPLE_CORE_FOUNDATION_LIBRARY}
${CMAKE_DL_LIBS}
${GCRYPT_LIBRARIES}
${GNUTLS_LIBRARIES}
${M_LIBRARIES}
${WIN_IPHLPAPI_LIBRARY}
${WIN_WS2_32_LIBRARY}
)
if(WIN32)
target_link_libraries(wsutil PRIVATE "iphlpapi.lib" "ws2_32.lib")
endif(WIN32)
target_include_directories(wsutil SYSTEM
PUBLIC
target_include_directories(wsutil
SYSTEM PRIVATE
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
)