okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
508e6999a
main
1include ( CheckCXXCompilerFlag ) 2include ( "../cmake/common.cmake" ) 3 4add_compile_definitions ( GGML_SCHED_MAX_COPIES= ${ GGML_SCHED_MAX_COPIES }) 5 6# enable libstdc++ assertions for debug builds 7if ( CMAKE_SYSTEM_NAMEMATCHES "Linux" ) 8add_compile_definitions ( $< $ <CONFIG:Debug>:_GLIBCXX_ASSERTIONS> ) 9endif () 10 11if ( NOT MSVC) 12if ( GGML_SANITIZE_THREAD) 13add_compile_options ( -fsanitize=thread ) 14link_libraries ( -fsanitize=thread ) 15endif () 16 17if ( GGML_SANITIZE_ADDRESS) 18add_compile_options ( -fsanitize=address -fno-omit-frame-pointer ) 19link_libraries ( -fsanitize=address ) 20endif () 21 22if ( GGML_SANITIZE_UNDEFINED) 23add_compile_options ( -fsanitize=undefined ) 24link_libraries ( -fsanitize=undefined ) 25endif () 26endif () 27 28if ( GGML_FATAL_WARNINGS) 29if ( CMAKE_CXX_COMPILER_IDMATCHES "GNU" OR CMAKE_CXX_COMPILER_IDMATCHES "Clang" ) 30list ( APPEND C_FLAGS -Werror ) 31list ( APPEND CXX_FLAGS -Werror ) 32elseif ( CMAKE_CXX_COMPILER_IDSTREQUAL "MSVC" ) 33add_compile_options ( /WX ) 34endif () 35endif () 36 37if ( GGML_ALL_WARNINGS) 38if ( NOT MSVC) 39list ( APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function ) 40list ( APPEND C_FLAGS -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes 41-Werror=implicit-int -Werror=implicit-function-declaration ) 42list ( APPEND CXX_FLAGS -Wmissing-declarations -Wmissing-noreturn ) 43 44list ( APPEND C_FLAGS ${ WARNING_FLAGS }) 45list ( APPEND CXX_FLAGS ${ WARNING_FLAGS }) 46 47ggml_get_flags ( $ { CMAKE_CXX_COMPILER_ID } ${ CMAKE_CXX_COMPILER_VERSION }) 48 49add_compile_options ( " $ < $ <COMPILE_LANGUAGE:C>: ${ C_FLAGS } ; ${ GF_C_FLAGS } >" 50" $ < $ <COMPILE_LANGUAGE:CXX>: ${ CXX_FLAGS } ; ${ GF_CXX_FLAGS } >" ) 51else () 52# todo : msvc 53set ( C_FLAGS "" ) 54set ( CXX_FLAGS "" ) 55endif () 56endif () 57 58if ( GGML_LTO) 59include ( CheckIPOSupported ) 60check_ipo_supported ( RESULT result OUTPUT output ) 61if ( result) 62set ( CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE ) 63else () 64message ( WARNING "IPO is not supported: ${ output } " ) 65endif () 66endif () 67 68if ( GGML_CCACHEAND NOT CMAKE_C_COMPILER_LAUNCHERAND NOT CMAKE_CXX_COMPILER_LAUNCHER) 69find_program ( GGML_CCACHE_FOUND ccache ) 70find_program ( GGML_SCCACHE_FOUND sccache ) 71 72if ( GGML_CCACHE_FOUNDOR GGML_SCCACHE_FOUND) 73if ( GGML_CCACHE_FOUND) 74set ( GGML_CCACHE_VARIANT ccache ) 75else () 76set ( GGML_CCACHE_VARIANT sccache ) 77endif () 78# TODO: should not be set globally 79if ( GGML_SYCLAND GGML_CCACHE_FOUNDAND WIN32) 80set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache compiler_type=icl" ) 81else () 82set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE " ${ GGML_CCACHE_VARIANT } " ) 83endif () 84set ( ENV{CCACHE_SLOPPINESS} time_macros ) 85message ( STATUS " ${ GGML_CCACHE_VARIANT } found, compilation results will be cached. Disable with GGML_CCACHE=OFF." ) 86else () 87message ( STATUS "Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF" ) 88endif () 89endif () 90 91# this version of Apple ld64 is buggy 92execute_process ( 93COMMAND ${ CMAKE_C_COMPILER } ${ CMAKE_EXE_LINKER_FLAGS } -Wl,-v 94ERROR_VARIABLE output 95OUTPUT_QUIET 96) 97 98if ( outputMATCHES "dyld-1015\.7" ) 99add_compile_definitions ( HAVE_BUGGY_APPLE_LINKER ) 100endif () 101 102# architecture specific 103# TODO: probably these flags need to be tweaked on some architectures 104# feel free to update the Makefile for your architecture and send a pull request or issue 105message ( STATUS "CMAKE_SYSTEM_PROCESSOR: ${ CMAKE_SYSTEM_PROCESSOR } " ) 106if ( MSVC) 107string ( TOLOWER " ${ CMAKE_GENERATOR_PLATFORM } " CMAKE_GENERATOR_PLATFORM_LWR ) 108message ( STATUS "CMAKE_GENERATOR_PLATFORM: ${ CMAKE_GENERATOR_PLATFORM } " ) 109else () 110set ( CMAKE_GENERATOR_PLATFORM_LWR "" ) 111endif () 112ggml_get_system_arch () 113message ( STATUS "GGML_SYSTEM_ARCH: ${ GGML_SYSTEM_ARCH } " ) 114 115if ( NOT MSVC) 116if ( GGML_STATIC) 117if ( UNIXAND NOT APPLE) 118set ( CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so" ) 119endif () 120add_link_options ( -static ) 121if ( MINGW) 122add_link_options ( -static-libgcc -static-libstdc++ ) 123endif () 124endif () 125if ( GGML_GPROF) 126add_compile_options ( -pg ) 127endif () 128endif () 129 130# 131# POSIX conformance 132# 133 134# clock_gettime came in POSIX.1b (1993) 135# CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional 136# posix_memalign came in POSIX.1-2001 / SUSv3 137# M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985) 138 139# Somehow in OpenBSD whenever POSIX conformance is specified 140# some string functions rely on locale_t availability, 141# which was introduced in POSIX.1-2008, forcing us to go higher 142if ( CMAKE_SYSTEM_NAMEMATCHES "OpenBSD" ) 143add_compile_definitions ( _XOPEN_SOURCE=700 ) 144elseif ( CMAKE_SYSTEM_NAMEMATCHES "AIX" ) 145# Don't define _XOPEN_SOURCE. We need _ALL_SOURCE, which is the default, 146# in order to define _SC_PHYS_PAGES. 147else () 148add_compile_definitions ( _XOPEN_SOURCE=600 ) 149endif () 150 151# Data types, macros and functions related to controlling CPU affinity and 152# some memory allocation are available on Linux through GNU extensions in libc 153if ( CMAKE_SYSTEM_NAMEMATCHES "Linux" OR CMAKE_SYSTEM_NAMEMATCHES "Android" ) 154add_compile_definitions ( _GNU_SOURCE ) 155endif () 156 157# RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1, 158# and on macOS its availability depends on enabling Darwin extensions 159# similarly on DragonFly, enabling BSD extensions is necessary 160if ( 161 CMAKE_SYSTEM_NAMEMATCHES "Darwin" OR 162 CMAKE_SYSTEM_NAMEMATCHES "iOS" OR 163 CMAKE_SYSTEM_NAMEMATCHES "tvOS" OR 164 CMAKE_SYSTEM_NAMEMATCHES "DragonFly" 165) 166add_compile_definitions ( _DARWIN_C_SOURCE ) 167endif () 168 169# alloca is a non-standard interface that is not visible on BSDs when 170# POSIX conformance is specified, but not all of them provide a clean way 171# to enable it in such cases 172if ( CMAKE_SYSTEM_NAMEMATCHES "FreeBSD" ) 173add_compile_definitions ( __BSD_VISIBLE ) 174endif () 175if ( CMAKE_SYSTEM_NAMEMATCHES "NetBSD" ) 176add_compile_definitions ( _NETBSD_SOURCE ) 177endif () 178if ( CMAKE_SYSTEM_NAMEMATCHES "OpenBSD" ) 179add_compile_definitions ( _BSD_SOURCE ) 180endif () 181 182if ( WIN32) 183add_compile_definitions ( _CRT_SECURE_NO_WARNINGS ) 184endif () 185 186# ggml 187 188if ( GGML_BACKEND_DLAND NOT BUILD_SHARED_LIBS) 189message ( FATAL_ERROR "GGML_BACKEND_DL requires BUILD_SHARED_LIBS" ) 190endif () 191 192add_library ( ggml-base 193../include/ggml.h 194../include/ggml-alloc.h 195../include/ggml-backend.h 196../include/ggml-cpp.h 197../include/ggml-opt.h 198../include/gguf.h 199ggml.c 200ggml.cpp 201ggml-alloc.c 202ggml-backend.cpp 203ggml-backend-meta.cpp 204ggml-opt.cpp 205ggml-threading.cpp 206ggml-threading.h 207ggml-quants.c 208ggml-quants.h 209gguf.cpp ) 210 211set_target_properties ( ggml-base PROPERTIES 212VERSION ${ GGML_VERSION } 213SOVERSION ${ GGML_VERSION_MAJOR } 214) 215 216configure_file ( ggml-version.h.in ${ CMAKE_CURRENT_BINARY_DIR } /ggml-version.h @ONLY ) 217 218target_include_directories ( ggml-base PRIVATE . ${ CMAKE_CURRENT_BINARY_DIR }) 219if ( GGML_BACKEND_DL) 220target_compile_definitions ( ggml-base PUBLIC GGML_BACKEND_DL ) 221endif () 222 223if ( GGML_SCHED_NO_REALLOC) 224target_compile_definitions ( ggml-base PUBLIC GGML_SCHED_NO_REALLOC ) 225endif () 226 227if ( GGML_OPENMP_FETCH) 228if ( NOT GGML_OPENMP) 229message ( FATAL_ERROR "GGML_OPENMP_FETCH requires GGML_OPENMP" ) 230elseif ( NOT WIN32OR NOT ( CMAKE_C_COMPILER_IDMATCHES "Clang" )) 231message ( FATAL_ERROR "GGML_OPENMP_FETCH currently requires Clang on Windows" ) 232endif () 233 234set ( GGML_OPENMP_LLVM_VERSION "20.1.8" ) 235string ( REGEX MATCH "^[0-9]+" GGML_OPENMP_LLVM_VERSION_MAJOR " ${ GGML_OPENMP_LLVM_VERSION } " ) 236string ( REGEX MATCH "^[0-9]+" GGML_OPENMP_COMPILER_VERSION_MAJOR " ${ CMAKE_C_COMPILER_VERSION } " ) 237if ( NOT GGML_OPENMP_COMPILER_VERSION_MAJORSTREQUAL GGML_OPENMP_LLVM_VERSION_MAJOR) 238message ( FATAL_ERROR "LLVM OpenMP ${ GGML_OPENMP_LLVM_VERSION } requires Clang ${ GGML_OPENMP_LLVM_VERSION_MAJOR } .x" ) 239endif () 240 241string ( TOLOWER " ${ CMAKE_SYSTEM_PROCESSOR } " GGML_OPENMP_SYSTEM_PROCESSOR ) 242if ( GGML_OPENMP_SYSTEM_PROCESSORMATCHES "^(amd64|x86_64) $ " ) 243set ( GGML_OPENMP_ARCH "x64" ) 244set ( GGML_OPENMP_INSTALLER_SUFFIX "win64" ) 245set ( GGML_OPENMP_INSTALLER_SHA256 "3197846a2b19063687dd56e93e34cd941e3548d907f23a6131571321bdf9fe7b" ) 246elseif ( GGML_OPENMP_SYSTEM_PROCESSORMATCHES "^(aarch64|arm64) $ " ) 247set ( GGML_OPENMP_ARCH "arm64" ) 248set ( GGML_OPENMP_INSTALLER_SUFFIX "woa64" ) 249set ( GGML_OPENMP_INSTALLER_SHA256 "7c4ac97eb2ae6b960ca5f9caf3ff6124c8d2a18cc07a7840a4d2ea15537bad8e" ) 250else () 251message ( FATAL_ERROR "GGML_OPENMP_FETCH does not support ${ CMAKE_SYSTEM_PROCESSOR } " ) 252endif () 253 254set ( GGML_OPENMP_CACHE_DIR " ${ CMAKE_BINARY_DIR } /_deps" ) 255set ( GGML_OPENMP_ROOT " ${ GGML_OPENMP_CACHE_DIR } /llvm-openmp- ${ GGML_OPENMP_LLVM_VERSION } - ${ GGML_OPENMP_ARCH } " ) 256set ( GGML_OPENMP_LIBRARY " ${ GGML_OPENMP_ROOT } /lib/libomp.lib" ) 257set ( GGML_OPENMP_RUNTIME " ${ GGML_OPENMP_ROOT } /bin/libomp.dll" ) 258set ( GGML_OPENMP_HEADER " ${ GGML_OPENMP_ROOT } /include/omp.h" ) 259set ( GGML_OPENMP_LICENSE " ${ GGML_OPENMP_ROOT } /LICENSE.TXT" ) 260set ( GGML_OPENMP_LICENSE_SHA256 "fdad1758a9e1f9d5a81e18879b3406772115edc92c24bfa36b70c654f325e8e4" ) 261 262if ( NOT EXISTS " ${ GGML_OPENMP_LIBRARY } " OR NOT EXISTS " ${ GGML_OPENMP_RUNTIME } " OR NOT EXISTS " ${ GGML_OPENMP_HEADER } " ) 263find_program ( GGML_OPENMP_7Z NAMES 7z 7zz 7za ) 264if ( NOT GGML_OPENMP_7Z) 265message ( FATAL_ERROR "GGML_OPENMP_FETCH requires 7-Zip to extract the LLVM installer" ) 266endif () 267 268set ( GGML_OPENMP_INSTALLER " ${ GGML_OPENMP_ROOT } /LLVM- ${ GGML_OPENMP_LLVM_VERSION } - ${ GGML_OPENMP_INSTALLER_SUFFIX } .exe" ) 269set ( GGML_OPENMP_EXTRACT_DIR " ${ GGML_OPENMP_ROOT } /extract" ) 270set ( GGML_OPENMP_INSTALLER_URL "https://github.com/llvm/llvm-project/releases/download/llvmorg- ${ GGML_OPENMP_LLVM_VERSION } /LLVM- ${ GGML_OPENMP_LLVM_VERSION } - ${ GGML_OPENMP_INSTALLER_SUFFIX } .exe" ) 271 272file ( MAKE_DIRECTORY " ${ GGML_OPENMP_EXTRACT_DIR } " ) 273file ( DOWNLOAD " ${ GGML_OPENMP_INSTALLER_URL } " " ${ GGML_OPENMP_INSTALLER } " 274EXPECTED_HASH "SHA256= ${ GGML_OPENMP_INSTALLER_SHA256 } " 275SHOW_PROGRESS 276STATUS GGML_OPENMP_DOWNLOAD_STATUS ) 277list ( GET GGML_OPENMP_DOWNLOAD_STATUS 0 GGML_OPENMP_DOWNLOAD_RESULT ) 278if ( NOT GGML_OPENMP_DOWNLOAD_RESULTEQUAL 0 ) 279list ( GET GGML_OPENMP_DOWNLOAD_STATUS 1 GGML_OPENMP_DOWNLOAD_ERROR ) 280message ( FATAL_ERROR "Failed to download LLVM OpenMP: ${ GGML_OPENMP_DOWNLOAD_ERROR } " ) 281endif () 282 283execute_process ( 284COMMAND " ${ GGML_OPENMP_7Z } " e -y "-o ${ GGML_OPENMP_EXTRACT_DIR } " " ${ GGML_OPENMP_INSTALLER } " -r libomp.lib libomp.dll omp.h 285RESULT_VARIABLE GGML_OPENMP_EXTRACT_RESULT 286OUTPUT_QUIET ) 287if ( NOT GGML_OPENMP_EXTRACT_RESULTEQUAL 0 OR 288NOT EXISTS " ${ GGML_OPENMP_EXTRACT_DIR } /libomp.lib" OR 289NOT EXISTS " ${ GGML_OPENMP_EXTRACT_DIR } /libomp.dll" OR 290NOT EXISTS " ${ GGML_OPENMP_EXTRACT_DIR } /omp.h" ) 291message ( FATAL_ERROR "Failed to extract libomp from ${ GGML_OPENMP_INSTALLER } " ) 292endif () 293 294file ( MAKE_DIRECTORY " ${ GGML_OPENMP_ROOT } /lib" " ${ GGML_OPENMP_ROOT } /bin" " ${ GGML_OPENMP_ROOT } /include" ) 295file ( COPY " ${ GGML_OPENMP_EXTRACT_DIR } /libomp.lib" DESTINATION " ${ GGML_OPENMP_ROOT } /lib" ) 296file ( COPY " ${ GGML_OPENMP_EXTRACT_DIR } /libomp.dll" DESTINATION " ${ GGML_OPENMP_ROOT } /bin" ) 297file ( COPY " ${ GGML_OPENMP_EXTRACT_DIR } /omp.h" DESTINATION " ${ GGML_OPENMP_ROOT } /include" ) 298file ( REMOVE_RECURSE " ${ GGML_OPENMP_INSTALLER } " " ${ GGML_OPENMP_EXTRACT_DIR } " ) 299endif () 300 301# The NSIS installer embeds LLVM's general license in its UI but does not install it as a file; use OpenMP's license to include its additional notices. 302if ( EXISTS " ${ GGML_OPENMP_LICENSE } " ) 303file ( SHA256 " ${ GGML_OPENMP_LICENSE } " GGML_OPENMP_LICENSE_ACTUAL_SHA256 ) 304endif () 305if ( NOT GGML_OPENMP_LICENSE_ACTUAL_SHA256STREQUAL GGML_OPENMP_LICENSE_SHA256) 306file ( DOWNLOAD "https://raw.githubusercontent.com/llvm/llvm-project/llvmorg- ${ GGML_OPENMP_LLVM_VERSION } /openmp/LICENSE.TXT" " ${ GGML_OPENMP_LICENSE } " 307EXPECTED_HASH "SHA256= ${ GGML_OPENMP_LICENSE_SHA256 } " ) 308endif () 309 310if ( COMMAND license_add_file) 311license_add_file ( "LLVM OpenMP" " ${ GGML_OPENMP_LICENSE } " ) 312endif () 313 314add_library ( ggml-openmp-c INTERFACE ) 315target_compile_options ( ggml-openmp-c INTERFACE " $ < $ <COMPILE_LANGUAGE:C>:-fopenmp=libomp>" ) 316target_include_directories ( ggml-openmp-c SYSTEM INTERFACE " ${ GGML_OPENMP_ROOT } /include" ) 317target_link_libraries ( ggml-openmp-c INTERFACE " ${ GGML_OPENMP_LIBRARY } " ) 318 319add_library ( ggml-openmp-cxx INTERFACE ) 320target_compile_options ( ggml-openmp-cxx INTERFACE " $ < $ <COMPILE_LANGUAGE:CXX>:-fopenmp=libomp>" ) 321target_include_directories ( ggml-openmp-cxx SYSTEM INTERFACE " ${ GGML_OPENMP_ROOT } /include" ) 322target_link_libraries ( ggml-openmp-cxx INTERFACE " ${ GGML_OPENMP_LIBRARY } " ) 323 324set ( GGML_OPENMP_RUNTIME_OUTPUT_DIR " ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } " ) 325if ( CMAKE_CONFIGURATION_TYPES) 326string ( APPEND GGML_OPENMP_RUNTIME_OUTPUT_DIR "/ $ <CONFIG>" ) 327endif () 328add_custom_target ( ggml-openmp-runtime ALL 329COMMAND ${ CMAKE_COMMAND } -E make_directory " ${ GGML_OPENMP_RUNTIME_OUTPUT_DIR } " 330COMMAND ${ CMAKE_COMMAND } -E copy_if_different " ${ GGML_OPENMP_RUNTIME } " " ${ GGML_OPENMP_RUNTIME_OUTPUT_DIR } /libomp.dll" 331COMMAND ${ CMAKE_COMMAND } -E copy_if_different " ${ GGML_OPENMP_LICENSE } " " ${ GGML_OPENMP_RUNTIME_OUTPUT_DIR } /LICENSE-LLVM-OpenMP" ) 332add_dependencies ( ggml-base ggml-openmp-runtime ) 333install ( FILES " ${ GGML_OPENMP_RUNTIME } " DESTINATION ${ CMAKE_INSTALL_BINDIR }) 334install ( FILES " ${ GGML_OPENMP_LICENSE } " DESTINATION ${ CMAKE_INSTALL_BINDIR } RENAME LICENSE-LLVM-OpenMP ) 335 336set ( GGML_OPENMP_TARGET_C ggml-openmp-c ) 337set ( GGML_OPENMP_TARGET_CXX ggml-openmp-cxx ) 338set ( GGML_OPENMP_ENABLED "ON" CACHE INTERNAL "" ) 339elseif ( GGML_OPENMP) 340find_package ( OpenMP ) 341if ( OpenMP_FOUND) 342set ( GGML_OPENMP_TARGET_C OpenMP::OpenMP_C ) 343set ( GGML_OPENMP_TARGET_CXX OpenMP::OpenMP_CXX ) 344set ( GGML_OPENMP_ENABLED "ON" CACHE INTERNAL "" ) 345else () 346set ( GGML_OPENMP_ENABLED "OFF" CACHE INTERNAL "" ) 347message ( WARNING "OpenMP not found" ) 348endif () 349else () 350set ( GGML_OPENMP_ENABLED "OFF" CACHE INTERNAL "" ) 351endif () 352 353if ( GGML_OPENMP_ENABLED) 354target_compile_definitions ( ggml-base PRIVATE GGML_USE_OPENMP ) 355target_link_libraries ( ggml-base PRIVATE ${ GGML_OPENMP_TARGET_C } ${ GGML_OPENMP_TARGET_CXX }) 356endif () 357 358 359function ( ggml_add_backend_library backend ) 360if ( GGML_BACKEND_DL) 361message ( FATAL_ERROR "GGML_BACKEND_DL: dynamic backends are not part of the vendored ggml (third_party/strata-ggml)" ) 362endif () 363add_library ( $ { backend } ${ ARGN }) 364 365target_link_libraries ( $ { backend } PRIVATE ggml-base ) 366target_include_directories ( $ { backend } PRIVATE .. ) 367 368if (${ BUILD_SHARED_LIBS }) 369target_compile_definitions ( $ { backend } PRIVATE GGML_BACKEND_BUILD ) 370target_compile_definitions ( $ { backend } PUBLIC GGML_BACKEND_SHARED ) 371endif () 372 373set_target_properties ( $ { backend } PROPERTIES 374VERSION ${ GGML_VERSION } 375SOVERSION ${ GGML_VERSION_MAJOR } 376) 377endfunction () 378 379if ( GGML_CPU_ALL_VARIANTS) 380message ( FATAL_ERROR "GGML_CPU_ALL_VARIANTS: the all-variants CPU build is not part of the vendored ggml (third_party/strata-ggml)" ) 381endif () 382 383if ( GGML_CPU) 384add_subdirectory ( ggml-cpu ) 385ggml_add_cpu_backend_variant_impl ( "" ) 386endif () 387 388target_include_directories ( ggml-base PUBLIC $ <BUILD_INTERFACE: ${ CMAKE_CURRENT_SOURCE_DIR } /../include> $ <INSTALL_INTERFACE:include> ) 389target_compile_features ( ggml-base PRIVATE c_std_11 cxx_std_17 ) # don't bump 390 391target_link_libraries ( ggml-base PRIVATE Threads::Threads ) 392 393if ( DEFINED MATH_LIBRARY) 394target_link_libraries ( ggml-base PRIVATE ${ MATH_LIBRARY }) 395elseif ( NOT WIN32AND NOT DEFINED ENV{ONEAPI_ROOT}) 396target_link_libraries ( ggml-base PRIVATE m ) 397endif () 398 399if ( CMAKE_SYSTEM_NAMEMATCHES "Android" ) 400target_link_libraries ( ggml-base PRIVATE dl ) 401endif () 402 403if ( CMAKE_SYSTEM_NAMEMATCHES "visionOS" ) 404target_compile_definitions ( ggml-base PUBLIC _DARWIN_C_SOURCE ) 405endif () 406 407if ( BUILD_SHARED_LIBS) 408set_target_properties ( ggml-base PROPERTIES POSITION_INDEPENDENT_CODE ON ) 409target_compile_definitions ( ggml-base PRIVATE GGML_BUILD ) 410target_compile_definitions ( ggml-base PUBLIC GGML_SHARED ) 411endif ()