cmake : fix build shared ggml when CUDA is enabled (#1929)

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This commit is contained in:
Howard Su 2023-06-19 23:10:37 +08:00 committed by GitHub
parent 16b9cd1939
commit 1e3abfcef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -469,6 +469,7 @@ add_library(ggml_static STATIC $<TARGET_OBJECTS:ggml>)
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
set_target_properties(ggml PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(ggml PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(ggml_shared SHARED $<TARGET_OBJECTS:ggml>) add_library(ggml_shared SHARED $<TARGET_OBJECTS:ggml>)
target_link_libraries(ggml_shared PUBLIC Threads::Threads ${LLAMA_EXTRA_LIBS})
endif() endif()
add_library(llama add_library(llama
@ -500,6 +501,11 @@ if (GGML_SOURCES_CUDA)
set_property(TARGET ggml_static PROPERTY CUDA_ARCHITECTURES "native") set_property(TARGET ggml_static PROPERTY CUDA_ARCHITECTURES "native")
set_property(TARGET ggml_static PROPERTY CUDA_SELECT_NVCC_ARCH_FLAGS "Auto") set_property(TARGET ggml_static PROPERTY CUDA_SELECT_NVCC_ARCH_FLAGS "Auto")
if (BUILD_SHARED_LIBS)
set_property(TARGET ggml_shared PROPERTY CUDA_ARCHITECTURES "native")
set_property(TARGET ggml_shared PROPERTY CUDA_SELECT_NVCC_ARCH_FLAGS "Auto")
endif()
set_property(TARGET llama PROPERTY CUDA_ARCHITECTURES "native") set_property(TARGET llama PROPERTY CUDA_ARCHITECTURES "native")
endif() endif()