Add glslang dependency to VulkanBenchmarks

Note glslang's build targets may already have been added by the PowerVR
SDK. In that case, we use their copy. This is not optimal since it
potentially makes our test results depend on whether or not building the
PowerVR samples has been enabled, but it prevents duplicate targets.

Bug: b/158655757
Change-Id: Ic4e9292da9b1bb498164929cc7f93e73bf1fd6e6
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45628
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3bda399..899f676 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,6 +203,7 @@
 
 if(SWIFTSHADER_BUILD_BENCHMARKS)
     InitSubmodule(benchmark::benchmark ${THIRD_PARTY_DIR}/benchmark)
+    InitSubmodule(glslang ${THIRD_PARTY_DIR}/glslang)
 endif()
 
 if(REACTOR_EMIT_DEBUG_INFO)
@@ -864,6 +865,10 @@
         add_subdirectory(${THIRD_PARTY_DIR}/benchmark)
     endif()
 
+    if (NOT TARGET glslang)
+        add_subdirectory(${THIRD_PARTY_DIR}/glslang)
+    endif()
+
     add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target
     add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target
     add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target
diff --git a/tests/VulkanBenchmarks/CMakeLists.txt b/tests/VulkanBenchmarks/CMakeLists.txt
index 783b1ea..851ac91 100644
--- a/tests/VulkanBenchmarks/CMakeLists.txt
+++ b/tests/VulkanBenchmarks/CMakeLists.txt
@@ -35,6 +35,18 @@
     message(FATAL_ERROR "Missing required target: benchmark::benchmark")
 endif()
 
+if (NOT TARGET glslang)
+    message(FATAL_ERROR "Missing required target: glslang")
+endif()
+
+if (NOT TARGET glslang-default-resource-limits)
+    message(FATAL_ERROR "Missing required target: glslang-default-resource-limits")
+endif()
+
+if (NOT TARGET SPIRV)
+    message(FATAL_ERROR "Missing required target: SPIRV")
+endif()
+
 add_dependencies(VulkanBenchmarks
     vk_swiftshader
 )
@@ -46,7 +58,7 @@
 
 target_include_directories(VulkanBenchmarks
     PRIVATE
-        "${SWIFTSHADER_DIR}/include"
+        "${SWIFTSHADER_DIR}/include/"
 )
 
 target_compile_options(VulkanBenchmarks
@@ -62,5 +74,8 @@
 target_link_libraries(VulkanBenchmarks
     PRIVATE
         benchmark::benchmark
+        glslang
+        glslang-default-resource-limits
+        SPIRV
         ${ROOT_PROJECT_LINK_LIBRARIES}
 )