Fix CMake compilation on macOS.
Bug: None
Change-Id: Ifbb5f3a50f2e9fc9efcfcc80dd50a32c4e1941e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/147200
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index ab5878e..5b72f6d 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -178,19 +178,6 @@
PROPERTIES COMPILE_DEFINITIONS "TINT_ENABLE_BREAK_IN_DEBUGGER=1" )
endif()
-# If we're building on mac / ios and we have CoreGraphics, then we can use the
-# metal API to validate our shaders. This is roughly 4x faster than invoking
-# the metal shader compiler executable.
-if(APPLE)
- find_library(LIB_CORE_GRAPHICS CoreGraphics)
- if(LIB_CORE_GRAPHICS)
- target_sources(tint_val PRIVATE "lang/msl/validate/msl_metal.mm")
- target_compile_definitions(tint_val PUBLIC "-DTINT_ENABLE_MSL_VALIDATION_USING_METAL_API=1")
- target_compile_options(tint_val PRIVATE "-fmodules" "-fcxx-modules")
- target_link_options(tint_val PUBLIC "-framework" "CoreGraphics")
- endif()
-endif()
-
################################################################################
# Tests
################################################################################
@@ -578,6 +565,19 @@
################################################################################
include("BUILD.cmake")
+# If we're building on mac / ios and we have CoreGraphics, then we can use the
+# metal API to validate our shaders. This is roughly 4x faster than invoking
+# the metal shader compiler executable.
+if(APPLE AND TINT_BUILD_MSL_WRITER)
+ find_library(LIB_CORE_GRAPHICS CoreGraphics)
+ if(LIB_CORE_GRAPHICS)
+ target_sources("tint_lang_msl_validate" PRIVATE "lang/msl/validate/msl_metal.mm")
+ target_compile_definitions("tint_lang_msl_validate" PUBLIC "-DTINT_ENABLE_MSL_VALIDATION_USING_METAL_API=1")
+ target_compile_options("tint_lang_msl_validate" PRIVATE "-fmodules" "-fcxx-modules")
+ target_link_options("tint_lang_msl_validate" PUBLIC "-framework" "CoreGraphics")
+ endif()
+endif()
+
################################################################################
# Tint aliases
################################################################################