summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Ramos <juan@lunarg.com>2023-10-04 14:34:47 -0600
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>2023-10-04 15:05:23 -0600
commitd9faa0f8442d13fff3041f92c299a6361a4ebf41 (patch)
tree8d01c723e13a44557865eedc892e4cfedb3d8276
parenta37ec45d8a2f1ba722a845c176aca12b8a28fe74 (diff)
downloadVulkan-Loader-d9faa0f8442d13fff3041f92c299a6361a4ebf41.tar.gz
Vulkan-Loader-d9faa0f8442d13fff3041f92c299a6361a4ebf41.tar.bz2
Vulkan-Loader-d9faa0f8442d13fff3041f92c299a6361a4ebf41.zip
cmake: Cleanup package config code
-rw-r--r--.github/workflows/build.yml3
-rw-r--r--loader/CMakeLists.txt50
-rw-r--r--loader/vulkan.pc.in12
3 files changed, 32 insertions, 33 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index de296897..003ed3e3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -73,6 +73,9 @@ jobs:
- name: Install the loader
run: cmake --install build --prefix build/install
+ - name: cat vulkan.pc
+ run: cat ./build/install/lib/pkgconfig/vulkan.pc
+
- name: Validate pkg-config
run: pkg-config --validate ./build/install/lib/pkgconfig/vulkan.pc
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 06563704..132bc90e 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -390,9 +390,24 @@ if (TARGET asm_offset)
set_target_properties(asm_offset PROPERTIES ${LOADER_STANDARD_C_PROPERTIES})
endif()
-# Generate pkg-config file.
-find_package(PkgConfig QUIET)
-if(PKG_CONFIG_FOUND)
+target_link_libraries(vulkan PRIVATE Vulkan::Headers)
+add_library(Vulkan::Loader ALIAS vulkan)
+
+if (APPLE AND BUILD_STATIC_LOADER)
+ # When exporting a static library all linked libraries - private or not - need to be exported.
+ return()
+endif()
+
+install(TARGETS vulkan EXPORT VulkanLoaderConfig)
+# Generate CMake Configuration File (IE: VulkanLoaderConfig.cmake)
+set_target_properties(vulkan PROPERTIES EXPORT_NAME "Loader")
+install(EXPORT VulkanLoaderConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanLoader NAMESPACE Vulkan::)
+
+# Generate PkgConfig File (IE: vulkan.pc)
+# NOTE: Hopefully in the future CMake can generate .pc files natively.
+# https://gitlab.kitware.com/cmake/cmake/-/issues/22621
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
set(PRIVATE_LIBS "")
if (APPLE AND BUILD_STATIC_LOADER)
# Libs.private should only be present when building a static loader
@@ -411,30 +426,17 @@ if(PKG_CONFIG_FOUND)
endif()
endif()
- set(CMAKE_INSTALL_FULL_LIBDIR_PC ${CMAKE_INSTALL_FULL_LIBDIR})
-
- # NOTE: Hopefully in the future CMake can generate .pc files natively so we can simplify our code.
- # https://gitlab.kitware.com/cmake/cmake/-/issues/22621
+ # BUG: The following code will NOT work will with `cmake --install ... --prefix <dir>`
+ #
+ # ISSUE: vulkan.pc also adds an include path that incidentally points to the vulkan headers.
+ # This shouldn't have been added but removing it may break backcompat at this point.
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
- set(CMAKE_INSTALL_REL_LIBDIR_PC ${CMAKE_INSTALL_FULL_LIBDIR_PC})
- set(CMAKE_INSTALL_REL_INCLUDEDIR_PC ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+ set(CMAKE_INSTALL_LIBDIR_PC ${CMAKE_INSTALL_FULL_LIBDIR})
+ set(CMAKE_INSTALL_INCLUDEDIR_PC ${CMAKE_INSTALL_FULL_INCLUDEDIR})
else()
- file(RELATIVE_PATH CMAKE_INSTALL_REL_LIBDIR_PC ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR_PC})
- file(RELATIVE_PATH CMAKE_INSTALL_REL_INCLUDEDIR_PC ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+ 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()
- set(VULKAN_LOADER_PKG_CONFIG_NAME "Vulkan-Loader")
configure_file("vulkan.pc.in" "vulkan.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vulkan.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
-
-target_link_libraries(vulkan PRIVATE Vulkan::Headers)
-add_library(Vulkan::Loader ALIAS vulkan)
-
-if (APPLE AND BUILD_STATIC_LOADER)
- # When exporting a static library all linked libraries - private or not - need to be exported.
- return()
-endif()
-
-install(TARGETS vulkan EXPORT VulkanLoaderConfig)
-set_target_properties(vulkan PROPERTIES EXPORT_NAME "Loader")
-install(EXPORT VulkanLoaderConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanLoader NAMESPACE Vulkan::)
diff --git a/loader/vulkan.pc.in b/loader/vulkan.pc.in
index 80974e8a..bcd800c9 100644
--- a/loader/vulkan.pc.in
+++ b/loader/vulkan.pc.in
@@ -1,11 +1,5 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/@CMAKE_INSTALL_REL_LIBDIR_PC@
-includedir=${prefix}/@CMAKE_INSTALL_REL_INCLUDEDIR_PC@
-
-Name: @VULKAN_LOADER_PKG_CONFIG_NAME@
+Name: Vulkan-Loader
Description: Vulkan Loader
Version: @VULKAN_LOADER_VERSION@
-Libs: -L${libdir} -lvulkan@VULKAN_LIB_SUFFIX@
-@PRIVATE_LIBS@
-Cflags: -I${includedir}
+Libs: -L@CMAKE_INSTALL_LIBDIR_PC@ -lvulkan@VULKAN_LIB_SUFFIX@ @PRIVATE_LIBS@
+Cflags: -I@CMAKE_INSTALL_INCLUDEDIR_PC@