aports/testing/whisper.cpp/0002-Install-libraries-into-WHISPER_LIB_INSTALL_DIR.patch
Hugo Osvaldo Barrera 10234d733c testing/whisper.cpp: new aport
https://github.com/ggerganov/whisper.cpp
Port of OpenAI's Whisper model in C/C++

Co-Authored-By: Marian Buschsieweke <marian.buschsieweke@posteo.net>
2026-04-25 20:55:21 +00:00

59 lines
2.4 KiB
Diff

From ab6b1560c4edd93bb048059dfaf001bca4b2d6a5 Mon Sep 17 00:00:00 2001
From: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
Date: Sat, 25 Apr 2026 15:45:32 +0200
Subject: [PATCH 2/2] Install libraries into WHISPER_LIB_INSTALL_DIR
whisper.cpp uses a vendored diverging version of libggml, but installs
into /usr/lib/ by default, conflicting with non-vendored libggml.
Install these libraries into WHISPER_LIB_INSTALL_DIR.
See: https://github.com/ggml-org/whisper.cpp/issues/3772
---
CMakeLists.txt | 7 ++++++-
ggml/CMakeLists.txt | 7 +++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0f74041..9d796983 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,10 +176,15 @@ set(WHISPER_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location
set(WHISPER_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
set(WHISPER_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
+if (NOT WHISPER_LIB_INSTALL_DIR STREQUAL CMAKE_INSTALL_LIBDIR)
+ set(CMAKE_INSTALL_RPATH "${WHISPER_LIB_INSTALL_DIR}")
+ set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/bin")
+endif()
+
get_directory_property(WHISPER_TRANSIENT_DEFINES COMPILE_DEFINITIONS)
set_target_properties(whisper PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/whisper.h)
-install(TARGETS whisper LIBRARY PUBLIC_HEADER)
+install(TARGETS whisper LIBRARY DESTINATION ${WHISPER_LIB_INSTALL_DIR} PUBLIC_HEADER)
target_compile_definitions(whisper PRIVATE
WHISPER_VERSION="${PROJECT_VERSION}"
diff --git a/ggml/CMakeLists.txt b/ggml/CMakeLists.txt
index c780077a..ee70a617 100644
--- a/ggml/CMakeLists.txt
+++ b/ggml/CMakeLists.txt
@@ -336,8 +336,11 @@ set_target_properties(ggml PROPERTIES PUBLIC_HEADER "${GGML_PUBLIC_HEADERS}")
#if (GGML_METAL)
# set_target_properties(ggml PROPERTIES RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/ggml-metal.metal")
#endif()
-install(TARGETS ggml LIBRARY PUBLIC_HEADER)
-install(TARGETS ggml-base LIBRARY)
+if (NOT DEFINED GGML_LIB_INSTALL_DIR)
+ set(GGML_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
+endif()
+install(TARGETS ggml LIBRARY DESTINATION ${GGML_LIB_INSTALL_DIR} PUBLIC_HEADER)
+install(TARGETS ggml-base LIBRARY DESTINATION ${GGML_LIB_INSTALL_DIR})
if (GGML_STANDALONE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ggml.pc.in
--
2.53.0