KhronosGroup / KhronosGroup/glslang

Build interface include path for `glslang/SPIRV/*` inconsistent with install layout

Open
#4,185 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

**glslang version:** 16.2.0

### Description

When glslang is used as a cmake subproject (e.g. via `add_subdirectory` or meson's cmake subproject integration), `#include "glslang/SPIRV/GlslangToSpv.h"` fails to compile because the header cannot be found. The `SPIRV` cmake target declares:

```cmake
target_include_directories(SPIRV PUBLIC
$
$)
```
`CMAKE_CURRENT_SOURCE_DIR` in `SPIRV/CMakeLists.txt` is `/SPIRV/`. This means the BUILD interface adds `/` to include paths.
With that, `glslang/SPIRV/GlslangToSpv.h` resolves to `/glslang/SPIRV/GlslangToSpv.h`, which does not exist in the source tree. The actual file is at `/SPIRV/GlslangToSpv.h`.

The INSTALL interface correctly places headers at `/include/glslang/SPIRV/GlslangToSpv.h`, so `glslang/SPIRV/GlslangToSpv.h` works for installed glslang.

The two interfaces are inconsistent.

## Expected behaviour

`#include "glslang/SPIRV/GlslangToSpv.h"` should compile when glslang is used as a cmake subproject, consistent with the installed layout.

## Suggested fix

Either add a glslang/SPIRV/ directory (or symlink) to the source tree mirroring the install layout, or adjust the BUILD interface include path so that `glslang/SPIRV/GlslangToSpv.h` resolves correctly from the source tree.

I patched the `CMakeLists.txt` like to fix the issue on by Ubuntu and Windows CIs:

```cmake
...
if(ENABLE_SPIRV)
add_subdirectory(SPIRV)
# @LDAP: create glslang/SPIRV/ symlink in the generated include dir so that
# #include "glslang/SPIRV/GlslangToSpv.h" works consistently with the install layout.
file(MAKE_DIRECTORY "${GLSLANG_GENERATED_INCLUDEDIR}/glslang")
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/SPIRV" "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/SPIRV" SYMBOLIC COPY_ON_ERROR)
endif()
...
```

Contributor guide

Open the contributing guide

Research direction

Start with SPIRV/CMakeLists.txt and the SPIRV target's BUILD and INSTALL include directories, then configure a minimal CMake subproject that includes glslang/SPIRV/GlslangToSpv.h. Done means the include compiles from the build tree and remains consistent with the installed header layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.