mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-28 15:18:26 +01:00
fix: ggml: fix vulkan-shaders-gen build
The vulkan-shaders-gen target was not being built correctly in case of cross-compilation. Other outputs need to be built for the cross compile target, but vulkan-shaders-gen needs to be built for the host.
This commit is contained in:
parent
60cfa728e2
commit
1eac779fbe
@ -1,3 +1,6 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.19)
|
||||||
|
cmake_policy(SET CMP0114 NEW)
|
||||||
|
|
||||||
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
||||||
|
|
||||||
if (Vulkan_FOUND)
|
if (Vulkan_FOUND)
|
||||||
@ -59,9 +62,32 @@ if (Vulkan_FOUND)
|
|||||||
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT CMAKE_CROSSCOMPILING)
|
||||||
add_subdirectory(vulkan-shaders)
|
add_subdirectory(vulkan-shaders)
|
||||||
|
else()
|
||||||
set (_ggml_vk_genshaders_cmd vulkan-shaders-gen)
|
include(ExternalProject)
|
||||||
|
# Native build through ExternalProject_Add
|
||||||
|
ExternalProject_Add(
|
||||||
|
vulkan-shaders-gen
|
||||||
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
|
||||||
|
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=
|
||||||
|
-DCMAKE_SYSROOT=
|
||||||
|
-DCMAKE_C_FLAGS=-O2
|
||||||
|
-DCMAKE_CXX_FLAGS=-O2
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER
|
||||||
|
-DCMAKE_C_COMPILER=gcc
|
||||||
|
-DCMAKE_CXX_COMPILER=g++
|
||||||
|
BUILD_COMMAND ${CMAKE_COMMAND} --build .
|
||||||
|
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
|
||||||
|
INSTALL_DIR ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(vulkan-shaders-gen build install)
|
||||||
|
endif()
|
||||||
|
set (_ggml_vk_genshaders_cmd ${CMAKE_BINARY_DIR}/bin/vulkan-shaders-gen)
|
||||||
set (_ggml_vk_header ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.hpp)
|
set (_ggml_vk_header ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.hpp)
|
||||||
set (_ggml_vk_source ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.cpp)
|
set (_ggml_vk_source ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.cpp)
|
||||||
set (_ggml_vk_input_dir ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders)
|
set (_ggml_vk_input_dir ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders)
|
||||||
@ -69,6 +95,10 @@ if (Vulkan_FOUND)
|
|||||||
|
|
||||||
file(GLOB _ggml_vk_shader_deps "${_ggml_vk_input_dir}/*.comp")
|
file(GLOB _ggml_vk_shader_deps "${_ggml_vk_input_dir}/*.comp")
|
||||||
|
|
||||||
|
if (CMAKE_CROSSCOMPILING)
|
||||||
|
set(_ggml_vk_shader_deps ${_ggml_vk_shader_deps} vulkan-shaders-gen-build vulkan-shaders-gen-install)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${_ggml_vk_header}
|
OUTPUT ${_ggml_vk_header}
|
||||||
${_ggml_vk_source}
|
${_ggml_vk_source}
|
||||||
|
@ -3,7 +3,11 @@ find_package(Vulkan COMPONENTS glslc REQUIRED)
|
|||||||
|
|
||||||
set(TARGET vulkan-shaders-gen)
|
set(TARGET vulkan-shaders-gen)
|
||||||
add_executable(${TARGET} vulkan-shaders-gen.cpp)
|
add_executable(${TARGET} vulkan-shaders-gen.cpp)
|
||||||
install(TARGETS ${TARGET} RUNTIME)
|
if (${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||||
|
install(TARGETS ${TARGET} RUNTIME)
|
||||||
|
else()
|
||||||
|
install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
|
||||||
|
endif()
|
||||||
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|
||||||
target_link_libraries(vulkan-shaders-gen PUBLIC Threads::Threads)
|
target_link_libraries(vulkan-shaders-gen PUBLIC Threads::Threads)
|
||||||
target_link_libraries(vulkan-shaders-gen PRIVATE Vulkan::Vulkan)
|
target_link_libraries(vulkan-shaders-gen PRIVATE Vulkan::Vulkan)
|
||||||
|
Loading…
Reference in New Issue
Block a user