From f44d1ddc8cf71e9d48fd9aa6633341fa11f395f9 Mon Sep 17 00:00:00 2001 From: Lucas Wilkinson Date: Tue, 3 Mar 2026 00:58:16 -0500 Subject: [PATCH] [BugFix] Fix cmake based incremental install (wrong vllm install dir) (#35773) Signed-off-by: Lucas Wilkinson Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> --- cmake/external_projects/vllm_flash_attn.cmake | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cmake/external_projects/vllm_flash_attn.cmake b/cmake/external_projects/vllm_flash_attn.cmake index c206b9c39..dd184e38e 100644 --- a/cmake/external_projects/vllm_flash_attn.cmake +++ b/cmake/external_projects/vllm_flash_attn.cmake @@ -46,24 +46,20 @@ else() ) endif() - -# Install rules for FA components need the install prefix nested under vllm/ -# These run at install time, before the FA library's own install rules -foreach(_FA_COMPONENT _vllm_fa2_C _vllm_fa3_C) - install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" COMPONENT ${_FA_COMPONENT}) - install(CODE "set(OLD_CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}\")" COMPONENT ${_FA_COMPONENT}) - install(CODE "set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/vllm/\")" COMPONENT ${_FA_COMPONENT}) -endforeach() +# Make sure vllm-flash-attn install rules are nested under vllm/ +# ALL_COMPONENTS ensures the save/modify/restore runs exactly once regardless +# of how many components are being installed, avoiding double-append of /vllm/. +install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" ALL_COMPONENTS) +install(CODE "set(OLD_CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS) +install(CODE "set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/vllm/\")" ALL_COMPONENTS) # Fetch the vllm-flash-attn library FetchContent_MakeAvailable(vllm-flash-attn) message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}") # Restore the install prefix after FA's install rules -foreach(_FA_COMPONENT _vllm_fa2_C _vllm_fa3_C) - install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" COMPONENT ${_FA_COMPONENT}) - install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" COMPONENT ${_FA_COMPONENT}) -endforeach() +install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS) +install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS) # Install shared Python files for both FA2 and FA3 components foreach(_FA_COMPONENT _vllm_fa2_C _vllm_fa3_C)