diff --git a/lldb/bindings/lua/CMakeLists.txt b/lldb/bindings/lua/CMakeLists.txt index 677a07044c2af..9b9af28b7588f 100644 --- a/lldb/bindings/lua/CMakeLists.txt +++ b/lldb/bindings/lua/CMakeLists.txt @@ -64,6 +64,17 @@ function(finish_swig_lua swig_target lldb_lua_bindings_dir lldb_lua_target_dir) add_llvm_install_targets(${lldb_lua_library_install_target} COMPONENT ${lldb_lua_library_target} DEPENDS ${lldb_lua_library_target}) + # Tools that link liblldb need the lua bindings installed alongside. + # The list is populated by add_lldb_executable. + get_property(lldb_liblldb_tools GLOBAL PROPERTY LLDB_TOOLS_LINKING_LIBLLDB) + foreach(tool ${lldb_liblldb_tools}) + if(TARGET install-${tool}) + add_dependencies(install-${tool} ${lldb_lua_library_install_target}) + endif() + if(TARGET install-${tool}-stripped AND TARGET ${lldb_lua_library_install_target}-stripped) + add_dependencies(install-${tool}-stripped ${lldb_lua_library_install_target}-stripped) + endif() + endforeach() endif() endfunction() diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index 04457dfd32e3c..c0d01ce4e65ce 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -187,6 +187,17 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar add_llvm_install_targets(${python_scripts_install_target} COMPONENT ${python_scripts_target} DEPENDS ${python_scripts_target}) + # Tools that link liblldb need the python scripts installed alongside. + # The list is populated by add_lldb_executable. + get_property(lldb_liblldb_tools GLOBAL PROPERTY LLDB_TOOLS_LINKING_LIBLLDB) + foreach(tool ${lldb_liblldb_tools}) + if(TARGET install-${tool}) + add_dependencies(install-${tool} ${python_scripts_install_target}) + endif() + if(TARGET install-${tool}-stripped AND TARGET ${python_scripts_install_target}-stripped) + add_dependencies(install-${tool}-stripped ${python_scripts_install_target}-stripped) + endif() + endforeach() 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 diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 93b6bd2740abb..74068ce7acc3c 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -36,6 +36,30 @@ function(lldb_tablegen) endif() endfunction(lldb_tablegen) +# Returns TRUE in `out_var` if any of `libs` is `liblldb` or already carries +# the LLDB_LINKS_LIBLLDB property. +function(_lldb_links_liblldb_check out_var libs) + set(${out_var} FALSE PARENT_SCOPE) + foreach(lib ${libs}) + if("${lib}" STREQUAL "liblldb") + set(${out_var} TRUE PARENT_SCOPE) + return() + endif() + if(TARGET "${lib}") + get_target_property(_p "${lib}" LLDB_LINKS_LIBLLDB) + if(_p) + set(${out_var} TRUE PARENT_SCOPE) + return() + endif() + endif() + endforeach() +endfunction() + +function(_lldb_propagate_links_liblldb name libs) + _lldb_links_liblldb_check(_links_liblldb "${libs}") + set_target_properties(${name} PROPERTIES LLDB_LINKS_LIBLLDB ${_links_liblldb}) +endfunction() + function(add_lldb_library name) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} @@ -95,6 +119,9 @@ function(add_lldb_library name) ${pass_NO_INSTALL_RPATH} ) + # Mark whether this library transitively pulls in liblldb. + _lldb_propagate_links_liblldb(${name} "${PARAM_LINK_LIBS}") + if(CLANG_LINK_CLANG_DYLIB) target_link_libraries(${name} PRIVATE clang-cpp) else() @@ -220,6 +247,20 @@ function(add_lldb_executable name) add_llvm_install_targets(install-${name} DEPENDS ${name} COMPONENT ${name}) + # An installed tool that links liblldb won't run without liblldb + # installed alongside it. Record it on a global list so other + # runtime components (e.g. the Python/Lua script packages) can + # attach themselves to the same install targets. + _lldb_links_liblldb_check(_links_liblldb "${ARG_LINK_LIBS}") + if(_links_liblldb) + set_property(GLOBAL APPEND PROPERTY LLDB_TOOLS_LINKING_LIBLLDB ${name}) + if(TARGET install-liblldb) + add_dependencies(install-${name} install-liblldb) + if(TARGET install-${name}-stripped AND TARGET install-liblldb-stripped) + add_dependencies(install-${name}-stripped install-liblldb-stripped) + endif() + endif() + endif() endif() if(APPLE AND ARG_INSTALL_PREFIX) lldb_add_post_install_steps_darwin(${name} ${ARG_INSTALL_PREFIX})