Skip to content

Commit 1715896

Browse files
authored
mtmd: explicitly forbidden inclusion of private header and libcommon (#17946)
1 parent 12280ae commit 1715896

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

tools/mtmd/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ if (TARGET BUILD_INFO)
5353
add_dependencies(mtmd-helper BUILD_INFO)
5454
endif()
5555

56+
# if mtmd is linked against common, we throw an error
57+
if (TARGET mtmd)
58+
get_target_property(libs mtmd LINK_LIBRARIES)
59+
if (libs AND "common" IN_LIST libs)
60+
message(FATAL_ERROR "mtmd is designed to be a public library.\n"
61+
"It must not link against common")
62+
endif()
63+
endif()
64+
5665
add_executable(llama-llava-cli deprecation-warning.cpp)
5766
add_executable(llama-gemma3-cli deprecation-warning.cpp)
5867
add_executable(llama-minicpmv-cli deprecation-warning.cpp)

tools/mtmd/clip-impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
// Internal header for clip.cpp
1515

16+
#define MTMD_INTERNAL_HEADER
17+
1618
#define KEY_FTYPE "general.file_type"
1719
#define KEY_NAME "general.name"
1820
#define KEY_DESCRIPTION "general.description"

tools/mtmd/clip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
// !!! Internal header, to be used by mtmd only !!!
99

10+
#define MTMD_INTERNAL_HEADER
11+
1012
struct clip_ctx;
1113

1214
struct clip_image_size {

tools/mtmd/mtmd-audio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <vector>
77
#include <string>
88

9+
#define MTMD_INTERNAL_HEADER
10+
911
#define WHISPER_ASSERT GGML_ASSERT
1012

1113
#define WHISPER_SAMPLE_RATE 16000

tools/mtmd/mtmd-helper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#define STB_IMAGE_IMPLEMENTATION
3333
#include "stb/stb_image.h"
3434

35+
#ifdef MTMD_INTERNAL_HEADER
36+
#error "mtmd-helper is a public library outside of mtmd. it must not include internal headers"
37+
#endif
38+
3539
//
3640
// internal logging functions
3741
//

0 commit comments

Comments
 (0)