From ff60fcf92dfc33f001e990268d060af4e97bfb7a Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 13 Jul 2021 11:02:52 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 11 ++++++++--- capture/CMakeLists.txt | 5 +---- epan/CMakeLists.txt | 2 ++ plugins/codecs/G722/CMakeLists.txt | 6 +++++- plugins/codecs/G726/CMakeLists.txt | 6 +++++- ui/CMakeLists.txt | 13 ++++++++++--- wsutil/CMakeLists.txt | 29 +++++++++++++++-------------- 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 861087d044..2d891e75ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/capture/CMakeLists.txt b/capture/CMakeLists.txt index d9378f11bc..f25ddb31e6 100644 --- a/capture/CMakeLists.txt +++ b/capture/CMakeLists.txt @@ -52,6 +52,7 @@ target_link_libraries(caputils $<$: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") diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index ba9d7d2784..027d0384b1 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -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} diff --git a/plugins/codecs/G722/CMakeLists.txt b/plugins/codecs/G722/CMakeLists.txt index 5807d4915d..7aad62fe9f 100644 --- a/plugins/codecs/G722/CMakeLists.txt +++ b/plugins/codecs/G722/CMakeLists.txt @@ -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) diff --git a/plugins/codecs/G726/CMakeLists.txt b/plugins/codecs/G726/CMakeLists.txt index 8eac543891..65a7f3d576 100644 --- a/plugins/codecs/G726/CMakeLists.txt +++ b/plugins/codecs/G726/CMakeLists.txt @@ -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) diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 4a959bc013..81c068e908 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -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} ) diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index cb1cea38e5..9e9b62c89c 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -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} )