diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -165,16 +165,19 @@ endif() set(python_scripts_target "lldb-python-scripts") set(python_scripts_install_target "install-${python_scripts_target}") - add_custom_target(${python_scripts_target}) + # This function might be called multiple times but we only need to create the custom target once. + if (NOT TARGET ${python_scripts_target}) + add_custom_target(${python_scripts_target}) + if (NOT LLVM_ENABLE_IDE) + add_llvm_install_targets(${python_scripts_install_target} + COMPONENT ${python_scripts_target} + DEPENDS ${python_scripts_target}) + endif() + endif() add_dependencies(${python_scripts_target} ${swig_target}) install(DIRECTORY ${lldb_python_target_dir}/../ DESTINATION ${LLDB_PYTHON_INSTALL_PATH} COMPONENT ${python_scripts_target}) - if (NOT LLVM_ENABLE_IDE) - add_llvm_install_targets(${python_scripts_install_target} - COMPONENT ${python_scripts_target} - DEPENDS ${python_scripts_target}) - endif() # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching # lldb.exe or any other executables that were linked with liblldb.