11cmake_minimum_required (VERSION  3.19)
22cmake_policy (SET CMP0114 NEW)
33
4- find_package (Vulkan COMPONENTS glslc REQUIRED )
4+ find_package (Vulkan COMPONENTS glslc)
55
66function (detect_host_compiler)
77    if  (CMAKE_HOST_SYSTEM_NAME  STREQUAL  "Windows" )
@@ -18,6 +18,15 @@ endfunction()
1818if  (Vulkan_FOUND)
1919    message (STATUS  "Vulkan found" )
2020
21+     set  (GLSLC_PROGRAM ${Vulkan_GLSLC_EXECUTABLE} )
22+     if  (NOT  GLSLC_PROGRAM)
23+         # When cross-compiling the glslc program needs to be runnable on 
24+         # build-system architecture but the Vulkan SDK will be for the 
25+         # target architecture. 
26+ 
27+         find_program (GLSLC_PROGRAM glslc REQUIRED NO_CMAKE_FIND_ROOT_PATH )
28+     endif ()
29+ 
2130    ggml_add_backend_library(ggml-vulkan
2231                             ggml-vulkan.cpp
2332                             ../../include /ggml-vulkan.h
@@ -26,7 +35,7 @@ if (Vulkan_FOUND)
2635    # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported. 
2736    # If it's not, there will be an error to stderr. 
2837    # If it's supported, set a define to indicate that we should compile those shaders 
29-     execute_process (COMMAND  ${Vulkan_GLSLC_EXECUTABLE }  -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat_support.comp" 
38+     execute_process (COMMAND  ${GLSLC_PROGRAM }  -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat_support.comp" 
3039                    OUTPUT_VARIABLE  glslc_output
3140                    ERROR_VARIABLE glslc_error)
3241
@@ -40,7 +49,7 @@ if (Vulkan_FOUND)
4049    # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported. 
4150    # If it's not, there will be an error to stderr. 
4251    # If it's supported, set a define to indicate that we should compile those shaders 
43-     execute_process (COMMAND  ${Vulkan_GLSLC_EXECUTABLE }  -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat2_support.comp" 
52+     execute_process (COMMAND  ${GLSLC_PROGRAM }  -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat2_support.comp" 
4453                    OUTPUT_VARIABLE  glslc_output
4554                    ERROR_VARIABLE glslc_error)
4655
@@ -144,7 +153,7 @@ if (Vulkan_FOUND)
144153                ${_ggml_vk_source} 
145154
146155        COMMAND  ${_ggml_vk_genshaders_cmd} 
147-             --glslc      ${Vulkan_GLSLC_EXECUTABLE } 
156+             --glslc      ${GLSLC_PROGRAM } 
148157            --input -dir  ${_ggml_vk_input_dir} 
149158            --output -dir ${_ggml_vk_output_dir} 
150159            --target -hpp ${_ggml_vk_header} 
0 commit comments