Skip to content

Commit

Permalink
build: Mark the installed libpng headers as system headers in CMake
Browse files Browse the repository at this point in the history
Modern compilers can disable the warnings that originate from system
headers. This change allows them to do so with the libpng headers.

Signed-off-by: Cosmin Truta <[email protected]>
  • Loading branch information
bebuch authored and ctruta committed Feb 21, 2024
1 parent 14a348d commit 7b88809
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
21 changes: 9 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,9 @@ if(PNG_SHARED)
set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
endif()
target_include_directories(png_shared
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(png_shared SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()

Expand All @@ -729,10 +728,9 @@ if(PNG_STATIC)
OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}"
DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
target_include_directories(png_static
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(png_static SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()

Expand All @@ -759,10 +757,9 @@ if(PNG_FRAMEWORK)
# Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS".
set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "")
target_include_directories(png_framework
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(png_framework SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()

Expand Down
1 change: 1 addition & 0 deletions scripts/cmake/AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Author List
* Alex Gaynor
* Andreas Franek
* B. Scott Michel
* Benjamin Buch
* Cameron Cawley
* Christian Ehrlicher
* Christopher Sean Morrison
Expand Down

0 comments on commit 7b88809

Please sign in to comment.