Index: lldb/cmake/modules/AddLLDB.cmake =================================================================== --- lldb/cmake/modules/AddLLDB.cmake +++ lldb/cmake/modules/AddLLDB.cmake @@ -243,6 +243,15 @@ COMMAND ${CMAKE_COMMAND} -E copy $ ${copy_dest} COMMENT "Copy ${name} to ${copy_dest}" ) + + # Create a target to remove the target again before the install phase. We + # intentionally use remove_directory because the target can be a directory + # and it's harmless for files. + add_custom_target(${name}-cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory ${copy_dest} + COMMENT "Removing ${name} from LLDB.framework") + add_dependencies(lldb-framework-cleanup + ${name}-cleanup) endfunction() # Add extra install steps for dSYM creation and stripping for the given target. Index: lldb/cmake/modules/LLDBConfig.cmake =================================================================== --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -101,6 +101,13 @@ # Essentially, emit the framework's dSYM outside of the framework directory. set(LLDB_DEBUGINFO_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)") + + # Custom target to remove the tools (binaries) that were copied into + # LLDB.framework in the build tree. These binaries need to be removed because + # otherwise they're copied as part of the install phase of the framework + # without getting their RPATHs fixed up. + add_custom_target(lldb-framework-cleanup + COMMENT "Cleaning up build-tree frameworks in preparation for install") endif() if(APPLE AND CMAKE_GENERATOR STREQUAL Xcode)