Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit cea480b

Browse files
committed
misc(windows): make sure to expose platform in rendering args
1 parent c91cde3 commit cea480b

3 files changed

Lines changed: 21 additions & 28 deletions

File tree

build2cmake/src/templates/windows.cmake

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,27 @@ function(add_kernels_install_target TARGET_NAME PACKAGE_NAME BUILD_VARIANT_NAME)
103103
set(ARG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
104104
endif()
105105

106-
# Create the kernels_install target if it doesn't exist
107-
if(NOT TARGET kernels_install)
108-
add_custom_target(kernels_install ALL
109-
COMMENT "Installing all kernels to hub-compatible layout"
110-
VERBATIM)
111-
endif()
112-
113-
# Create a custom target for this specific kernel
114-
set(KERNEL_INSTALL_TARGET "${TARGET_NAME}_kernel_install")
106+
# Set the installation directory
115107
set(KERNEL_INSTALL_DIR "${ARG_INSTALL_PREFIX}/${BUILD_VARIANT_NAME}/${PACKAGE_NAME}")
116108

117-
add_custom_target(${KERNEL_INSTALL_TARGET} ALL
118-
COMMAND ${CMAKE_COMMAND} -E make_directory "${KERNEL_INSTALL_DIR}"
119-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGET_NAME}> "${KERNEL_INSTALL_DIR}/"
120-
COMMAND ${CMAKE_COMMAND} -E copy_directory
121-
"${CMAKE_SOURCE_DIR}/torch-ext/${PACKAGE_NAME}"
122-
"${KERNEL_INSTALL_DIR}/"
123-
DEPENDS ${TARGET_NAME}
124-
COMMENT "Installing ${TARGET_NAME} to ${KERNEL_INSTALL_DIR}"
125-
VERBATIM)
126-
127-
# Make kernels_install depend on this specific kernel's install
128-
add_dependencies(kernels_install ${KERNEL_INSTALL_TARGET})
129-
130-
# Set folder for IDE organization
131-
if(MSVC OR XCODE)
132-
set_target_properties(${KERNEL_INSTALL_TARGET} PROPERTIES FOLDER "Install")
133-
endif()
109+
message(STATUS "Using PACKAGE_NAME: ${PACKAGE_NAME}")
110+
111+
# Install the compiled extension using CMake's install() command
112+
# This will be triggered by the standard INSTALL target
113+
install(TARGETS ${TARGET_NAME}
114+
LIBRARY DESTINATION "${KERNEL_INSTALL_DIR}"
115+
RUNTIME DESTINATION "${KERNEL_INSTALL_DIR}"
116+
COMPONENT ${TARGET_NAME})
134117

135-
message(STATUS "Added kernels_install target for ${TARGET_NAME} -> ${BUILD_VARIANT_NAME}/${PACKAGE_NAME}")
118+
# Glob Python files to install
119+
file(GLOB PYTHON_FILES "${CMAKE_SOURCE_DIR}/torch-ext/${PACKAGE_NAME}/*.py")
120+
121+
# Install Python files (__init__.py and _ops.py)
122+
install(FILES ${PYTHON_FILES}
123+
DESTINATION "${KERNEL_INSTALL_DIR}"
124+
COMPONENT ${TARGET_NAME})
125+
126+
message(STATUS "Added install rules for ${TARGET_NAME} -> ${BUILD_VARIANT_NAME}/${PACKAGE_NAME}")
136127
endfunction()
137128

138129
#
@@ -181,4 +172,4 @@ function(add_local_install_target TARGET_NAME PACKAGE_NAME BUILD_VARIANT_NAME)
181172

182173
file(MAKE_DIRECTORY ${LOCAL_INSTALL_DIR})
183174
message(STATUS "Added install rules for ${TARGET_NAME} -> build/${BUILD_VARIANT_NAME}/${PACKAGE_NAME}")
184-
endfunction()
175+
endfunction()

build2cmake/src/torch/cuda.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ pub fn render_extension(
384384
context! {
385385
name => name,
386386
ops_name => ops_name,
387+
platform => std::env::consts::OS,
387388
},
388389
&mut *write,
389390
)

build2cmake/src/torch/xpu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ pub fn render_extension(
262262
context! {
263263
name => name,
264264
ops_name => ops_name,
265+
platform => std::env::consts::OS
265266
},
266267
&mut *write,
267268
)

0 commit comments

Comments
 (0)