From f1c0efa5f7ff39a0712b6e93ce628d3177aecd35 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Sun, 17 Mar 2024 00:10:46 +0100 Subject: [PATCH] cmake: allow system glslang library --- CMakeLists.txt | 23 +++++++++++++++-------- core/rend/vulkan/compiler.cpp | 3 ++- core/rend/vulkan/shaders.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64d8803b1..ddb66d711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ option(ENABLE_LOG "Enable full logging" OFF) option(ASAN "Enable address sanitizer" OFF) option(USE_GLES "Use GLES[3] API" OFF) option(USE_GLES2 "Use GLES2 API" OFF) +option(USE_HOST_GLSLANG "Use host glslang" OFF) option(USE_HOST_LIBZIP "Use host libzip" ON) option(USE_HOST_SDL "Use host SDL library" ${USE_HOST_SDL_DEFAULT}) option(USE_OPENMP "Use OpenMP if available" ON) @@ -383,14 +384,20 @@ add_subdirectory(core/deps/glm) target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm) if(USE_VULKAN) - option(BUILD_EXTERNAL "Build external dependencies in /External" OFF) - option(SKIP_GLSLANG_INSTALL "Skip installation" ON) - option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" OFF) - option(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" OFF) - option(ENABLE_HLSL "Enables HLSL input support" OFF) - option(ENABLE_PCH "Enables Precompiled header" OFF) - add_subdirectory(core/deps/glslang EXCLUDE_FROM_ALL) - target_link_libraries(${PROJECT_NAME} PRIVATE glslang-default-resource-limits SPIRV) + if(USE_HOST_GLSLANG) + find_package(glslang REQUIRED) + else() + option(BUILD_EXTERNAL "Build external dependencies in /External" OFF) + option(SKIP_GLSLANG_INSTALL "Skip installation" ON) + option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" OFF) + option(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" OFF) + option(ENABLE_HLSL "Enables HLSL input support" OFF) + option(ENABLE_PCH "Enables Precompiled header" OFF) + add_subdirectory(core/deps/glslang EXCLUDE_FROM_ALL) + add_library(glslang::glslang-default-resource-limits ALIAS glslang-default-resource-limits) + add_library(glslang::SPIRV ALIAS SPIRV) + endif() + target_link_libraries(${PROJECT_NAME} PRIVATE glslang::glslang-default-resource-limits glslang::SPIRV) endif() if(NOT LIBRETRO) diff --git a/core/rend/vulkan/compiler.cpp b/core/rend/vulkan/compiler.cpp index a1619f310..a58394e53 100644 --- a/core/rend/vulkan/compiler.cpp +++ b/core/rend/vulkan/compiler.cpp @@ -22,7 +22,8 @@ #include "vulkan_context.h" #include -#include +#include +#include int ShaderCompiler::initCount; diff --git a/core/rend/vulkan/shaders.h b/core/rend/vulkan/shaders.h index 10f5c91e2..426081381 100644 --- a/core/rend/vulkan/shaders.h +++ b/core/rend/vulkan/shaders.h @@ -20,7 +20,7 @@ */ #pragma once #include "vulkan.h" -#include "SPIRV/GlslangToSpv.h" +#include #include #include