From de9a04027fea1fb526597d983eba9a0a1de6661d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 26 Jul 2019 15:35:59 +0800 Subject: [PATCH] cmake/modules/Distutils: do not add ${name}-clone if already added if `distutils_install_module("foo" ...)` is called mutiple times with different python version, `foo-clone` will be added multiple times as a custom target. which is not allowed: add_custom_target cannot create target "foo-clone" because another target with the same name already exists. Signed-off-by: Kefu Chai --- cmake/modules/Distutils.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index d664fa814bde8..3275fa5117456 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -11,8 +11,10 @@ function(distutils_install_module name) COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${src}) endif() endforeach() - add_custom_target(${name}-clone ALL - DEPENDS ${py_clone}) + if(NOT TARGET ${name}-clone) + add_custom_target(${name}-clone ALL + DEPENDS ${py_clone}) + endif() cmake_parse_arguments(DU "" "INSTALL_SCRIPT;PYTHON_VERSION" "" ${ARGN}) if(DU_PYTHON_VERSION) set(python_version ${DU_PYTHON_VERSION}) -- 2.39.5