From 9055a49bc5b43a407946115ec08734c1d7fd024b Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Thu, 23 Oct 2025 11:45:41 +0200 Subject: [PATCH 1/4] misc(windows): use proper INSTALL target to generate correct layout --- scripts/windows/builder.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/windows/builder.ps1 b/scripts/windows/builder.ps1 index bf0e0618..329bd5cd 100644 --- a/scripts/windows/builder.ps1 +++ b/scripts/windows/builder.ps1 @@ -365,7 +365,9 @@ function Invoke-CMakeTarget { ) Write-Status "Running $DisplayName..." -Type Info - cmake --build . --target $Target --config $BuildConfig + + # Use cmake --build with proper escaping for Visual Studio generator + cmake --build . --config $BuildConfig --target $Target if ($LASTEXITCODE -ne 0) { throw "$DisplayName failed with exit code $LASTEXITCODE" @@ -420,7 +422,7 @@ function Invoke-CMakeBuild { # Run install targets if requested if ($RunLocalInstall) { - Invoke-CMakeTarget -Target 'local_install' -BuildConfig $BuildConfig -DisplayName 'install target (local development layout)' + Invoke-CMakeTarget -Target 'INSTALL' -BuildConfig $BuildConfig -DisplayName 'install target (local development layout)' } if ($RunKernelsInstall) { From c91cde3cbbb4ce17e5e82c7215ffaa8b63d030b9 Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Thu, 23 Oct 2025 14:48:28 +0200 Subject: [PATCH 2/4] misc(windows): use correct cmake parameter order --- scripts/windows/builder.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/windows/builder.ps1 b/scripts/windows/builder.ps1 index 329bd5cd..0747ee3e 100644 --- a/scripts/windows/builder.ps1 +++ b/scripts/windows/builder.ps1 @@ -420,13 +420,13 @@ function Invoke-CMakeBuild { Write-Status "Build completed successfully!" -Type Success - # Run install targets if requested + # Run install target if requested if ($RunLocalInstall) { Invoke-CMakeTarget -Target 'INSTALL' -BuildConfig $BuildConfig -DisplayName 'install target (local development layout)' } if ($RunKernelsInstall) { - Invoke-CMakeTarget -Target 'kernels_install' -BuildConfig $BuildConfig -DisplayName 'kernels_install target' + Invoke-CMakeTarget -Target 'INSTALL' -BuildConfig $BuildConfig -DisplayName 'install target' } } finally { From cea480bb5fde4779ea0884a5c236171c7eaaabb8 Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Thu, 23 Oct 2025 17:18:49 +0200 Subject: [PATCH 3/4] misc(windows): make sure to expose platform in rendering args --- build2cmake/src/templates/windows.cmake | 47 ++++++++++--------------- build2cmake/src/torch/cuda.rs | 1 + build2cmake/src/torch/xpu.rs | 1 + 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/build2cmake/src/templates/windows.cmake b/build2cmake/src/templates/windows.cmake index 948bd643..85fb029e 100644 --- a/build2cmake/src/templates/windows.cmake +++ b/build2cmake/src/templates/windows.cmake @@ -103,36 +103,27 @@ function(add_kernels_install_target TARGET_NAME PACKAGE_NAME BUILD_VARIANT_NAME) set(ARG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") endif() - # Create the kernels_install target if it doesn't exist - if(NOT TARGET kernels_install) - add_custom_target(kernels_install ALL - COMMENT "Installing all kernels to hub-compatible layout" - VERBATIM) - endif() - - # Create a custom target for this specific kernel - set(KERNEL_INSTALL_TARGET "${TARGET_NAME}_kernel_install") + # Set the installation directory set(KERNEL_INSTALL_DIR "${ARG_INSTALL_PREFIX}/${BUILD_VARIANT_NAME}/${PACKAGE_NAME}") - add_custom_target(${KERNEL_INSTALL_TARGET} ALL - COMMAND ${CMAKE_COMMAND} -E make_directory "${KERNEL_INSTALL_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy $ "${KERNEL_INSTALL_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_SOURCE_DIR}/torch-ext/${PACKAGE_NAME}" - "${KERNEL_INSTALL_DIR}/" - DEPENDS ${TARGET_NAME} - COMMENT "Installing ${TARGET_NAME} to ${KERNEL_INSTALL_DIR}" - VERBATIM) - - # Make kernels_install depend on this specific kernel's install - add_dependencies(kernels_install ${KERNEL_INSTALL_TARGET}) - - # Set folder for IDE organization - if(MSVC OR XCODE) - set_target_properties(${KERNEL_INSTALL_TARGET} PROPERTIES FOLDER "Install") - endif() + message(STATUS "Using PACKAGE_NAME: ${PACKAGE_NAME}") + + # Install the compiled extension using CMake's install() command + # This will be triggered by the standard INSTALL target + install(TARGETS ${TARGET_NAME} + LIBRARY DESTINATION "${KERNEL_INSTALL_DIR}" + RUNTIME DESTINATION "${KERNEL_INSTALL_DIR}" + COMPONENT ${TARGET_NAME}) - message(STATUS "Added kernels_install target for ${TARGET_NAME} -> ${BUILD_VARIANT_NAME}/${PACKAGE_NAME}") + # Glob Python files to install + file(GLOB PYTHON_FILES "${CMAKE_SOURCE_DIR}/torch-ext/${PACKAGE_NAME}/*.py") + + # Install Python files (__init__.py and _ops.py) + install(FILES ${PYTHON_FILES} + DESTINATION "${KERNEL_INSTALL_DIR}" + COMPONENT ${TARGET_NAME}) + + message(STATUS "Added install rules for ${TARGET_NAME} -> ${BUILD_VARIANT_NAME}/${PACKAGE_NAME}") endfunction() # @@ -181,4 +172,4 @@ function(add_local_install_target TARGET_NAME PACKAGE_NAME BUILD_VARIANT_NAME) file(MAKE_DIRECTORY ${LOCAL_INSTALL_DIR}) message(STATUS "Added install rules for ${TARGET_NAME} -> build/${BUILD_VARIANT_NAME}/${PACKAGE_NAME}") -endfunction() \ No newline at end of file +endfunction() diff --git a/build2cmake/src/torch/cuda.rs b/build2cmake/src/torch/cuda.rs index 65fdb082..267fe576 100644 --- a/build2cmake/src/torch/cuda.rs +++ b/build2cmake/src/torch/cuda.rs @@ -384,6 +384,7 @@ pub fn render_extension( context! { name => name, ops_name => ops_name, + platform => std::env::consts::OS, }, &mut *write, ) diff --git a/build2cmake/src/torch/xpu.rs b/build2cmake/src/torch/xpu.rs index e7c44672..41bd4518 100644 --- a/build2cmake/src/torch/xpu.rs +++ b/build2cmake/src/torch/xpu.rs @@ -262,6 +262,7 @@ pub fn render_extension( context! { name => name, ops_name => ops_name, + platform => std::env::consts::OS }, &mut *write, ) From 5c13dcebdd196702ed0c1ec56a5228fef48e7399 Mon Sep 17 00:00:00 2001 From: medmekk Date: Fri, 24 Oct 2025 09:39:12 +0000 Subject: [PATCH 4/4] chore: trigger ci