@@ -209,10 +209,14 @@ add_library(ggml-base
209209 gguf.cpp
210210 uint8-buff-stream.cpp)
211211
212- set_target_properties (ggml-base PROPERTIES
213- VERSION ${GGML_VERSION}
214- SOVERSION ${GGML_VERSION_MAJOR}
215- )
212+ # Set version properties for shared libraries ONLY when building as shared.
213+ # '-current_version' only allowed with '-dynamiclib'
214+ if (BUILD_SHARED_LIBS )
215+ set_target_properties (ggml-base PROPERTIES
216+ VERSION ${GGML_VERSION}
217+ SOVERSION ${GGML_VERSION_MAJOR}
218+ )
219+ endif ()
216220
217221target_include_directories (ggml-base PRIVATE .)
218222if (GGML_BACKEND_DL)
@@ -223,10 +227,12 @@ add_library(ggml
223227 ggml-backend-reg.cpp)
224228add_library (ggml::ggml ALIAS ggml)
225229
226- set_target_properties (ggml PROPERTIES
227- VERSION ${GGML_VERSION}
228- SOVERSION ${GGML_VERSION_MAJOR}
229- )
230+ if (BUILD_SHARED_LIBS )
231+ set_target_properties (ggml PROPERTIES
232+ VERSION ${GGML_VERSION}
233+ SOVERSION ${GGML_VERSION_MAJOR}
234+ )
235+ endif ()
230236
231237if (GGML_BACKEND_DIR)
232238 if (NOT GGML_BACKEND_DL)
@@ -277,11 +283,15 @@ function(ggml_add_backend_library backend)
277283 target_compile_definitions (${backend} PUBLIC GGML_BACKEND_SHARED)
278284 endif ()
279285
280- # Set versioning properties for all backend libraries
281- set_target_properties (${backend} PROPERTIES
282- VERSION ${GGML_VERSION}
283- SOVERSION ${GGML_VERSION_MAJOR}
284- )
286+ # Set versioning properties for shared backend libraries only
287+ # Note: MODULE libraries (used with GGML_BACKEND_DL) cannot have version properties
288+ # on macOS as they use -bundle instead of -dynamiclib
289+ if (${BUILD_SHARED_LIBS} AND NOT GGML_BACKEND_DL)
290+ set_target_properties (${backend} PROPERTIES
291+ VERSION ${GGML_VERSION}
292+ SOVERSION ${GGML_VERSION_MAJOR}
293+ )
294+ endif ()
285295
286296 if (NOT GGML_AVAILABLE_BACKENDS)
287297 set (GGML_AVAILABLE_BACKENDS "${backend} "
0 commit comments