Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions tools/mtmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_library(mtmd OBJECT
clip-impl.h
)

set(MTMD_PUBLIC_HEADERS
"mtmd.h"
"clip.h")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clip.h is not a public header, we should remove it


target_link_libraries(mtmd PRIVATE ggml llama ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(mtmd PUBLIC .)
target_include_directories(mtmd PRIVATE ../..)
Expand All @@ -21,6 +25,9 @@ add_library(mtmd_helper OBJECT
mtmd-helper.h
)

set(MTMD_HELPER_PUBLIC_HEADERS
"mtmd-helper.h")

target_link_libraries(mtmd_helper PRIVATE ggml llama mtmd ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(mtmd_helper PUBLIC .)
target_include_directories(mtmd_helper PRIVATE ./vendor)
Expand All @@ -32,13 +39,22 @@ if (BUILD_SHARED_LIBS)
target_compile_definitions(mtmd PRIVATE LLAMA_SHARED LLAMA_BUILD)
add_library(mtmd_shared SHARED $<TARGET_OBJECTS:mtmd>)
target_link_libraries(mtmd_shared PRIVATE ggml llama ${CMAKE_THREAD_LIBS_INIT})
install(TARGETS mtmd_shared LIBRARY)
set_target_properties(mtmd_shared PROPERTIES PUBLIC_HEADER "${MTMD_PUBLIC_HEADERS}")
install(TARGETS mtmd_shared LIBRARY PUBLIC_HEADER)

set_target_properties(mtmd_helper PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(mtmd_helper PRIVATE LLAMA_SHARED LLAMA_BUILD)
add_library(mtmd_helper_shared SHARED $<TARGET_OBJECTS:mtmd>)
add_library(mtmd_helper_shared SHARED $<TARGET_OBJECTS:mtmd_helper>)
target_link_libraries(mtmd_helper_shared PRIVATE ggml llama mtmd ${CMAKE_THREAD_LIBS_INIT})
install(TARGETS mtmd_helper_shared LIBRARY)
set_target_properties(mtmd_helper_shared PROPERTIES PUBLIC_HEADER "${MTMD_HELPER_PUBLIC_HEADERS}")
install(TARGETS mtmd_helper_shared LIBRARY PUBLIC_HEADER)
else()
add_library(mtmd_static STATIC $<TARGET_OBJECTS:mtmd>)
set_target_properties(mtmd_static PROPERTIES PUBLIC_HEADER "${MTMD_PUBLIC_HEADERS}")
add_library(mtmd_helper_static STATIC $<TARGET_OBJECTS:mtmd_helper>)
set_target_properties(mtmd_helper_static PROPERTIES PUBLIC_HEADER "${MTMD_HELPER_PUBLIC_HEADERS}")
install(TARGETS mtmd_static LIBRARY PUBLIC_HEADER PUBLIC_HEADER)
install(TARGETS mtmd_helper_static LIBRARY PUBLIC_HEADER)
Comment on lines +51 to +57
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be redundant. If anything in the project need mtmd_helper, we can simply link the target binary with it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example:

target_link_libraries(${TARGET} PRIVATE common mtmd mtmd_helper ${CMAKE_THREAD_LIBS_INIT})

So, nothing need to be STATIC

endif()

if (NOT MSVC)
Expand Down
Loading