Skip to content

Commit 16a10e9

Browse files
committed
fix_version_only_dynamiclib
1 parent d4787f2 commit 16a10e9

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

ggml/src/CMakeLists.txt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

217221
target_include_directories(ggml-base PRIVATE .)
218222
if (GGML_BACKEND_DL)
@@ -223,10 +227,12 @@ add_library(ggml
223227
ggml-backend-reg.cpp)
224228
add_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

231237
if (GGML_BACKEND_DIR)
232238
if (NOT GGML_BACKEND_DL)
@@ -277,11 +283,13 @@ 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+
if (${BUILD_SHARED_LIBS} OR GGML_BACKEND_DL)
288+
set_target_properties(${backend} PROPERTIES
289+
VERSION ${GGML_VERSION}
290+
SOVERSION ${GGML_VERSION_MAJOR}
291+
)
292+
endif()
285293

286294
if(NOT GGML_AVAILABLE_BACKENDS)
287295
set(GGML_AVAILABLE_BACKENDS "${backend}"

0 commit comments

Comments
 (0)