From: 旺旺碎冰冰 Date: Sat, 6 Jan 2024 03:17:47 +0000 (+0800) Subject: fix ROCm on Windows (#683) X-Git-Tag: upstream/0.0.1642~1119 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=8bf3f009e653f6bdac893c4bb6441f88ee55fe48;p=pkg%2Fggml%2Fsources%2Fggml fix ROCm on Windows (#683) * fix ROCm on windows * keep windows does not link m.lib * add hip missed compile definitions * never link m.lib * use find_library for m --------- Co-authored-by: slaren --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 669b666d..5f9baa10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -263,7 +263,7 @@ if (GGML_HIPBLAS) if (${hipblas_FOUND} AND ${hip_FOUND}) message(STATUS "HIP and hipBLAS found") - set(GGML_EXTRA_FLAGS ${GGML_EXTRA_FLAGS} -DGGML_USE_CUBLAS) + add_compile_definitions(GGML_USE_HIPBLAS GGML_USE_CUBLAS) add_library(ggml-rocm OBJECT ggml-cuda.cu ggml-cuda.h) if (BUILD_SHARED_LIBS) @@ -343,12 +343,13 @@ target_include_directories(${TARGET} PUBLIC ${GGML_EXTRA_INCS} ) -if (MSVC) - target_link_libraries(${TARGET} PUBLIC ${GGML_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) -else() - target_link_libraries(${TARGET} PUBLIC m ${GGML_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) +find_library(MATH_LIBRARY m) +if (MATH_LIBRARY) + target_link_libraries(${TARGET} PUBLIC ${MATH_LIBRARY}) endif() +target_link_libraries(${TARGET} PUBLIC ${GGML_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + if (BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)