Skip to content

Commit 51c24c9

Browse files
[Build] Fix FetchContent multiple build issue (vllm-project#9596)
Signed-off-by: luka <[email protected]>
1 parent 831540c commit 51c24c9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ endif()
169169

170170
#
171171
# Use FetchContent for C++ dependencies that are compiled as part of vLLM's build process.
172-
# Configure it to place files in vllm/.deps, in order to play nicely with sccache.
172+
# setup.py will override FETCHCONTENT_BASE_DIR to play nicely with sccache.
173+
# Each dependency that produces build artifacts should override its BINARY_DIR to avoid
174+
# conflicts between build types. It should instead be set to ${CMAKE_BINARY_DIR}/<dependency>.
173175
#
174176
include(FetchContent)
175-
get_filename_component(PROJECT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
176-
file(MAKE_DIRECTORY "${FETCHCONTENT_BASE_DIR}")
177-
set(FETCHCONTENT_BASE_DIR "${PROJECT_ROOT_DIR}/.deps")
177+
file(MAKE_DIRECTORY ${FETCHCONTENT_BASE_DIR}) # Ensure the directory exists
178178
message(STATUS "FetchContent base directory: ${FETCHCONTENT_BASE_DIR}")
179179

180180
#
@@ -509,6 +509,8 @@ else()
509509
GIT_REPOSITORY https://github.com/vllm-project/flash-attention.git
510510
GIT_TAG 013f0c4fc47e6574060879d9734c1df8c5c273bd
511511
GIT_PROGRESS TRUE
512+
# Don't share the vllm-flash-attn build between build types
513+
BINARY_DIR ${CMAKE_BINARY_DIR}/vllm-flash-attn
512514
)
513515
endif()
514516

setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ def configure(self, ext: CMakeExtension) -> None:
157157
# on subsequent calls to python.
158158
cmake_args += ['-DVLLM_PYTHON_PATH={}'.format(":".join(sys.path))]
159159

160+
# Override the base directory for FetchContent downloads to $ROOT/.deps
161+
# This allows sharing dependencies between profiles,
162+
# and plays more nicely with sccache.
163+
# To override this, set the FETCHCONTENT_BASE_DIR environment variable.
164+
fc_base_dir = os.path.join(ROOT_DIR, ".deps")
165+
fc_base_dir = os.environ.get("FETCHCONTENT_BASE_DIR", fc_base_dir)
166+
cmake_args += ['-DFETCHCONTENT_BASE_DIR={}'.format(fc_base_dir)]
167+
160168
#
161169
# Setup parallelism and build tool
162170
#

0 commit comments

Comments
 (0)