Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/cmake/ggml-config.cmake.in # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / cmake / ggml-config.cmake.in` 216 lines ยท 8018 bytes Raw Blame History 1 @PACKAGE_INIT@ 2 3 @GGML_VARIABLES_EXPANDED@ 4 5 # Find all dependencies before creating any target. 6 include(CMakeFindDependencyMacro) 7 find_dependency(Threads) 8 if (NOT GGML_SHARED_LIB) 9 set(GGML_BASE_INTERFACE_LINK_LIBRARIES "") 10 set(GGML_CPU_INTERFACE_LINK_LIBRARIES "") 11 set(GGML_CPU_INTERFACE_LINK_OPTIONS "") 12 13 if (APPLE AND GGML_ACCELERATE) 14 find_library(ACCELERATE_FRAMEWORK Accelerate) 15 if(NOT ACCELERATE_FRAMEWORK) 16 set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0) 17 return() 18 endif() 19 list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${ACCELERATE_FRAMEWORK}) 20 endif() 21 22 if (GGML_OPENMP_ENABLED) 23 find_dependency(OpenMP) 24 set(GGML_OPENMP_INTERFACE_LINK_LIBRARIES "") 25 if (TARGET OpenMP::OpenMP_C) 26 list(APPEND GGML_OPENMP_INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_C) 27 endif() 28 if (TARGET OpenMP::OpenMP_CXX) 29 list(APPEND GGML_OPENMP_INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_CXX) 30 endif() 31 list(APPEND GGML_BASE_INTERFACE_LINK_LIBRARIES ${GGML_OPENMP_INTERFACE_LINK_LIBRARIES}) 32 list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${GGML_OPENMP_INTERFACE_LINK_LIBRARIES}) 33 endif() 34 35 if (GGML_CPU_HBM) 36 find_library(memkind memkind) 37 if(NOT memkind) 38 set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0) 39 return() 40 endif() 41 list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES memkind) 42 endif() 43 44 if (GGML_BLAS) 45 find_dependency(BLAS) 46 list(APPEND GGML_BLAS_INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES}) 47 list(APPEND GGML_BLAS_INTERFACE_LINK_OPTIONS ${BLAS_LINKER_FLAGS}) 48 endif() 49 50 if (GGML_CUDA) 51 set(GGML_CUDA_INTERFACE_LINK_LIBRARIES "") 52 find_dependency(CUDAToolkit) 53 if (GGML_STATIC) 54 list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $) 55 if (WIN32) 56 list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $ $) 57 else() 58 list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $ $) 59 endif() 60 endif() 61 if (NOT GGML_CUDA_NO_VMM) 62 list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $) 63 endif() 64 endif() 65 66 if (GGML_METAL) 67 find_library(FOUNDATION_LIBRARY Foundation) 68 find_library(METAL_FRAMEWORK Metal) 69 find_library(METALKIT_FRAMEWORK MetalKit) 70 if(NOT FOUNDATION_LIBRARY OR NOT METAL_FRAMEWORK OR NOT METALKIT_FRAMEWORK) 71 set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0) 72 return() 73 endif() 74 set(GGML_METAL_INTERFACE_LINK_LIBRARIES 75 ${FOUNDATION_LIBRARY} ${METAL_FRAMEWORK} ${METALKIT_FRAMEWORK}) 76 endif() 77 78 if (GGML_OPENCL) 79 find_dependency(OpenCL) 80 set(GGML_OPENCL_INTERFACE_LINK_LIBRARIES $) 81 endif() 82 83 if (GGML_VULKAN) 84 find_dependency(Vulkan) 85 set(GGML_VULKAN_INTERFACE_LINK_LIBRARIES $) 86 endif() 87 88 if (GGML_HIP) 89 find_dependency(hip) 90 find_dependency(hipblas) 91 find_dependency(rocblas) 92 set(GGML_HIP_INTERFACE_LINK_LIBRARIES hip::host roc::rocblas roc::hipblas) 93 endif() 94 95 if (GGML_SYCL) 96 set(GGML_SYCL_INTERFACE_LINK_LIBRARIES "") 97 find_package(DNNL) 98 if (${DNNL_FOUND} AND GGML_SYCL_TARGET STREQUAL "INTEL") 99 list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES DNNL::dnnl) 100 endif() 101 if (WIN32) 102 find_dependency(IntelSYCL) 103 find_dependency(MKL) 104 list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL) 105 endif() 106 endif() 107 endif() 108 109 set_and_check(GGML_INCLUDE_DIR "@PACKAGE_GGML_INCLUDE_INSTALL_DIR@") 110 set_and_check(GGML_LIB_DIR "@PACKAGE_GGML_LIB_INSTALL_DIR@") 111 #set_and_check(GGML_BIN_DIR "@PACKAGE_GGML_BIN_INSTALL_DIR@") 112 113 if (NOT GGML_SHARED_LIB AND GGML_CPU_KLEIDIAI) 114 unset(KLEIDIAI_LIBRARY CACHE) 115 unset(KLEIDIAI_LIBRARY) 116 find_library(KLEIDIAI_LIBRARY kleidiai 117 REQUIRED 118 HINTS ${GGML_LIB_DIR} 119 NO_CMAKE_FIND_ROOT_PATH) 120 list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${KLEIDIAI_LIBRARY}) 121 endif() 122 123 if(NOT TARGET ggml::ggml) 124 find_package(Threads REQUIRED) 125 126 unset(GGML_LIBRARY CACHE) 127 find_library(GGML_LIBRARY ggml 128 REQUIRED 129 HINTS ${GGML_LIB_DIR} 130 NO_CMAKE_FIND_ROOT_PATH) 131 132 add_library(ggml::ggml UNKNOWN IMPORTED) 133 set_target_properties(ggml::ggml 134 PROPERTIES 135 IMPORTED_LOCATION "${GGML_LIBRARY}" 136 INTERFACE_INCLUDE_DIRECTORIES "${GGML_INCLUDE_DIR}") 137 138 unset(GGML_BASE_LIBRARY CACHE) 139 find_library(GGML_BASE_LIBRARY ggml-base 140 REQUIRED 141 HINTS ${GGML_LIB_DIR} 142 NO_CMAKE_FIND_ROOT_PATH) 143 144 add_library(ggml::ggml-base UNKNOWN IMPORTED) 145 set_target_properties(ggml::ggml-base 146 PROPERTIES 147 IMPORTED_LOCATION "${GGML_BASE_LIBRARY}" 148 INTERFACE_INCLUDE_DIRECTORIES "${GGML_INCLUDE_DIR}" 149 INTERFACE_LINK_LIBRARIES "${GGML_BASE_INTERFACE_LINK_LIBRARIES}") 150 151 set(_ggml_all_targets "") 152 if (NOT GGML_BACKEND_DL) 153 foreach(_ggml_backend ${GGML_AVAILABLE_BACKENDS}) 154 string(REPLACE "-" "_" _ggml_backend_pfx "${_ggml_backend}") 155 string(TOUPPER "${_ggml_backend_pfx}" _ggml_backend_pfx) 156 157 unset(${_ggml_backend_pfx}_LIBRARY CACHE) 158 find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend} 159 REQUIRED 160 HINTS ${GGML_LIB_DIR} 161 NO_CMAKE_FIND_ROOT_PATH) 162 163 message(STATUS "Found ${${_ggml_backend_pfx}_LIBRARY}") 164 165 add_library(ggml::${_ggml_backend} UNKNOWN IMPORTED) 166 set_target_properties(ggml::${_ggml_backend} 167 PROPERTIES 168 INTERFACE_INCLUDE_DIRECTORIES "${GGML_INCLUDE_DIR}" 169 IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" 170 IMPORTED_LOCATION "${${_ggml_backend_pfx}_LIBRARY}" 171 INTERFACE_COMPILE_FEATURES c_std_90 172 POSITION_INDEPENDENT_CODE ON) 173 174 string(REGEX MATCH "^ggml-cpu" is_cpu_variant "${_ggml_backend}") 175 if(is_cpu_variant) 176 list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES "ggml::ggml-base") 177 set_target_properties(ggml::${_ggml_backend} 178 PROPERTIES 179 INTERFACE_LINK_LIBRARIES "${GGML_CPU_INTERFACE_LINK_LIBRARIES}") 180 181 if(GGML_CPU_INTERFACE_LINK_OPTIONS) 182 set_target_properties(ggml::${_ggml_backend} 183 PROPERTIES 184 INTERFACE_LINK_OPTIONS "${GGML_CPU_INTERFACE_LINK_OPTIONS}") 185 endif() 186 187 else() 188 list(APPEND ${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES "ggml::ggml-base") 189 set_target_properties(ggml::${_ggml_backend} 190 PROPERTIES 191 INTERFACE_LINK_LIBRARIES "${${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES}") 192 193 if(${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS) 194 set_target_properties(ggml::${_ggml_backend} 195 PROPERTIES 196 INTERFACE_LINK_OPTIONS "${${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS}") 197 endif() 198 endif() 199 200 list(APPEND _ggml_all_targets ggml::${_ggml_backend}) 201 endforeach() 202 endif() 203 204 list(APPEND GGML_INTERFACE_LINK_LIBRARIES ggml::ggml-base "${_ggml_all_targets}") 205 set_target_properties(ggml::ggml 206 PROPERTIES 207 INTERFACE_LINK_LIBRARIES "${GGML_INTERFACE_LINK_LIBRARIES}") 208 209 add_library(ggml::all INTERFACE IMPORTED) 210 set_target_properties(ggml::all 211 PROPERTIES 212 INTERFACE_LINK_LIBRARIES "${_ggml_all_targets}") 213 214 endif() 215 216 check_required_components(ggml)