Skip to content
Merged
52 changes: 26 additions & 26 deletions ports/ggml/pkgconfig.diff
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0211255..1b1732a 100644
index c97f681..64a456b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -333,7 +333,7 @@ if (GGML_STANDALONE)
@@ -352,7 +352,7 @@ if (GGML_STANDALONE)
@ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml.pc
Expand All @@ -11,7 +11,7 @@ index 0211255..1b1732a 100644
endif()

#
@@ -354,6 +354,7 @@ set(variable_set_statements
@@ -373,6 +373,7 @@ set(variable_set_statements
set(GGML_SHARED_LIB ${BUILD_SHARED_LIBS})

get_cmake_property(all_variables VARIABLES)
Expand All @@ -34,10 +34,10 @@ index 3e0291e..a762733 100644
+Libs.private: @GGML_PKGCONFIG_LIBS_PRIVATE@
+Requires.private: @GGML_PKGCONFIG_REQUIRES_PRIVATE@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 628db3f..af611bb 100644
index 3e48860..1ec27e8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -189,6 +189,10 @@ endif()
@@ -185,6 +185,10 @@ endif()

# ggml

Expand All @@ -48,15 +48,15 @@ index 628db3f..af611bb 100644
if (GGML_BACKEND_DL AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "GGML_BACKEND_DL requires BUILD_SHARED_LIBS")
endif()
@@ -241,6 +245,7 @@ target_link_libraries(ggml PUBLIC ggml-base)
@@ -243,6 +247,7 @@ target_link_libraries(ggml PUBLIC ggml-base)

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(ggml PRIVATE dl)
+ string(APPEND GGML_PKGCONFIG_LIBS_PRIVATE " -ldl")
endif()

function(ggml_add_backend_library backend)
@@ -291,12 +296,20 @@ function(ggml_add_backend backend)
@@ -296,12 +301,20 @@ function(ggml_add_backend backend)
string(TOUPPER "GGML_${backend}" backend_id)
if (${backend_id})
string(TOLOWER "ggml-${backend}" backend_target)
Expand All @@ -77,12 +77,11 @@ index 628db3f..af611bb 100644
endif()
endfunction()

@@ -434,11 +447,15 @@ find_library(MATH_LIBRARY m)
if (MATH_LIBRARY)
if (NOT WIN32 OR NOT DEFINED ENV{ONEAPI_ROOT})
target_link_libraries(ggml-base PRIVATE m)
+ string(APPEND GGML_PKGCONFIG_LIBS_PRIVATE " -lm")
endif()
@@ -474,10 +487,14 @@ if (DEFINED MATH_LIBRARY)
target_link_libraries(ggml-base PRIVATE ${MATH_LIBRARY})
elseif (NOT WIN32 AND NOT DEFINED ENV{ONEAPI_ROOT})
target_link_libraries(ggml-base PRIVATE m)
+ string(APPEND GGML_PKGCONFIG_LIBS_PRIVATE " -lm")
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Android")
Expand All @@ -93,34 +92,35 @@ index 628db3f..af611bb 100644
endif()

if(CMAKE_SYSTEM_NAME MATCHES "visionOS")
@@ -451,4 +468,10 @@ if (BUILD_SHARED_LIBS)
@@ -489,5 +506,11 @@ if (BUILD_SHARED_LIBS)
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${target} PRIVATE GGML_BUILD)
target_compile_definitions(${target} PUBLIC GGML_SHARED)
+ string(APPEND GGML_PKGCONFIG_CFLAGS " -DGGML_SHARED -DGGML_BACKEND_SHARED")
endforeach()
+ string(APPEND GGML_PKGCONFIG_CFLAGS " -DGGML_SHARED -DGGML_BACKEND_SHARED")
endif()
+
+set(GGML_PKGCONFIG_CFLAGS "${GGML_PKGCONFIG_CFLAGS}" PARENT_SCOPE)
+set(GGML_PKGCONFIG_LIBS_BACKEND "${GGML_PKGCONFIG_LIBS_BACKEND}" PARENT_SCOPE)
+set(GGML_PKGCONFIG_LIBS_PRIVATE "${GGML_PKGCONFIG_LIBS_PRIVATE}" PARENT_SCOPE)
+set(GGML_PKGCONFIG_REQUIRES_PRIVATE "${GGML_PKGCONFIG_REQUIRES_PRIVATE}" PARENT_SCOPE)
diff --git a/src/ggml-blas/CMakeLists.txt b/src/ggml-blas/CMakeLists.txt
index 60ce4b1..058f65c 100644
index c27dc17..ce1ab21 100644
--- a/src/ggml-blas/CMakeLists.txt
+++ b/src/ggml-blas/CMakeLists.txt
@@ -79,6 +79,7 @@ if (BLAS_FOUND)
@@ -93,6 +93,7 @@ if (BLAS_FOUND)
endif()

target_link_libraries (ggml-blas PRIVATE ${BLAS_LIBRARIES})
+ set(GGML_PKGCONFIG_REQUIRES_PRIVATE "${GGML_PKGCONFIG_REQUIRES_PRIVATE} cblas" PARENT_SCOPE)
target_include_directories(ggml-blas PRIVATE ${BLAS_INCLUDE_DIRS})
target_include_directories(ggml-blas SYSTEM PRIVATE ${BLAS_INCLUDE_DIRS})
else()
message(FATAL_ERROR "BLAS not found, please refer to "
diff --git a/src/ggml-cpu/CMakeLists.txt b/src/ggml-cpu/CMakeLists.txt
index e52e050..107cbf5 100644
index c1c225f..39ef457 100644
--- a/src/ggml-cpu/CMakeLists.txt
+++ b/src/ggml-cpu/CMakeLists.txt
@@ -52,6 +52,9 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
@@ -57,6 +57,9 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
target_compile_features(${GGML_CPU_NAME} PRIVATE c_std_11 cxx_std_17)
target_include_directories(${GGML_CPU_NAME} PRIVATE . ggml-cpu)

Expand All @@ -130,15 +130,15 @@ index e52e050..107cbf5 100644
if (APPLE AND GGML_ACCELERATE)
find_library(ACCELERATE_FRAMEWORK Accelerate)
if (ACCELERATE_FRAMEWORK)
@@ -62,6 +65,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
@@ -67,6 +70,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
target_compile_definitions(${GGML_CPU_NAME} PRIVATE ACCELERATE_LAPACK_ILP64)

target_link_libraries(${GGML_CPU_NAME} PRIVATE ${ACCELERATE_FRAMEWORK})
+ string(APPEND libs_private " -framework Accelerate")
else()
message(WARNING "Accelerate framework not found")
endif()
@@ -74,6 +78,18 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
@@ -79,6 +83,18 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
target_compile_definitions(${GGML_CPU_NAME} PRIVATE GGML_USE_OPENMP)

target_link_libraries(${GGML_CPU_NAME} PRIVATE OpenMP::OpenMP_C OpenMP::OpenMP_CXX)
Expand All @@ -157,7 +157,7 @@ index e52e050..107cbf5 100644
else()
set(GGML_OPENMP_ENABLED "OFF" CACHE INTERNAL "")
message(WARNING "OpenMP not found")
@@ -96,8 +112,12 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
@@ -101,8 +117,12 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
target_compile_definitions(${GGML_CPU_NAME} PRIVATE GGML_USE_CPU_HBM)

target_link_libraries(${GGML_CPU_NAME} PUBLIC memkind)
Expand All @@ -171,7 +171,7 @@ index e52e050..107cbf5 100644
message(STATUS "ARM detected")
list(APPEND GGML_CPU_SOURCES
diff --git a/src/ggml-metal/CMakeLists.txt b/src/ggml-metal/CMakeLists.txt
index 63418fe..138996a 100644
index 42054d8..d780361 100644
--- a/src/ggml-metal/CMakeLists.txt
+++ b/src/ggml-metal/CMakeLists.txt
@@ -19,6 +19,11 @@ target_link_libraries(ggml-metal PRIVATE
Expand All @@ -187,7 +187,7 @@ index 63418fe..138996a 100644
add_compile_definitions(GGML_METAL_NDEBUG)
endif()
diff --git a/src/ggml-opencl/CMakeLists.txt b/src/ggml-opencl/CMakeLists.txt
index 681c81b..bac7067 100644
index 5ed83ee..bb06a50 100644
--- a/src/ggml-opencl/CMakeLists.txt
+++ b/src/ggml-opencl/CMakeLists.txt
@@ -7,6 +7,7 @@ ggml_add_backend_library(${TARGET_NAME}
Expand All @@ -199,7 +199,7 @@ index 681c81b..bac7067 100644

if (GGML_OPENCL_PROFILING)
diff --git a/src/ggml-vulkan/CMakeLists.txt b/src/ggml-vulkan/CMakeLists.txt
index de01336..3f9524c 100644
index 715a263..04c142c 100644
--- a/src/ggml-vulkan/CMakeLists.txt
+++ b/src/ggml-vulkan/CMakeLists.txt
@@ -87,6 +87,11 @@ if (Vulkan_FOUND)
Expand Down
5 changes: 2 additions & 3 deletions ports/ggml/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ggml-org/ggml
REF 55bc9320a4aae82af18e23eefd5de319a755d7b9
SHA512 9433c9c258bbbfa817051f2ba2a8c8f166ee885c953d3ee27198890d4af8366fdee11ba55514b8b8414c836615e56eceaa98f33a01ecf51846338bc60d34263b
REF v${VERSION}
SHA512 c49b6498101f50a5ebde158f5707237f6df3af0182e819651003ec5f418144f9ca68cc8434189f2a658ea705269fad2d263cfe4931c12b369883aa5a66182ed9
HEAD_REF master
PATCHES
cmake-config.diff
pkgconfig.diff
relax-link-options.diff
vulkan-shaders-gen.diff
fix-dequant_funcs.diff
cuda-13-2.diff
Comment thread
miyanyan marked this conversation as resolved.
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
3 changes: 1 addition & 2 deletions ports/ggml/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "ggml",
"version-date": "2025-11-17",
"port-version": 2,
"version": "0.11.0",
"description": "Tensor library for machine learning",
"homepage": "https://github.com/ggml-org/ggml",
"license": "MIT",
Expand Down
45 changes: 29 additions & 16 deletions ports/llama-cpp/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ggml-org/llama.cpp
REF b${VERSION}
SHA512 879490cdeeef9397b9843730399bd55c7ef57de7e421cfcbaa15bd95416e028e4a0864f237218895a8a1244b7a4dbef9eacda49aa9697628e29774d0fc90d04b
SHA512 ef5e21b61ca2961004fc57ad9d4a07191458df4f1749e71a9dc96d653676a6d68d43b7b8c74ebb235f6dffe5c064330cb1124887bc5c119876d7292543321945
HEAD_REF master
PATCHES
cmake-config.diff
pkgconfig.diff
unvendor.diff
)
file(REMOVE_RECURSE "${SOURCE_PATH}/ggml/include" "${SOURCE_PATH}/ggml/src")
file(REMOVE_RECURSE
"${SOURCE_PATH}/vendor/cpp-httplib"
"${SOURCE_PATH}/vendor/miniaudio"
"${SOURCE_PATH}/vendor/nlohmann"
"${SOURCE_PATH}/vendor/stb")

vcpkg_check_features(OUT_FEATURE_OPTIONS options
FEATURES
download LLAMA_CURL
server LLAMA_BUILD_SERVER
tools LLAMA_BUILD_TOOLS
)

Expand All @@ -24,7 +31,6 @@ vcpkg_cmake_configure(
-DLLAMA_ALL_WARNINGS=OFF
-DLLAMA_BUILD_TESTS=OFF
-DLLAMA_BUILD_EXAMPLES=OFF
-DLLAMA_BUILD_SERVER=OFF
-DLLAMA_USE_SYSTEM_GGML=ON
-DVCPKG_LOCK_FIND_PACKAGE_Git=OFF
)
Expand All @@ -39,21 +45,28 @@ file(RENAME "${CURRENT_PACKAGES_DIR}/bin/convert_hf_to_gguf.py" "${CURRENT_PACKA
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/convert_hf_to_gguf.py")

if("tools" IN_LIST FEATURES)
set(tool_names
llama-batched-bench
llama-bench
llama-completion
llama-cvector-generator
llama-export-lora
llama-fit-params
llama-gguf-split
llama-imatrix
llama-mtmd-cli
llama-perplexity
llama-quantize
llama-results
llama-template-analysis
llama-tokenize
llama-tts
)
if("server" IN_LIST FEATURES)
list(APPEND tool_names llama-cli llama-server)
endif()
vcpkg_copy_tools(
TOOL_NAMES
llama-batched-bench
llama-bench
llama-cli
llama-cvector-generator
llama-export-lora
llama-gguf-split
llama-imatrix
llama-mtmd-cli
llama-perplexity
llama-quantize
llama-run
llama-tokenize
llama-tts
TOOL_NAMES ${tool_names}
AUTO_CLEAN
)
endif()
Expand Down
125 changes: 125 additions & 0 deletions ports/llama-cpp/unvendor.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 310a3dc..1f1495b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -197,8 +197,8 @@ add_subdirectory(src)
#

if (LLAMA_BUILD_COMMON)
+ find_package(httplib CONFIG REQUIRED)
add_subdirectory(common)
- add_subdirectory(vendor/cpp-httplib)
Comment on lines +9 to +12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

     add_subdirectory(common)
-    add_subdirectory(vendor/cpp-httplib)
+    find_package(httplib CONFIG REQUIRED)
+    add_library(cpp-httplib ALIAS httplib::httplib)

would avoid of changing all the uses of cpp-httplib (and still export httplib::httplib to cmake config).

... And we probably need a find_dependency(httplib CONFIG) in the cmake confiug file (unless it is only used in executables - check the export).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp-httplib is only linked privately by llama-common:

target_link_libraries(llama-common PRIVATE cpp-httplib)

and llama-common is not exported as a CMake target in the installed package. The generated llama-config.cmake only creates/imports the llama target, whose interface links to ggml. So httplib is not part of the public CMake interface for consumers.

https://github.com/ggml-org/llama.cpp/blob/master/cmake/llama-config.cmake.in#L20

https://github.com/ggml-org/llama.cpp/blob/bbeb89d76c41bc250f16e4a6fefcc9b530d6e3f3/CMakeLists.txt#L250-L254

endif()

if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 1a56c25..4612a21 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -135,7 +135,7 @@ if (BUILD_SHARED_LIBS)
endif()

target_link_libraries(${TARGET} PUBLIC llama-common-base)
-target_link_libraries(${TARGET} PRIVATE cpp-httplib)
+target_link_libraries(${TARGET} PRIVATE httplib::httplib)

if (LLAMA_LLGUIDANCE)
include(ExternalProject)
diff --git a/common/http.h b/common/http.h
index d3daccd..be18264 100644
--- a/common/http.h
+++ b/common/http.h
@@ -1,6 +1,6 @@
#pragma once

-#include <cpp-httplib/httplib.h>
+#include <httplib.h>

struct common_http_url {
std::string scheme;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index edb585b..5b0fec7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -267,11 +267,11 @@ unset(LLAMA_TEST_NAME)

# GGUF model data fetcher library for tests that need real model metadata
# Only compile when cpp-httplib has SSL support (CPPHTTPLIB_OPENSSL_SUPPORT)
-if (TARGET cpp-httplib)
- get_target_property(_cpp_httplib_defs cpp-httplib INTERFACE_COMPILE_DEFINITIONS)
+if (TARGET httplib::httplib)
+ get_target_property(_cpp_httplib_defs httplib::httplib INTERFACE_COMPILE_DEFINITIONS)
if (_cpp_httplib_defs MATCHES "CPPHTTPLIB_OPENSSL_SUPPORT")
add_library(gguf-model-data STATIC gguf-model-data.cpp)
- target_link_libraries(gguf-model-data PRIVATE llama-common cpp-httplib)
+ target_link_libraries(gguf-model-data PRIVATE llama-common httplib::httplib)
target_include_directories(gguf-model-data PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_executable(test-gguf-model-data test-gguf-model-data.cpp)
diff --git a/tools/mtmd/CMakeLists.txt b/tools/mtmd/CMakeLists.txt
index 35d721d..18eabc4 100644
--- a/tools/mtmd/CMakeLists.txt
+++ b/tools/mtmd/CMakeLists.txt
@@ -53,7 +53,6 @@ target_link_libraries (mtmd PUBLIC ggml llama)
target_link_libraries (mtmd PRIVATE Threads::Threads)
target_include_directories(mtmd PUBLIC .)
target_include_directories(mtmd PRIVATE ../..)
-target_include_directories(mtmd PRIVATE ../../vendor)
target_compile_features (mtmd PRIVATE cxx_std_17)

if (BUILD_SHARED_LIBS)
diff --git a/tools/mtmd/mtmd-helper.cpp b/tools/mtmd/mtmd-helper.cpp
index 4094074..d40ae74 100644
--- a/tools/mtmd/mtmd-helper.cpp
+++ b/tools/mtmd/mtmd-helper.cpp
@@ -27,10 +27,10 @@
#define MA_NO_ENGINE
#define MA_NO_GENERATION
#define MA_API static
-#include "miniaudio/miniaudio.h"
+#include "miniaudio.h"

#define STB_IMAGE_IMPLEMENTATION
-#include "stb/stb_image.h"
+#include "stb_image.h"

#ifdef MTMD_INTERNAL_HEADER
#error "mtmd-helper is a public library outside of mtmd. it must not include internal headers"
diff --git a/tools/server/CMakeLists.txt b/tools/server/CMakeLists.txt
index 71cc0e7..1925fff 100644
--- a/tools/server/CMakeLists.txt
+++ b/tools/server/CMakeLists.txt
@@ -70,6 +70,6 @@ install(TARGETS ${TARGET} RUNTIME)

target_include_directories(${TARGET} PRIVATE ../mtmd)
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
-target_link_libraries(${TARGET} PRIVATE server-context PUBLIC llama-common cpp-httplib ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${TARGET} PRIVATE server-context PUBLIC llama-common httplib::httplib ${CMAKE_THREAD_LIBS_INIT})

target_compile_features(${TARGET} PRIVATE cxx_std_17)
diff --git a/tools/server/server-http.cpp b/tools/server/server-http.cpp
index 6f24f83..40a5c85 100644
--- a/tools/server/server-http.cpp
+++ b/tools/server/server-http.cpp
@@ -2,7 +2,7 @@
#include "server-http.h"
#include "server-common.h"

-#include <cpp-httplib/httplib.h>
+#include <httplib.h>

#include <functional>
#include <string>
diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp
index 5a05ca2..3b7aef9 100644
--- a/tools/server/server-models.cpp
+++ b/tools/server/server-models.cpp
@@ -5,7 +5,7 @@
#include "preset.h"
#include "download.h"

-#include <cpp-httplib/httplib.h> // TODO: remove this once we use HTTP client from download.h
+#include <httplib.h> // TODO: remove this once we use HTTP client from download.h
#include <sheredom/subprocess.h>

#include <functional>
Loading
Loading