CMake: Make sure system headers are treated as such.

Use target_include_directories instead of include_directories in a few
places as recommended at

https://cmake.org/cmake/help/latest/command/include_directories.html

Doing so lets us mark a bunch of dependency includes SYSTEM PRIVATE, in
particular LIBXML2_INCLUDE_DIRS. On macOS this keeps us from triggering
the nullability warnings described at

https://www.wireshark.org/lists/wireshark-dev/202004/msg00056.html

(This might also keep the Visual Studio code analyzer from complaining
about various Qt headers, but I haven't tested this.)
This commit is contained in:
Gerald Combs 2021-02-14 14:08:15 -08:00 committed by Wireshark GitLab Utility
parent 3c404abf2c
commit 270c8ed746
5 changed files with 43 additions and 25 deletions

View File

@ -13,24 +13,6 @@ if (HAVE_HFI_SECTION_INIT)
)
endif()
include_directories(
${BROTLI_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${CARES_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${GTHREAD2_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${KERBEROS_INCLUDE_DIRS}
${LUA_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
${SMI_INCLUDE_DIRS}
${SNAPPY_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${ZSTD_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
)
add_definitions(
${LIBXML2_DEFINITIONS}
${KERBEROS_DEFINITIONS}
@ -41,6 +23,7 @@ add_subdirectory(dfilter)
add_subdirectory(dissectors)
add_subdirectory(ftypes)
add_subdirectory(wmem)
if(LUA_FOUND)
add_subdirectory(wslua)
endif()
@ -365,6 +348,20 @@ target_include_directories(epan
target_include_directories(epan SYSTEM PUBLIC ${GLIB2_INCLUDE_DIRS})
target_include_directories(epan
SYSTEM PRIVATE
${BROTLI_INCLUDE_DIRS}
${CARES_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${GTHREAD2_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${LUA_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
${SMI_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
add_dependencies(epan lemon)
install(TARGETS epan

View File

@ -60,6 +60,11 @@ add_library(crypt OBJECT
${CRYPT_FILES}
)
target_include_directories(crypt
SYSTEM PRIVATE
${GCRYPT_INCLUDE_DIRS}
)
set_target_properties(crypt PROPERTIES
FOLDER "Libs/epan/crypt"
COMPILE_DEFINITIONS "WS_BUILD_DLL"

View File

@ -2052,6 +2052,20 @@ add_library(dissectors OBJECT
${DISSECTOR_SUPPORT_SRC}
)
target_include_directories(dissectors
SYSTEM PRIVATE
${GCRYPT_INCLUDE_DIRS}
${GNUTLS_INCLUDE_DIRS}
${KERBEROS_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
${SMI_INCLUDE_DIRS}
${SNAPPY_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${ZSTD_INCLUDE_DIRS}
)
set_target_properties(dissectors PROPERTIES
FOLDER "Libs/epan/dissectors"
COMPILE_DEFINITIONS "WS_BUILD_DLL"

View File

@ -146,6 +146,11 @@ add_library(wslua OBJECT
${WSLUA_FILES}
)
target_include_directories(wslua
SYSTEM PRIVATE
${LUA_INCLUDE_DIRS}
)
set_target_properties(wslua PROPERTIES
FOLDER "Libs/epan/wslua"
COMPILE_DEFINITIONS "WS_BUILD_DLL"

View File

@ -9,10 +9,6 @@
ADD_CUSTOM_CMAKE_INCLUDE()
include_directories(
${GCRYPT_INCLUDE_DIRS}
)
set(WIRESHARK_WIDGET_HEADERS
widgets/additional_toolbar.h
widgets/apply_line_edit.h
@ -713,15 +709,16 @@ add_library(qtui OBJECT
wireshark-tap-register.c
)
target_include_directories(qtui SYSTEM
PUBLIC
target_include_directories(qtui
SYSTEM PUBLIC
${QT_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
${SPEEXDSP_INCLUDE_DIRS}
PRIVATE
SYSTEM PRIVATE
# Can't use imported target, linking object libraries for usage requirements
# requires CMake 3.12
${PCAP_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
)
target_compile_definitions(qtui