KhronosGroup / KhronosGroup/SPIRV-Tools

Wrong libdir in pkg-config .pc files if CMAKE_INSTALL_LIBDIR is absolute

Open
#3,905 1 comment 0 reactions 0 assignees View on GitHub
dev:building
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

#1284 dehardcoded the libdir and includedir in the pkg-config `.pc` files, but if you pass an absolute path to `CMAKE_INSTALL_LIBDIR` or `CMAKE_INSTALL_INCLUDEDIR` (which is supported by CMake and used among other things by RPM distro packager's cmake macros), you can end up with:

```
$ cat /usr/lib64/pkgconfig/SPIRV-Tools.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}//usr/lib64
includedir=${prefix}//usr/include

Name: SPIRV-Tools
Description: Tools for SPIR-V
Version: 2020.5.1
URL: https://github.com/KhronosGroup/SPIRV-Tools

Libs: -L${libdir} -lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link
Cflags: -I${includedir}
```

Similar to https://github.com/KhronosGroup/Vulkan-Loader/pull/214

I couldn't get this PR merged (though the bug is still valid in Vulkan-Loader), so I'm now trying with an issue instead of directly providing a potential fix.

That's a pretty common issue so I'm sure there's a proper way to do this with CMake... but there's so many ways to do things with CMake that I'm not so inclined to give it a go myself.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue by configuring with absolute CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_INCLUDEDIR, then inspect how the pkg-config .pc files are generated. Compare the resulting libdir and includedir values with the expected absolute paths, and verify that the generated SPIRV-Tools.pc no longer duplicates the install prefix.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.