mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 12:24:53 +00:00
feat: Fix Cmakelist to allow building on Darwin platform
This commit is contained in:
parent
6c5a75b593
commit
d4e65bfe7b
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
project(tgi-llama-cpp-backend VERSION 1.0.0)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
@ -10,13 +11,18 @@ set(LLAMA_CPP_TARGET_CUDA_ARCHS "75-real;80-real;86-real;89-real;90-real" CACHE
|
||||
option(LLAMA_CPP_BUILD_OFFLINE_RUNNER "Flag to build the standalone c++ backend runner")
|
||||
option(LLAMA_CPP_BUILD_CUDA "Flag to build CUDA enabled inference through llama.cpp")
|
||||
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin"))
|
||||
message(STATUS "Targeting libc++")
|
||||
set(CMAKE_CXX_FLAGS -stdlib=libc++ ${CMAKE_CXX_FLAGS})
|
||||
else ()
|
||||
message(STATUS "Not using libc++ ${CMAKE_CXX_COMPILER_ID} ${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
|
||||
# add linker options for Darwin
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L$HOMEBREW_PREFIX/opt/llvm/lib/c++ -L$HOMEBREW_PREFIX/opt/llvm/lib/unwind -lunwind")
|
||||
endif ()
|
||||
|
||||
# Add dependencies
|
||||
include(cmake/numa.cmake)
|
||||
include(cmake/spdlog.cmake)
|
||||
|
17
backends/llamacpp/README.md
Normal file
17
backends/llamacpp/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
## Compiling with MacOS
|
||||
|
||||
To compile the Llama.cpp backend on MacOS, you need to install `clang` and `cmake` via Homebrew:
|
||||
|
||||
```bash
|
||||
brew install llvm cmake
|
||||
```
|
||||
|
||||
You then need to configure CMakelists.txt to use the newly installed clang compiler.
|
||||
You can do this by configuring your IDE or adding the following lines to the top of the file:
|
||||
|
||||
```cmake
|
||||
set(CMAKE_C_COMPILER /opt/homebrew/opt/llvm/bin/clang)
|
||||
set(CMAKE_CXX_COMPILER /opt/homebrew/opt/llvm/bin/clang++)
|
||||
```
|
||||
|
||||
CMakelist.txt assumes that Homebrew installs libc++ in `$HOMEBREW_PREFIX/opt/llvm/lib/c++`.
|
Loading…
Reference in New Issue
Block a user