This commit addresses an issue where the CMake options
`GGML_LIB_INSTALL_DIR` and `LLAMA_LIB_INSTALL_DIR` currently only affect
the generated cmake config files and not the actual installation of the
libraries.
The motivation for this change is that if these options are set, a
project that uses cmake find_package to find ggml will fail to configure:
```console
$ cmake -S . -B build
CMake Error at /work/ai/llama.cpp/install/lib/cmake/ggml/ggml-config.cmake:11 (message):
File or directory /work/ai/llama.cpp/install/llama.cpp
referenced by variable GGML_LIB_DIR does not exist !
Call Stack (most recent call first):
/work/ai/llama.cpp/install/lib/cmake/ggml/ggml-config.cmake:259 (set_and_check)
CMakeLists.txt:7 (find_package)
```
Resolves: https://github.com/ggml-org/llama.cpp/issues/19748
* cmake: Add GGML_BACKEND_DIR option
This can be used by distributions to specify where to look for backends
when ggml is built with GGML_BACKEND_DL=ON.
* Fix phrasing
* CMake config: Create target only once
Fix error on repeated find_package(ggml).
For simplicity, check only for the top-level ggml::ggml.
* CMake config: Add CUDA link libs
* CMake config: Add OpenCL link libs
* CMake config: Use canonical find_dependency
Use set and append to control link lib variables.
Apply more $<LINK_ONLY...>.
* CMake config: Wire OpenMP dependency
* cmake: Define function for querying architecture
The tests and results match exactly those of ggml/src/CMakeLists.txt
* Switch arch detection over to new function
* cmake: Factor out compiler flag function from ggml
llama.cpps's build requires it, too, and we may want to make use of it
without add_subdirectory(ggml).
* cmake: Enable building against system ggml
This facilitates package maintenance for Linux distributions, where the
libggml library most likely will be shipped as an individual package
upon which a llama.cpp package depends.
* Fix dependencies between ggml and backends
ggml backends link only to ggml-base and ggml links to all backends.
* Fix installation of ggml backends
Set up GNUInstallDirs before setting the installation directory of ggml backends