Skip to content

cmake: prefer selected libheif headers and avoid system include demotion - #478

Open
DichenZhang1 wants to merge 1 commit into
mainfrom
fix/cmake-prefer-libheif-headers
Open

DichenZhang1 wants to merge 1 commit into
mainfrom
fix/cmake-prefer-libheif-headers

Conversation

@DichenZhang1

Copy link
Copy Markdown
Collaborator
  • Prepend libheif include directories (from target interface or LIBHEIF_INCLUDE_DIRS) to PRIVATE_INCLUDE_DIR so they are searched before other dependency or system include paths.
  • For CMake 3.25+, set SYSTEM FALSE on target libheif::heif to prevent it from being classified as a system target, ensuring its headers take precedence over conflicting host headers without stripping system include classification from other dependencies (e.g. GTest, Threads).
  • Guard get_target_property with if(TARGET libheif::heif) to prevent CMake configuration errors when using custom or legacy Find modules.

Ref: PR #468

- Prepend libheif include directories (from target interface or LIBHEIF_INCLUDE_DIRS) to PRIVATE_INCLUDE_DIR so they are searched before other dependency or system include paths.
- For CMake 3.25+, set SYSTEM FALSE on target libheif::heif to prevent it from being classified as a system target, ensuring its headers take precedence over conflicting host headers without stripping system include classification from other dependencies (e.g. GTest, Threads).
- Resolve ALIASED_TARGET before calling set_target_properties to prevent CMake configuration fatal errors when libheif::heif is an ALIAS target (e.g. from Findlibheif.cmake aliasing 'heif' or 'PkgConfig::PC_LIBHEIF').
- Fall back to LIBHEIF_INCLUDE_DIRS if the target does not define INTERFACE_INCLUDE_DIRECTORIES.
- Guard get_target_property with if(TARGET libheif::heif) to prevent CMake configuration errors when using custom or legacy Find modules.

Ref: PR #468, PR #478
@DichenZhang1
DichenZhang1 force-pushed the fix/cmake-prefer-libheif-headers branch from 24a610e to cf5cfe3 Compare September 18, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant