Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST)
# deploys from copying everything every build.
set(_prepare_aio_cmds)

# Ensure SKSE/Plugins dir exists and copy built plugin files
# Ensure SKSE/Plugins dir exists
# Note: DLL and PDB are copied via POST_BUILD command to avoid race conditions
list(
APPEND
_prepare_aio_cmds
Expand All @@ -342,26 +343,6 @@ if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST)
make_directory
"${AIO_DIR}/SKSE/Plugins"
)
list(
APPEND
_prepare_aio_cmds
COMMAND
${CMAKE_COMMAND}
-E
copy_if_different
$<TARGET_FILE:${PROJECT_NAME}>
"${AIO_DIR}/SKSE/Plugins/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
)
list(
APPEND
_prepare_aio_cmds
COMMAND
${CMAKE_COMMAND}
-E
copy_if_different
$<TARGET_PDB_FILE:${PROJECT_NAME}>
"${AIO_DIR}/SKSE/Plugins/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
)

# Copy package files
file(
Expand Down Expand Up @@ -454,6 +435,24 @@ if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/prepare_aio.stamp
)

# Copy DLL and PDB using POST_BUILD to avoid race conditions with file locking
# This ensures the linker has fully released the files before we attempt to copy them
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${AIO_DIR}/SKSE/Plugins"
COMMAND
${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:${PROJECT_NAME}>"
"${AIO_DIR}/SKSE/Plugins/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
COMMAND
${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_PDB_FILE:${PROJECT_NAME}>"
Comment thread
alandtse marked this conversation as resolved.
"${AIO_DIR}/SKSE/Plugins/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
COMMENT "Copying built DLL and PDB to AIO package"
VERBATIM
)
Comment thread
alandtse marked this conversation as resolved.

# Only copy shaders when HLSL files change; copy individually so unchanged
# files do not get their timestamps updated.
file(
Expand Down