Skip to content

Commit

Permalink
CMake: Properly declare target include directories for generated incl…
Browse files Browse the repository at this point in the history
…udes.

Previously the non targeted `include_directories()` was used, which had
issue when using the `png_static` target in a submodule.
  • Loading branch information
Green-Sky committed Apr 17, 2024
1 parent f1848a3 commit f45bc97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ else()
message(STATUS "Could not find an AWK-compatible program")
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})

if(NOT AWK OR ANDROID OR IOS)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
Expand Down Expand Up @@ -714,6 +712,8 @@ if(PNG_SHARED)
endif()
target_include_directories(png_shared
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(png_shared
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_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})
Expand All @@ -728,6 +728,8 @@ if(PNG_STATIC)
DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
target_include_directories(png_static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(png_static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_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})
Expand Down

0 comments on commit f45bc97

Please sign in to comment.