1# mtmd
2
3find_package(Threads REQUIRED)
4
5add_library(mtmd
6 mtmd.cpp
7 mtmd-audio.cpp
8 mtmd.h
9 mtmd-helper.cpp
10 mtmd-helper.h
11 clip.cpp
12 clip.h
13 clip-impl.h
14 clip-model.h
15 clip-graph.h
16 models/models.h
17 models/cogvlm.cpp
18 models/conformer.cpp
19 models/glm4v.cpp
20 models/internvl.cpp
21 models/kimivl.cpp
22 models/kimik25.cpp
23 models/llama4.cpp
24 models/llava.cpp
25 models/minicpmv.cpp
26 models/pixtral.cpp
27 models/qwen2vl.cpp
28 models/qwen3vl.cpp
29 models/siglip.cpp
30 models/whisper-enc.cpp
31 models/mobilenetv5.cpp
32 models/youtuvl.cpp
33 )
34
35set_target_properties(mtmd PROPERTIES
36 VERSION ${LLAMA_INSTALL_VERSION}
37 SOVERSION 0
38 MACHO_CURRENT_VERSION 0 # keep macOS linker from seeing oversized version number
39)
40
41target_link_libraries (mtmd PUBLIC ggml llama)
42target_link_libraries (mtmd PRIVATE Threads::Threads)
43target_include_directories(mtmd PUBLIC .)
44target_include_directories(mtmd PRIVATE ../..)
45target_include_directories(mtmd PRIVATE ../../vendor)
46target_compile_features (mtmd PRIVATE cxx_std_17)
47
48if (BUILD_SHARED_LIBS)
49 set_target_properties (mtmd PROPERTIES POSITION_INDEPENDENT_CODE ON)
50 target_compile_definitions(mtmd PRIVATE LLAMA_BUILD)
51 target_compile_definitions(mtmd PUBLIC LLAMA_SHARED)
52endif()
53
54set(MTMD_PUBLIC_HEADERS
55 ${CMAKE_CURRENT_SOURCE_DIR}/mtmd.h
56 ${CMAKE_CURRENT_SOURCE_DIR}/mtmd-helper.h
57 )
58
59set_target_properties(mtmd
60 PROPERTIES
61 PUBLIC_HEADER "${MTMD_PUBLIC_HEADERS}")
62
63install(TARGETS mtmd LIBRARY PUBLIC_HEADER)
64
65if (NOT MSVC)
66 # for stb_image.h and miniaudio.h
67 target_compile_options(mtmd PRIVATE -Wno-cast-qual)
68endif()
69
70if (TARGET BUILD_INFO)
71 add_dependencies(mtmd BUILD_INFO)
72 add_dependencies(mtmd-helper BUILD_INFO)
73endif()
74
75# if mtmd is linked against common, we throw an error
76if (TARGET mtmd)
77 get_target_property(libs mtmd LINK_LIBRARIES)
78 if (libs AND "common" IN_LIST libs)
79 message(FATAL_ERROR "mtmd is designed to be a public library.\n"
80 "It must not link against common")
81 endif()
82endif()
83
84add_executable(llama-llava-cli deprecation-warning.cpp)
85add_executable(llama-gemma3-cli deprecation-warning.cpp)
86add_executable(llama-minicpmv-cli deprecation-warning.cpp)
87add_executable(llama-qwen2vl-cli deprecation-warning.cpp)
88
89set(TARGET llama-mtmd-cli)
90add_executable (${TARGET} mtmd-cli.cpp)
91set_target_properties (${TARGET} PROPERTIES OUTPUT_NAME llama-mtmd-cli)
92if(LLAMA_TOOLS_INSTALL)
93 install(TARGETS ${TARGET} RUNTIME)
94endif()
95target_link_libraries (${TARGET} PRIVATE common mtmd Threads::Threads)
96target_compile_features(${TARGET} PRIVATE cxx_std_17)