char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Daniel Beveniuscmake : remove precompiled headers (#28892)f3a184b15

char/aliceai-t5-moe
5.5 KiB164 linesraw
1# mtmd
2
3set(MTMD_VIDEO_HELP "enable video support in mtmd (requires ffmpeg binary in PATH)")
4
5set(MTMD_VIDEO ON CACHE BOOL "${MTMD_VIDEO_HELP}")
6# TODO: add MTMD_VIDEO_METHOD in the future to select between ffmpeg and other backends
7
8if (MTMD_VIDEO AND NOT LLAMA_SUBPROCESS)
9    message(STATUS "Disabling MTMD_VIDEO because LLAMA_SUBPROCESS is OFF")
10    set(MTMD_VIDEO OFF CACHE BOOL "${MTMD_VIDEO_HELP}" FORCE)
11endif()
12
13find_package(Threads REQUIRED)
14
15add_library(mtmd
16            mtmd.cpp
17            mtmd-audio.cpp
18            mtmd-image.cpp
19            mtmd.h
20            mtmd-internal.h
21            mtmd-helper.cpp
22            mtmd-helper-gen.cpp
23            mtmd-helper-common.h
24            mtmd-helper.h
25            clip.cpp
26            clip.h
27            clip-impl.h
28            clip-model.h
29            clip-graph.h
30            models/models.h
31            models/cogvlm.cpp
32            models/conformer.cpp
33            models/deepseek4v.cpp
34            models/dots3note.cpp
35            models/dotsocr.cpp
36            models/exaone4_5.cpp
37            models/gemma4a.cpp
38            models/gemma4v.cpp
39            models/gemma4ua.cpp
40            models/gemma4uv.cpp
41            models/glm4v.cpp
42            models/granite-speech.cpp
43            models/granite4-vision.cpp
44            models/hunyuanvl.cpp
45            models/internvl.cpp
46            models/kimivl.cpp
47            models/kimik25.cpp
48            models/nemotron-v2-vl.cpp
49            models/muse-glimmer.cpp
50            models/llama4.cpp
51            models/llava.cpp
52            models/minicpmv.cpp
53            models/paddleocr.cpp
54            models/pixtral.cpp
55            models/qwen2vl.cpp
56            models/minimax-m3.cpp
57            models/qwen3vl.cpp
58            models/mimovl.cpp
59            models/qwen3a.cpp
60            models/mimo-audio.cpp
61            models/qwen3tts-spkenc.cpp
62            models/qwen3tts-gen.cpp
63            models/pockettts-seanet.cpp
64            models/pockettts-spkenc.cpp
65            models/pockettts-gen.cpp
66            models/step3vl.cpp
67            models/siglip.cpp
68            models/whisper-enc.cpp
69            models/deepseekocr.cpp
70            models/deepseekocr2.cpp
71            models/mobilenetv5.cpp
72            models/youtuvl.cpp
73            models/yasa2.cpp
74            models/parakeet.cpp
75            )
76
77set_target_properties(mtmd PROPERTIES
78    VERSION ${LLAMA_VERSION_BASE}
79    SOVERSION ${LLAMA_VERSION_MAJOR}
80    MACHO_CURRENT_VERSION 0 # keep macOS linker from seeing oversized version number
81)
82
83target_link_libraries     (mtmd PUBLIC ggml llama)
84target_link_libraries     (mtmd PRIVATE Threads::Threads vendor::hash vendor::miniaudio vendor::stb vendor::sheredom)
85target_include_directories(mtmd PUBLIC  .)
86target_compile_features   (mtmd PRIVATE cxx_std_17)
87
88if (MTMD_VIDEO)
89    target_compile_definitions(mtmd PRIVATE MTMD_VIDEO)
90endif()
91
92if (BUILD_SHARED_LIBS)
93    set_target_properties     (mtmd PROPERTIES POSITION_INDEPENDENT_CODE ON)
94    target_compile_definitions(mtmd PRIVATE LLAMA_BUILD)
95    target_compile_definitions(mtmd PUBLIC  LLAMA_SHARED)
96
97    # export all symbols so that internal components can be tested by test-mtmd-impl
98    set_target_properties     (mtmd PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
99endif()
100
101set(MTMD_PUBLIC_HEADERS
102    ${CMAKE_CURRENT_SOURCE_DIR}/mtmd.h
103    ${CMAKE_CURRENT_SOURCE_DIR}/mtmd-helper.h
104    )
105
106set_target_properties(mtmd
107    PROPERTIES
108    PUBLIC_HEADER "${MTMD_PUBLIC_HEADERS}")
109
110set_target_properties(mtmd
111    PROPERTIES
112    PRIVATE_HEADER debug/mtmd-debug.h)
113
114install(TARGETS mtmd LIBRARY PUBLIC_HEADER)
115
116if (NOT MSVC)
117    # for stb_image.h and miniaudio.h
118    target_compile_options(mtmd PRIVATE -Wno-cast-qual)
119endif()
120
121if (ANDROID)
122    # miniaudio.h defines ma_android_sdk_version() without a prior prototype
123    target_compile_options(mtmd PRIVATE -Wno-missing-prototypes)
124endif()
125
126if (TARGET BUILD_INFO)
127    add_dependencies(mtmd        BUILD_INFO)
128    add_dependencies(mtmd-helper BUILD_INFO)
129endif()
130
131# if mtmd is linked against llama-common, we throw an error
132if (TARGET mtmd)
133    get_target_property(libs mtmd LINK_LIBRARIES)
134    if (libs AND "llama-common" IN_LIST libs)
135        message(FATAL_ERROR "mtmd is designed to be a public library.\n"
136                            "It must not link against llama-common")
137    endif()
138endif()
139
140# Gate CLI binaries on LLAMA_BUILD_TOOLS so that standalone library-only
141# builds (LLAMA_BUILD_MTMD=ON with LLAMA_BUILD_TOOLS=OFF — e.g. Apple
142# XCFramework packaging) skip the executables entirely. LLAMA_BUILD_COMMON
143# defaults to ON in standalone builds, so we cannot rely on it for gating.
144if (LLAMA_BUILD_TOOLS)
145    add_executable(llama-llava-cli    deprecation-warning.cpp)
146    add_executable(llama-gemma3-cli   deprecation-warning.cpp)
147    add_executable(llama-minicpmv-cli deprecation-warning.cpp)
148    add_executable(llama-qwen2vl-cli  deprecation-warning.cpp)
149
150    set(TARGET llama-mtmd-cli)
151    add_executable         (${TARGET} mtmd-cli.cpp)
152    set_target_properties  (${TARGET} PROPERTIES OUTPUT_NAME llama-mtmd-cli)
153    if(LLAMA_TOOLS_INSTALL)
154        install(TARGETS ${TARGET} RUNTIME)
155    endif()
156    target_link_libraries  (${TARGET} PRIVATE llama-common mtmd Threads::Threads)
157    target_compile_features(${TARGET} PRIVATE cxx_std_17)
158
159    # mtmd-debug tool
160    add_executable(llama-mtmd-debug debug/mtmd-debug.cpp)
161    set_target_properties(llama-mtmd-debug PROPERTIES OUTPUT_NAME llama-mtmd-debug)
162    target_link_libraries(llama-mtmd-debug PRIVATE llama-common mtmd Threads::Threads)
163    target_compile_features(llama-mtmd-debug PRIVATE cxx_std_17)
164endif()