refactor: ggml: Improve vulkan-shaders-gen toolchain setup

Use configure_file to generate host_toolchain.cmake from template
This commit is contained in:
Junil Kim 2024-12-24 12:52:04 +09:00
parent 602295bb6d
commit 7c1a6853e5
2 changed files with 10 additions and 13 deletions

View File

@ -17,7 +17,7 @@ function(detect_host_compiler)
else() else()
message(WARNING "Neither MSVC nor clang found") message(WARNING "Neither MSVC nor clang found")
endif() endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") else()
find_program(CLANG_C_COMPILER clang) find_program(CLANG_C_COMPILER clang)
find_program(CLANG_CXX_COMPILER clang++) find_program(CLANG_CXX_COMPILER clang++)
find_program(GNU_C_COMPILER gcc) find_program(GNU_C_COMPILER gcc)
@ -31,8 +31,6 @@ function(detect_host_compiler)
else() else()
message(WARNING "Neither clang nor gcc found") message(WARNING "Neither clang nor gcc found")
endif() endif()
else()
message(WARNING "Unsupported host system: ${CMAKE_HOST_SYSTEM_NAME}")
endif() endif()
endfunction() endfunction()
@ -107,16 +105,7 @@ if (Vulkan_FOUND)
else() else()
message(STATUS "Host compiler: ${HOST_C_COMPILER} ${HOST_CXX_COMPILER}") message(STATUS "Host compiler: ${HOST_C_COMPILER} ${HOST_CXX_COMPILER}")
endif() endif()
file(WRITE ${CMAKE_BINARY_DIR}/host_toolchain.cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/host_toolchain.cmake.in ${CMAKE_BINARY_DIR}/host_toolchain.cmake @ONLY)
"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"
)
set(HOST_CMAKE_TOOLCHAIN_FILE ${CMAKE_BINARY_DIR}/host_toolchain.cmake) set(HOST_CMAKE_TOOLCHAIN_FILE ${CMAKE_BINARY_DIR}/host_toolchain.cmake)
endif() endif()
message(STATUS "vulkan-shaders-gen toolchain file: ${HOST_CMAKE_TOOLCHAIN_FILE}") message(STATUS "vulkan-shaders-gen toolchain file: ${HOST_CMAKE_TOOLCHAIN_FILE}")

View File

@ -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@)