Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 2 additions & 6 deletions llamacpp/native/src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ if (MINGW)
add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
endif()

set(TARGET_SRCS
server.cpp
utils.hpp
httplib.h
)
file(GLOB TARGET_SRCS "*.cpp")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using file(GLOB ...) to collect source files is generally discouraged in CMake. If you add or remove a source file, the build system won't automatically detect the change and re-run CMake, which can lead to build issues. It's more robust to list the source files explicitly.

set(TARGET_SRCS
    server.cpp
    server-common.cpp
    server-context.cpp
    server-http.cpp
    server-models.cpp
    server-queue.cpp
    server-task.cpp
)


add_executable(${TARGET} ${TARGET_SRCS})
install(TARGETS ${TARGET} RUNTIME)

target_include_directories(${TARGET} PRIVATE ../../vendor/llama.cpp/tools/mtmd)
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(${TARGET} PRIVATE common mtmd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE common mtmd ${CMAKE_THREAD_LIBS_INIT} cpp-httplib)

if (WIN32)
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
Expand Down
18 changes: 10 additions & 8 deletions llamacpp/native/src/server/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
LLAMA_SERVER_DIR = ../../vendor/llama.cpp/tools/server/
SERVER_FILES = server-common server-context server-http server-models server-queue server-task server
HEADERS = $(addsuffix .h, $(filter-out server, $(SERVER_FILES)))
SOURCES = $(addsuffix .cpp, $(SERVER_FILES))

.PHONY: clean all

all: utils.hpp server.cpp
all: $(HEADERS) $(SOURCES)

utils.hpp: $(LLAMA_SERVER_DIR)/utils.hpp
cp $(LLAMA_SERVER_DIR)/utils.hpp .
%.h: $(LLAMA_SERVER_DIR)/%.h
cp $< $@

server.cpp: $(LLAMA_SERVER_DIR)/server.cpp
cp $(LLAMA_SERVER_DIR)/server.cpp .
patch server.cpp < server.patch
%.cpp: $(LLAMA_SERVER_DIR)/%.cpp
cp $< $@
@if [ "$@" = "server-http.cpp" ]; then patch $@ < server-http.patch; fi

clean:
rm *.cpp
rm *.hpp
rm -f $(HEADERS) $(SOURCES)
Loading