Add CMake support for buildint Tint in third_party (#1090)
This is off by default, and not announced in the README.
Requires some Tint changes in order to build:
https://dawn-review.googlesource.com/c/tint/+/24020
diff --git a/.gitignore b/.gitignore
index c775e31..756c305 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,13 +5,14 @@
compile_commands.json
.ycm_extra_conf.py
cscope.*
-third_party/effcee/
-third_party/glslang/
-third_party/googletest/
-third_party/re2/
-third_party/spirv-tools/
-third_party/spirv-headers/
-third_party/spirv-cross/
+third_party/effcee
+third_party/glslang
+third_party/googletest
+third_party/re2
+third_party/spirv-tools
+third_party/spirv-headers
+third_party/spirv-cross
+third_party/tint
android_test/libs
android_test/include
.DS_Store
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93a808a..ebaf655 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@
message(STATUS "Shaderc: build type is \"${CMAKE_BUILD_TYPE}\".")
option(SHADERC_ENABLE_SPVC "Enable libshaderc_spvc" OFF)
+option(SHADERC_ENABLE_WGSL_OUTPUT "Enable WGSL output" OFF)
option(SHADERC_SKIP_INSTALL "Skip installation" ${SHADERC_SKIP_INSTALL})
if(NOT ${SHADERC_SKIP_INSTALL})
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 900ee23..d4e540a 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -17,6 +17,8 @@
"Location of effcee source")
set(SHADERC_RE2_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/re2" CACHE STRING
"Location of re2 source")
+set(SHADERC_TINT_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/tint" CACHE STRING
+ "Location of tint source")
set( SKIP_GLSLANG_INSTALL ${SHADERC_SKIP_INSTALL} )
set( SKIP_SPIRV_TOOLS_INSTALL ${SHADERC_SKIP_INSTALL} )
@@ -99,3 +101,21 @@
endif()
endif()
endif (SHADERC_ENABLE_SPVC)
+
+if (SHADERC_ENABLE_WGSL_OUTPUT)
+ # Use Google Tint for WGSL output.
+ if (NOT TARGET libtint)
+ if (IS_DIRECTORY ${SHADERC_TINT_DIR})
+ if (NOT IS_DIRECTORY ${SHADERC_TINT_DIR}/out/docs)
+ # The Tint Doxygen configuration assumes it can write to the out/docs
+ # source directory.
+ message(STATUS "Tint source directory out/docs does not exist. Disabling doc generation")
+ set(TINT_BUILD_DOCS OFF)
+ endif()
+ add_subdirectory(${SHADERC_TINT_DIR} tint)
+ endif()
+ endif()
+ if (NOT TARGET libtint)
+ message(FATAL_ERROR "Tint was not found - required for WGSL output")
+ endif()
+endif (SHADERC_ENABLE_WGSL_OUTPUT)