From: Carlos Zoido Date: Fri, 19 Sep 2025 03:33:53 +0000 (+0200) Subject: ggml : Fix MKL detection by quoting BLAS_INCLUDE_DIRS (#3426) X-Git-Tag: upstream/1.8.0~241 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=44fa2f647cf2a6953493b21ab83b50d5f5dbc483;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp ggml : Fix MKL detection by quoting BLAS_INCLUDE_DIRS (#3426) While working on the [whisper-cpp](https://conan.io/center/recipes/whisper-cpp) Conan package for ConanCenter, I noticed that enabling the `with_blas` option fails to build due to an issue in the _MKL_ detection logic. The problem is that the CMake condition currently expands `BLAS_INCLUDE_DIRS` without quotes: ```cmake if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel")) ``` When `BLAS_INCLUDE_DIRS` is a list (as Conan provides it), the `if()` command receives multiple arguments and produces a CMake error: ```bash ... -- BLAS found, Includes: /root/.conan2/p/b/openb034c5a6ca927b/p/include;/root/.conan2/p/b/openb034c5a6ca927b/p/include/openblas CMake Error at ggml/src/ggml-blas/CMakeLists.txt:77 (if): if given arguments: "/root/.conan2/p/b/openb034c5a6ca927b/p/include" "/root/.conan2/p/b/openb034c5a6ca927b/p/include/openblas" "MATCHES" "mkl" "AND" "(" "OpenBLAS" "MATCHES" "Generic" "OR" "OpenBLAS" "MATCHES" "Intel" ")" Unknown arguments specified ... ``` This PR fixes the issue by quoting the variable: ```cmake if ("${BLAS_INCLUDE_DIRS}" MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel")) ``` With this change, the whole list is treated as a single string and the regex still works correctly. --- diff --git a/ggml/src/ggml-blas/CMakeLists.txt b/ggml/src/ggml-blas/CMakeLists.txt index 76064c3f..60ce4b1e 100644 --- a/ggml/src/ggml-blas/CMakeLists.txt +++ b/ggml/src/ggml-blas/CMakeLists.txt @@ -74,7 +74,7 @@ if (BLAS_FOUND) target_compile_options(ggml-blas PRIVATE ${BLAS_LINKER_FLAGS}) - if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel")) + if ("${BLAS_INCLUDE_DIRS}" MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel")) add_compile_definitions(GGML_BLAS_USE_MKL) endif()