Skip to content

Commit

Permalink
refactor: ggml: Improve vulkan-shaders-gen toolchain setup
Browse files Browse the repository at this point in the history
Use configure_file to generate host_toolchain.cmake from template
  • Loading branch information
sparkleholic committed Dec 24, 2024
1 parent 602295b commit 49c225f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 2 additions & 13 deletions ggml/src/ggml-vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function(detect_host_compiler)
else()
message(WARNING "Neither MSVC nor clang found")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
else()
find_program(CLANG_C_COMPILER clang)
find_program(CLANG_CXX_COMPILER clang++)
find_program(GNU_C_COMPILER gcc)
Expand All @@ -31,8 +31,6 @@ function(detect_host_compiler)
else()
message(WARNING "Neither clang nor gcc found")
endif()
else()
message(WARNING "Unsupported host system: ${CMAKE_HOST_SYSTEM_NAME}")
endif()
endfunction()

Expand Down Expand Up @@ -107,16 +105,7 @@ if (Vulkan_FOUND)
else()
message(STATUS "Host compiler: ${HOST_C_COMPILER} ${HOST_CXX_COMPILER}")
endif()
file(WRITE ${CMAKE_BINARY_DIR}/host_toolchain.cmake
"set(CMAKE_BUILD_TYPE Release)\n"
"set(CMAKE_C_FLAGS -O2)\n"
"set(CMAKE_CXX_FLAGS -O2)\n"
"set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n"
"set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)\n"
"set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)\n"
"set(CMAKE_C_COMPILER ${HOST_C_COMPILER})\n"
"set(CMAKE_CXX_COMPILER ${HOST_CXX_COMPILER})\n"
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/host_toolchain.cmake.in ${CMAKE_BINARY_DIR}/host_toolchain.cmake @ONLY)
set(HOST_CMAKE_TOOLCHAIN_FILE ${CMAKE_BINARY_DIR}/host_toolchain.cmake)
endif()
message(STATUS "vulkan-shaders-gen toolchain file: ${HOST_CMAKE_TOOLCHAIN_FILE}")
Expand Down
8 changes: 8 additions & 0 deletions ggml/src/ggml-vulkan/host_toolchain.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_C_FLAGS -O2)
set(CMAKE_CXX_FLAGS -O2)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
set(CMAKE_C_COMPILER @HOST_C_COMPILER@)
set(CMAKE_CXX_COMPILER @HOST_CXX_COMPILER@)

0 comments on commit 49c225f

Please sign in to comment.