forked from johnmai-dev/ANE-LM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
94 lines (77 loc) · 1.96 KB
/
Copy pathCMakeLists.txt
File metadata and controls
94 lines (77 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
cmake_minimum_required(VERSION 3.20)
project(ane.cpp VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# macOS deployment target
set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0" CACHE STRING "Minimum macOS deployment target")
# Use new Accelerate LAPACK API
add_compile_definitions(ACCELERATE_NEW_LAPACK)
# Fetch dependencies
include(FetchContent)
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
)
FetchContent_Declare(
tokenizers_cpp
GIT_REPOSITORY https://github.com/mlc-ai/tokenizers-cpp.git
GIT_TAG main
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(json tokenizers_cpp)
# Include paths
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR})
# Source files
set(VENDOR_SOURCES
vendor/jinja/value.cpp
vendor/jinja/string.cpp
vendor/jinja/lexer.cpp
vendor/jinja/parser.cpp
vendor/jinja/runtime.cpp
vendor/jinja/caps.cpp
)
set(CORE_SOURCES
common.cpp
core/safetensors.cpp
core/model_loader.cpp
core/tokenizer.cpp
core/cpu_ops.cpp
core/sampling.cpp
core/ane_runtime.cpp
utils.cpp
generate.cpp
)
set(MODEL_SOURCES
models/llm/qwen3_5.cpp
models/llm/qwen3.cpp
)
set(MAIN_SOURCE
main.cpp
)
# Executable
add_executable(ane_cpp
${VENDOR_SOURCES}
${CORE_SOURCES}
${MODEL_SOURCES}
${MAIN_SOURCE}
)
set_target_properties(ane_cpp PROPERTIES OUTPUT_NAME "ane.cpp")
# Link frameworks and ObjC runtime
target_link_libraries(ane_cpp PRIVATE
nlohmann_json::nlohmann_json
tokenizers_cpp
"-framework Foundation"
"-framework IOSurface"
"-framework Accelerate"
"-lobjc"
)
# Optimization for release
target_compile_options(ane_cpp PRIVATE
$<$<CONFIG:Release>:-O3>
$<$<CONFIG:RelWithDebInfo>:-O2 -g>
)
# Default to Release if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()