From c19329c832eedde0e2379de53578dda131a70946 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 23 Sep 2021 19:24:43 +0000 Subject: [PATCH] CMake: Only require SPIRV-Cross when enabling OpenGL backend Change-Id: Ie6be1301c3f2f9877a9dfb04ab5025559b90d926 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64741 Reviewed-by: Austin Eng Reviewed-by: Stephen White Reviewed-by: Corentin Wallez Commit-Queue: Ben Clayton --- CMakeLists.txt | 6 ++++++ src/dawn_native/CMakeLists.txt | 11 +++++++---- third_party/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fefeb44f2..1560493f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,12 @@ if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES}) set(DAWN_ENABLE_OPENGL ON) endif() +# OpenGL backend requires SPIRV-Cross +set(DAWN_REQUIRES_SPIRV_CROSS OFF) +if (DAWN_ENABLE_OPENGL) + set(DAWN_REQUIRES_SPIRV_CROSS ON) +endif() + ################################################################################ # Dawn's public and internal "configs" ################################################################################ diff --git a/src/dawn_native/CMakeLists.txt b/src/dawn_native/CMakeLists.txt index 8e2b2ce9e5..e651f943c0 100644 --- a/src/dawn_native/CMakeLists.txt +++ b/src/dawn_native/CMakeLists.txt @@ -185,13 +185,16 @@ target_link_libraries(dawn_native dawn_platform dawn_internal_config libtint - spirv-cross-core - spirv-cross-glsl - spirv-cross-hlsl - spirv-cross-msl SPIRV-Tools-opt ) +if (DAWN_REQUIRES_SPIRV_CROSS) + target_link_libraries(dawn_native PRIVATE spirv-cross-core) + if (DAWN_ENABLE_OPENGL) + target_link_libraries(dawn_native PRIVATE spirv-cross-glsl) + endif() +endif() + if (DAWN_USE_X11) find_package(X11 REQUIRED) target_link_libraries(dawn_native PRIVATE ${X11_LIBRARIES}) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 94e5d8360e..a5e0a24ce3 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if (NOT TARGET spirv-cross) +if (DAWN_REQUIRES_SPIRV_CROSS AND NOT TARGET spirv-cross) set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS ON CACHE BOOL "" FORCE) set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE BOOL "" FORCE) set(SPIRV_CROSS_SKIP_INSTALL ON CACHE BOOL "" FORCE)