Support overriding the header path in the .pc at configure-time
rcombs opened this issue · 4 comments
Currently, the include dir in the .pc is always set to ${prefix}/@CMAKE_INSTALL_INCLUDEDIR_PC@
(i.e. ${prefix}/include
in most cases):
Vulkan-Loader/loader/vulkan.pc.in
Line 4 in 54d04df
This works fine in most package managers, but falls apart in brew, where the headers and loader are installed into different prefixes. Consuming software expects vulkan.pc
to provide an -I
pointing at the headers, so we need to be able to point into the headers' prefix. Would it be possible to offer a -D
at configure-time specifying a full path to put in the .pc for the headers instead of something prefix-based?
Why not just specify CMAKE_INSTALL_FULL_INCLUDEDIR
?
# BUG: The following code will NOT work well with `cmake --install ... --prefix <dir>`
# due to this code relying on CMAKE_INSTALL_PREFIX being defined at configure time.
#
# NOTE: vulkan.pc essentially cover both Vulkan-Loader and Vulkan-Headers for legacy reasons.
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
set(CMAKE_INSTALL_LIBDIR_PC ${CMAKE_INSTALL_FULL_LIBDIR})
set(CMAKE_INSTALL_INCLUDEDIR_PC ${CMAKE_INSTALL_FULL_INCLUDEDIR})
else()
file(RELATIVE_PATH CMAKE_INSTALL_LIBDIR_PC ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR})
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR_PC ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_INCLUDEDIR})
endif()
There is an open issue on the gitlab for adding native support:
https://gitlab.kitware.com/cmake/cmake/-/issues/22621
If that gets in that would be great. But it looks like the more likely answer is going to be a vulkan-loader.cps
file in the future:
https://www.youtube.com/watch?v=IwuBZpLUq8Q
To be clear CMAKE_INSTALL_FULL_INCLUDEDIR
is valid CMake usage:
https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
CMAKE_INSTALL_FULL_\<dir\>
The absolute path generated from the corresponding CMAKE_INSTALL_<dir> value. If the value is not already an absolute path, an absolute path is constructed typically by prepending the value of the CMAKE_INSTALL_PREFIX variable. However, there are some special cases as documented below.
Closing since you can override the header path in the .pc at configure time via CMAKE_INSTALL_FULL_INCLUDEDIR
.
Feel free to re-open if this doesn't work for you.