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)