cmake : skip PCH for llama-server PCH when using MSVC (#28763)

This commit fixes an issue that I introduced when adding PCH
(precompiled headers) in Commit 3bcfeb700f
("cmake : add PCH and unity build to improve build times (#28091)".

See linked issue for details.

Co-authored-by: mjungnickel18
Co-authored-by: Pascal <admin@serveurperso.com>

Resolves: https://github.com/ggml-org/llama.cpp/issues/28758
Refs: https://github.com/ggml-org/llama.cpp/actions/runs/34592933983/job/103262608990#step:9:1284
This commit is contained in:
Daniel Bevenius
2026-09-11 21:36:52 +02:00
committed by GitHub
parent b78a39a2f9
commit 8ea290247c
+16 -2
View File
@@ -1,5 +1,13 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
# MSVC emits a PCH bookkeeping symbol that WINDOWS_EXPORT_ALL_SYMBOLS exports as an ambiguous "__"
set(LLAMA_SERVER_PCH ON)
if (BUILD_SHARED_LIBS AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(LLAMA_SERVER_PCH OFF)
endif()
# server-context containing the core server logic, used by llama-server and CLI
set(TARGET server-context)
@@ -32,7 +40,10 @@ endif()
target_include_directories(${TARGET} PRIVATE ../mtmd)
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(${TARGET} PUBLIC llama-common mtmd ${CMAKE_THREAD_LIBS_INIT})
target_precompile_headers(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/common/common.h)
if (LLAMA_SERVER_PCH)
target_precompile_headers(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/common/common.h)
endif()
# llama-server-impl: server logic, reusable by app
@@ -50,7 +61,10 @@ set_target_properties(${TARGET} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${TARGET} PRIVATE ../mtmd ${CMAKE_SOURCE_DIR})
target_link_libraries(${TARGET} PUBLIC server-context llama-ui cpp-httplib ${CMAKE_THREAD_LIBS_INIT})
target_precompile_headers(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/common/common.h)
if (LLAMA_SERVER_PCH)
target_precompile_headers(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/common/common.h)
endif()
add_dependencies(${TARGET} llama-ui-assets)