From f3564aa1e8d30dda91354a68f29a5b5dee774a94 Mon Sep 17 00:00:00 2001 From: littlemine Date: Fri, 27 Sep 2024 21:16:10 +0800 Subject: [PATCH] avoid repeated copy --- projects/CUDA/CMakeLists.txt | 50 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/projects/CUDA/CMakeLists.txt b/projects/CUDA/CMakeLists.txt index b753132791..6a5a9063c2 100644 --- a/projects/CUDA/CMakeLists.txt +++ b/projects/CUDA/CMakeLists.txt @@ -99,20 +99,21 @@ if (ZS_PYTHON_FOUND AND ZENO_WITH_PyZpc) if (WIN32) cmake_path(GET ZS_OVERWRITE_PYTHON_EXECUTABLE PARENT_PATH PYTHON_ENV_PATH) message(STATUS "python3 parent: ${PYTHON_ENV_PATH}") - add_custom_command( - TARGET copy_py - POST_BUILD - # COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/lib ${RESOURCE_BASE_DIR}/lib - # COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/dlls ${RESOURCE_BASE_DIR}/dlls - COMMAND ${CMAKE_COMMAND} - -DOBJECTS=${PYTHON_ENV_PATH}/Lib - -DOUTPUT=${RESOURCE_BASE_DIR} - -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_dir.cmake - - COMMAND ${CMAKE_COMMAND} - -DOBJECTS=${PYTHON_ENV_PATH}/DLLs - -DOUTPUT=${RESOURCE_BASE_DIR} - -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_dir.cmake + if (NOT EXISTS ${RESOURCE_BASE_DIR}/Lib/site-packages) + add_custom_command( + TARGET copy_py + POST_BUILD + # COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/lib ${RESOURCE_BASE_DIR}/lib + # COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/dlls ${RESOURCE_BASE_DIR}/dlls + COMMAND ${CMAKE_COMMAND} + -DOBJECTS=${PYTHON_ENV_PATH}/Lib + -DOUTPUT=${RESOURCE_BASE_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_dir.cmake + + COMMAND ${CMAKE_COMMAND} + -DOBJECTS=${PYTHON_ENV_PATH}/DLLs + -DOUTPUT=${RESOURCE_BASE_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_dir.cmake # COMMAND ${CMAKE_COMMAND} # -DOBJECTS=${PYTHON_ENV_PATH}/library @@ -125,8 +126,9 @@ if (ZS_PYTHON_FOUND AND ZENO_WITH_PyZpc) # -DOUTPUT=$ # -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_dll.cmake - COMMENT "copying python lib directories at ${PYTHON_ENV_PATH} to ${RESOURCE_BASE_DIR}" - ) + COMMENT "copying python lib directories at ${PYTHON_ENV_PATH} to ${RESOURCE_BASE_DIR}" + ) + endif() if (EXISTS ${PYTHON_ENV_PATH}/library) add_custom_command( TARGET copy_py @@ -154,14 +156,16 @@ if (ZS_PYTHON_FOUND AND ZENO_WITH_PyZpc) cmake_path(GET ZS_OVERWRITE_PYTHON_EXECUTABLE PARENT_PATH PYTHON_ENV_PATH) cmake_path(GET PYTHON_ENV_PATH PARENT_PATH PYTHON_ENV_PATH) message(STATUS "python3 parent: ${PYTHON_ENV_PATH}") - add_custom_command( - TARGET copy_py - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/bin ${RESOURCE_BASE_DIR}/bin - COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/lib ${RESOURCE_BASE_DIR}/lib + if (NOT EXISTS ${RESOURCE_BASE_DIR}/lib/libtinfo.a) + add_custom_command( + TARGET copy_py + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/bin ${RESOURCE_BASE_DIR}/bin + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_ENV_PATH}/lib ${RESOURCE_BASE_DIR}/lib - COMMENT "copying python lib directory ${PYTHON_ENV_PATH}/lib to ${RESOURCE_BASE_DIR}/lib" - ) + COMMENT "copying python lib directory ${PYTHON_ENV_PATH}/lib to ${RESOURCE_BASE_DIR}/lib" + ) + endif() endif() # prepare zpc headers for pyzpc