From 15ebcea6765610c1faced0a9c71842446325149b Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Fri, 20 Sep 2024 17:53:58 -0400 Subject: [PATCH] Print an error when SPIR-V is requested and ENABLE_SPIRV=0 is set This case fails slightly less silently now. Also make ENABLE_OPT depend on ENABLE_SPIRV, since when there's no SPIR-V optimization doesn't really make sense. --- CMakeLists.txt | 2 +- StandAlone/StandAlone.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc3fb4b9b4..1b97ecd549 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ CMAKE_DEPENDENT_OPTION(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE option(ENABLE_HLSL "Enables HLSL input support" ON) option(ENABLE_RTTI "Enables RTTI") option(ENABLE_EXCEPTIONS "Enables Exceptions") -option(ENABLE_OPT "Enables spirv-opt capability if present" ON) +CMAKE_DEPENDENT_OPTION(ENABLE_OPT "Enables spirv-opt capability if present" ON "ENABLE_SPIRV" OFF) if(MINGW OR (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")) # Workaround for CMake behavior on Mac OS with gcc, cmake generates -Xarch_* arguments diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 9c3beac923..3288b887c7 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -1507,9 +1507,9 @@ void CompileAndLinkShaderUnits(std::vector compUnits) std::vector outputFiles; -#ifdef ENABLE_SPIRV // Dump SPIR-V if (Options & EOptionSpv) { +#ifdef ENABLE_SPIRV CompileOrLinkFailed.fetch_or(CompileFailed); CompileOrLinkFailed.fetch_or(LinkFailed); if (static_cast(CompileOrLinkFailed.load())) @@ -1569,8 +1569,10 @@ void CompileAndLinkShaderUnits(std::vector compUnits) } } } - } +#else + Error("This configuration of glslang does not have SPIR-V support"); #endif + } CompileOrLinkFailed.fetch_or(CompileFailed); CompileOrLinkFailed.fetch_or(LinkFailed);