Skip to content

[CMake] Make LLVMSPIRVLib include directories PUBLIC for in-tree builds#3590

Open
wenju-he wants to merge 1 commit intoKhronosGroup:mainfrom
wenju-he:public-include-dirs
Open

[CMake] Make LLVMSPIRVLib include directories PUBLIC for in-tree builds#3590
wenju-he wants to merge 1 commit intoKhronosGroup:mainfrom
wenju-he:public-include-dirs

Conversation

@wenju-he
Copy link
Copy Markdown
Contributor

LLVMSPIRVLib provides a public API through headers like LLVMSPIRVLib.h, LLVMSPIRVOpts.h, and LLVMSPIRVExtensions.inc. Any target that links to LLVMSPIRVLib and calls its functions must include these headers.

Currently, the include directory is marked PRIVATE, which prevents CMake from automatically propagating include paths to downstream targets. This forces consumers to manually add the include directories.

This commit makes the include directory PUBLIC with BUILD_INTERFACE, following standard CMake practice for libraries with public APIs. This allows targets linking to LLVMSPIRVLib to automatically get the correct include paths, which is necessary for in-tree consumers like opencl-clang.

Changes:

  • lib/SPIRV/CMakeLists.txt: Move ${LLVM_SPIRV_INCLUDE_DIRS} from PRIVATE to PUBLIC with $<BUILD_INTERFACE:...> generator expression
  • tools/llvm-spirv/CMakeLists.txt: Remove redundant explicit include since it's now automatically propagated via CMake target propagation

LLVMSPIRVLib provides a public API through headers like LLVMSPIRVLib.h,
LLVMSPIRVOpts.h, and LLVMSPIRVExtensions.inc. Any target that links to
LLVMSPIRVLib and calls its functions must include these headers.

Currently, the include directory is marked PRIVATE, which prevents CMake
from automatically propagating include paths to downstream targets. This
forces consumers to manually add the include directories.

This commit makes the include directory PUBLIC with BUILD_INTERFACE,
following standard CMake practice for libraries with public APIs. This
allows targets linking to LLVMSPIRVLib to automatically get the correct
include paths, which is necessary for in-tree consumers like opencl-clang.

Changes:
- lib/SPIRV/CMakeLists.txt: Move ${LLVM_SPIRV_INCLUDE_DIRS} from PRIVATE
  to PUBLIC with $<BUILD_INTERFACE:...> generator expression
- tools/llvm-spirv/CMakeLists.txt: Remove redundant explicit include since
  it's now automatically propagated via CMake target propagation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants