]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
examples : Test installed CMake config package (#1294)
authorKai Pastor <redacted>
Thu, 10 Jul 2025 06:57:51 +0000 (08:57 +0200)
committerGitHub <redacted>
Thu, 10 Jul 2025 06:57:51 +0000 (09:57 +0300)
* Add test-cmake example

* CI: Run test for installed cmake config

.github/workflows/ci.yml
examples/test-cmake/CMakeLists.txt [new file with mode: 0644]
examples/test-cmake/README.md [new file with mode: 0644]
examples/test-cmake/test-cmake.cpp [new file with mode: 0644]

index b1e80df79742d51345e4208d59a1e27f3ab6a4d9..e4114f593956d333bd2e7b6a2f7aa33cadb97a84 100644 (file)
@@ -65,7 +65,11 @@ jobs:
 
     - name: Configure CMake
       working-directory: ./build
-      run: cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DGGML_METAL=OFF ..
+      run: cmake ..
+        -DCMAKE_C_COMPILER=clang
+        -DCMAKE_CXX_COMPILER=clang++
+        -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/installed
+        -DGGML_METAL=OFF
 
     - name: Build
       working-directory: ./build
@@ -75,6 +79,16 @@ jobs:
       working-directory: ./build
       run: ctest --verbose --timeout 900
 
+    - name: Install
+      working-directory: ./build
+      run: cmake --build . --target install
+
+    - name: Test CMake config
+      run: |
+        mkdir test-cmake
+        cmake -S examples/test-cmake -B test-cmake -DCMAKE_PREFIX_PATH=${{ github.workspace }}/installed
+        cmake --build test-cmake
+
   windows:
     if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
             github.event.inputs.run_type == 'full-ci' }}
diff --git a/examples/test-cmake/CMakeLists.txt b/examples/test-cmake/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d6bc0cc
--- /dev/null
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.14)
+project(ggml-simple)
+
+set(CMAKE_CXX_STANDARD 17)
+
+find_package(ggml CONFIG REQUIRED)
+
+set(TEST_TARGET test-cmake)
+add_executable(test-cmake test-cmake.cpp)
+target_link_libraries(test-cmake PRIVATE ggml::ggml)
diff --git a/examples/test-cmake/README.md b/examples/test-cmake/README.md
new file mode 100644 (file)
index 0000000..8f580d1
--- /dev/null
@@ -0,0 +1,3 @@
+## cmake-test
+
+This directory can be built as a separate project with an installed ggml.
diff --git a/examples/test-cmake/test-cmake.cpp b/examples/test-cmake/test-cmake.cpp
new file mode 100644 (file)
index 0000000..029c889
--- /dev/null
@@ -0,0 +1,6 @@
+#include "ggml-backend.h"
+
+int main(void) {
+    ggml_backend_load_all();
+    return 0;
+}