Commit 7d9b931df for llama.cpp
commit 7d9b931df9bb7c689f067a7fed23e7f5253951f6
Author: Daniel Bevenius <daniel.bevenius@gmail.com>
Date: Mon Nov 23 11:05:21 2026 +0100
ggml : update cmake MATH_LIBRARY check (#32864)
This commit updates the cmake check for `MATH_LIBRARY` and removes the
DEFINED operator for the if() command.
The motivation for this is that on windows if a parent project of ggml
calls find_library(MATH_LIBRARY) this could return
`MATH_LIBRARY-NOTFOUND` which will cause the if clause to be true.
Removing the DEFINED operator will work as intended will evaluate to
false, as specified by cmake if command docs:
```console
False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the
empty string, or ends in the suffix -NOTFOUND.
```
This commit was originally opened in a PR against whisper.cpp, see link
below.
Refs: https://github.com/ggml-org/whisper.cpp/pull/4168
Refs: https://cmake.org/cmake/help/latest/command/if.html#constant
diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt
index eee1a460d..74ddb51ca 100644
--- a/ggml/src/CMakeLists.txt
+++ b/ggml/src/CMakeLists.txt
@@ -621,7 +621,7 @@ endforeach()
target_link_libraries(ggml-base PRIVATE Threads::Threads)
-if (DEFINED MATH_LIBRARY)
+if (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)