Skip to content

Commit a7d6d29

Browse files
authored
chore: allow building ggml as a separate shared lib (#468)
1 parent 2e9242e commit a7d6d29

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ option(SD_SYCL "sd: sycl backend" OFF)
3333
option(SD_MUSA "sd: musa backend" OFF)
3434
option(SD_FAST_SOFTMAX "sd: x1.5 faster softmax, indeterministic (sometimes, same seed don't generate same image), cuda only" OFF)
3535
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
36+
option(SD_BUILD_SHARED_GGML_LIB "sd: build ggml as a separate shared lib" OFF)
3637
option(SD_USE_SYSTEM_GGML "sd: use system-installed GGML library" OFF)
3738
#option(SD_BUILD_SERVER "sd: build server example" ON)
3839

@@ -86,18 +87,21 @@ file(GLOB SD_LIB_SOURCES
8687
"*.hpp"
8788
)
8889

89-
# we can get only one share lib
9090
if(SD_BUILD_SHARED_LIBS)
9191
message("-- Build shared library")
9292
message(${SD_LIB_SOURCES})
93-
set(BUILD_SHARED_LIBS OFF)
93+
if(NOT SD_BUILD_SHARED_GGML_LIB)
94+
set(BUILD_SHARED_LIBS OFF)
95+
endif()
9496
add_library(${SD_LIB} SHARED ${SD_LIB_SOURCES})
9597
add_definitions(-DSD_BUILD_SHARED_LIB)
9698
target_compile_definitions(${SD_LIB} PRIVATE -DSD_BUILD_DLL)
9799
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
98100
else()
99101
message("-- Build static library")
100-
set(BUILD_SHARED_LIBS OFF)
102+
if(NOT SD_BUILD_SHARED_GGML_LIB)
103+
set(BUILD_SHARED_LIBS OFF)
104+
endif()
101105
add_library(${SD_LIB} STATIC ${SD_LIB_SOURCES})
102106
endif()
103107

0 commit comments

Comments
 (0)