From 89c533af1876ca554e85238785ef2a17cf6913b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=95=AD=E6=BE=A7=E9=82=A6?= <45505768+shou692199@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:20:04 +0800 Subject: [PATCH 1/2] cmake: exclude math library when generator is Visual Studio Trying to build cpu only variant on Windows when oneAPI environment is active, it will failed by an linker error LNK1104. This commit solved the issue by excluding libm.lib target link also when cmake generator is any version of Visual Studio. --- ggml/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt index aa405e4d0fb1a..b4b9dde918650 100644 --- a/ggml/src/CMakeLists.txt +++ b/ggml/src/CMakeLists.txt @@ -1400,7 +1400,7 @@ list(APPEND GGML_EXTRA_LIBS_PRIVATE Threads::Threads) find_library(MATH_LIBRARY m) if (MATH_LIBRARY) - if (NOT WIN32 OR NOT GGML_SYCL) + if ((NOT WIN32 OR NOT GGML_SYCL) AND NOT CMAKE_GENERATOR MATCHES "Visual Studio*") list(APPEND GGML_EXTRA_LIBS_PRIVATE m) endif() endif() From d3b183f7431ca1d2d772ec62302913b98ad8131e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=95=AD=E6=BE=A7=E9=82=A6?= <45505768+shou692199@users.noreply.github.com> Date: Tue, 22 Oct 2024 05:23:45 +0800 Subject: [PATCH 2/2] more clever way to exclude libm if needed check GGML_SYCL and ONEAPI_ROOT state rather than generator name. --- ggml/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt index b4b9dde918650..0ed81193ac153 100644 --- a/ggml/src/CMakeLists.txt +++ b/ggml/src/CMakeLists.txt @@ -1400,7 +1400,7 @@ list(APPEND GGML_EXTRA_LIBS_PRIVATE Threads::Threads) find_library(MATH_LIBRARY m) if (MATH_LIBRARY) - if ((NOT WIN32 OR NOT GGML_SYCL) AND NOT CMAKE_GENERATOR MATCHES "Visual Studio*") + if (NOT WIN32 OR NOT (GGML_SYCL OR DEFINED ENV{ONEAPI_ROOT})) list(APPEND GGML_EXTRA_LIBS_PRIVATE m) endif() endif()