CMake: Allow building with system Vulkan and ShaderC

Previously the cmake code would try to run the LIBDIR specific "findX.cmake" files for both vulkan and shaderc.

However these would pick up system headers and libraries when LIBDIR were not present. This would lead to compilation errors as the system library configurations were not taken into account or queried.

This changes it so that if LIBDIR is not present, the proper pkgconfig files will be used instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/114639
This commit is contained in:
Sebastian Parborg
2023-11-10 18:10:41 +01:00
committed by Sebastian Parborg
parent 8618547dfe
commit eaef914487
3 changed files with 16 additions and 14 deletions

View File

@@ -26,12 +26,6 @@ set(_shaderc_SEARCH_DIRS
${SHADERC_ROOT_DIR}
)
# FIXME: These finder modules typically don't use LIBDIR,
# this should be set by `./build_files/cmake/platform/` instead.
if(DEFINED LIBDIR)
set(_shaderc_SEARCH_DIRS ${_shaderc_SEARCH_DIRS} ${LIBDIR}/shaderc)
endif()
find_path(SHADERC_INCLUDE_DIR
NAMES
shaderc/shaderc.h

View File

@@ -26,12 +26,6 @@ set(_vulkan_SEARCH_DIRS
${VULKAN_ROOT_DIR}
)
# FIXME: These finder modules typically don't use LIBDIR,
# this should be set by `./build_files/cmake/platform/` instead.
if(DEFINED LIBDIR)
set(_vulkan_SEARCH_DIRS ${_vulkan_SEARCH_DIRS} ${LIBDIR}/vulkan)
endif()
find_path(VULKAN_INCLUDE_DIR
NAMES
vulkan/vulkan.h

View File

@@ -116,8 +116,22 @@ find_package_wrapper(Epoxy REQUIRED)
find_package(TIFF)
if(WITH_VULKAN_BACKEND)
find_package_wrapper(Vulkan REQUIRED)
find_package_wrapper(ShaderC REQUIRED)
if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/vulkan") AND (EXISTS "${LIBDIR}/shaderc"))
if(NOT DEFINED VULKAN_ROOT_DIR)
set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan)
endif()
if(NOT DEFINED SHADERC_ROOT_DIR)
set(SHADERC_ROOT_DIR ${LIBDIR}/shaderc)
endif()
find_package_wrapper(Vulkan REQUIRED)
find_package_wrapper(ShaderC REQUIRED)
else()
# Use system libs
find_package(PkgConfig)
pkg_check_modules(VULKAN REQUIRED vulkan)
pkg_check_modules(SHADERC REQUIRED shaderc)
endif()
endif()
add_bundled_libraries(vulkan/lib)