From 2d83fff5815d319091d9433b9e19580c3365ec66 Mon Sep 17 00:00:00 2001 From: Castor215 <132155746+Castor215@users.noreply.github.com> Date: Tue, 17 Oct 2023 19:02:50 +0100 Subject: [PATCH] externals: allow user to use system glslang (#7075) --- CMakeLists.txt | 1 + externals/CMakeLists.txt | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65b16f44e..393df00d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ option(USE_SYSTEM_XBYAK "Use the system xbyak (instead of the bundled one)" OFF) option(USE_SYSTEM_INIH "Use the system inih (instead of the bundled one)" OFF) option(USE_SYSTEM_FDK_AAC_HEADERS "Use the system fdk-aac headers (instead of the bundled one)" OFF) option(USE_SYSTEM_FFMPEG_HEADERS "Use the system FFmpeg headers (instead of the bundled one)" OFF) +option(USE_SYSTEM_GLSLANG "Use the system glslang and SPIR-V libraries (instead of the bundled ones)" OFF) if (CITRA_USE_PRECOMPILED_HEADERS) message(STATUS "Using Precompiled Headers.") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index f9b24f1b3..527929b15 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -117,13 +117,24 @@ endif() add_subdirectory(glad) # glslang -set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "") -set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "") -set(ENABLE_SPVREMAPPER OFF CACHE BOOL "") -set(ENABLE_CTEST OFF CACHE BOOL "") -set(ENABLE_HLSL OFF CACHE BOOL "") -set(BUILD_EXTERNAL OFF CACHE BOOL "") -add_subdirectory(glslang) +if(USE_SYSTEM_GLSLANG) + find_package(glslang REQUIRED) + add_library(glslang INTERFACE) + add_library(SPIRV INTERFACE) + target_link_libraries(glslang INTERFACE glslang::glslang) + target_link_libraries(SPIRV INTERFACE glslang::SPIRV) + # System include path is different from submodule include path + get_target_property(GLSLANG_PREFIX glslang::SPIRV INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(SPIRV SYSTEM INTERFACE "${GLSLANG_PREFIX}/glslang") +else() + set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "") + set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "") + set(ENABLE_SPVREMAPPER OFF CACHE BOOL "") + set(ENABLE_CTEST OFF CACHE BOOL "") + set(ENABLE_HLSL OFF CACHE BOOL "") + set(BUILD_EXTERNAL OFF CACHE BOOL "") + add_subdirectory(glslang) +endif() # inih if(USE_SYSTEM_INIH)