From 3805888a57c07904b6bbdec639bfe5f078e26342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 3 Mar 2023 18:20:24 +0100 Subject: [PATCH] Look for external SPIR-V Tools build, if not building in-tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to build with optimizer enabled, if external SPIR-V tools libraries are available in the system. It is quite common in *nix world to package spirv-tools and glslang separately. Signed-off-by: Kacper Michajłow --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b48f6324f..c3a4f322a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,8 +264,15 @@ if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External) add_subdirectory(External) endif() +option(ALLOW_EXTERNAL_SPIRV_TOOLS "Allows to build against installed SPIRV-Tools-opt" OFF) if(NOT TARGET SPIRV-Tools-opt) - set(ENABLE_OPT OFF) + if(ALLOW_EXTERNAL_SPIRV_TOOLS) + # Look for external SPIR-V Tools build, if not building in-tree + find_package(SPIRV-Tools-opt) + endif() + if(NOT TARGET SPIRV-Tools-opt) + set(ENABLE_OPT OFF) + endif() endif() if(ENABLE_OPT)