diff options
Diffstat (limited to 'cmake/modules/AddLLDB.cmake')
| -rw-r--r-- | cmake/modules/AddLLDB.cmake | 115 |
1 files changed, 70 insertions, 45 deletions
diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake index 129a5ef7500d..f7cac3dad837 100644 --- a/cmake/modules/AddLLDB.cmake +++ b/cmake/modules/AddLLDB.cmake @@ -44,21 +44,32 @@ function(add_lldb_library name) if (PARAM_OBJECT) add_library(${name} ${libkind} ${srcs}) else() - llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS - ${PARAM_LINK_LIBS} - DEPENDS ${PARAM_DEPENDS}) + if(LLDB_NO_INSTALL_DEFAULT_RPATH) + set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH) + endif() + + llvm_add_library(${name} ${libkind} ${srcs} + LINK_LIBS ${PARAM_LINK_LIBS} + DEPENDS ${PARAM_DEPENDS} + ${pass_NO_INSTALL_RPATH} + ) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb") if (PARAM_SHARED) - set(out_dir lib${LLVM_LIBDIR_SUFFIX}) if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK) - set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) + if(LLDB_FRAMEWORK_INSTALL_DIR) + set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) + else() + set(install_dir ".") + endif() + else() + set(install_dir lib${LLVM_LIBDIR_SUFFIX}) endif() install(TARGETS ${name} COMPONENT ${name} RUNTIME DESTINATION bin - LIBRARY DESTINATION ${out_dir} - ARCHIVE DESTINATION ${out_dir}) + LIBRARY DESTINATION ${install_dir} + ARCHIVE DESTINATION ${install_dir}) else() install(TARGETS ${name} COMPONENT ${name} @@ -67,12 +78,13 @@ function(add_lldb_library name) endif() if (NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} - DEPENDS ${name} + DEPENDS $<TARGET_FILE:${name}> COMPONENT ${name}) endif() endif() endif() + # Hack: only some LLDB libraries depend on the clang autogenerated headers, # but it is simple enough to make all of LLDB depend on some of those # headers without negatively impacting much of anything. @@ -86,59 +98,35 @@ endfunction(add_lldb_library) function(add_lldb_executable name) cmake_parse_arguments(ARG - "INCLUDE_IN_SUITE;GENERATE_INSTALL" - "" + "GENERATE_INSTALL" + "ENTITLEMENTS" "LINK_LIBS;LINK_COMPONENTS" ${ARGN} ) + if(LLDB_NO_INSTALL_DEFAULT_RPATH) + set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH) + endif() + list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS}) - add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}) + add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} + ENTITLEMENTS ${ARG_ENTITLEMENTS} + ${pass_NO_INSTALL_RPATH} + ) target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS}) - set_target_properties(${name} PROPERTIES - FOLDER "lldb executables") - - if(ARG_INCLUDE_IN_SUITE) - add_dependencies(lldb-suite ${name}) - if(LLDB_BUILD_FRAMEWORK) - if(NOT IOS) - set(resource_dir "/Resources") - set(resource_dots "../") - endif() - string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR}) - set_target_properties(${name} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:liblldb>${resource_dir} - BUILD_WITH_INSTALL_RPATH On - INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}") - endif() - endif() - - if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE) - set_target_properties(${name} PROPERTIES - BUILD_WITH_INSTALL_RPATH On - INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") - endif() + set_target_properties(${name} PROPERTIES FOLDER "lldb executables") if(ARG_GENERATE_INSTALL) - set(out_dir "bin") - if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE) - set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}) - endif() install(TARGETS ${name} - COMPONENT ${name} - RUNTIME DESTINATION ${out_dir}) + COMPONENT ${name} + RUNTIME DESTINATION bin) if (NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} DEPENDS ${name} COMPONENT ${name}) endif() endif() - - if(ARG_INCLUDE_IN_SUITE AND LLDB_BUILD_FRAMEWORK) - add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL - OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - endif() endfunction(add_lldb_executable) function(add_lldb_tool name) @@ -160,3 +148,40 @@ function(lldb_append_link_flags target_name new_link_flags) # Now set them onto the target. set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) endfunction() + +# For tools that depend on liblldb, account for varying directory structures in +# which LLDB.framework can be used and distributed: In the build-tree we find it +# by its absolute target path. This is only relevant for running the test suite. +# In the install step CMake will remove this entry and insert the final RPATHs. +# These are relative to the file path from where the tool will be loaded on the +# enduser system. +# +# Note that the LLVM install-tree doesn't match the enduser system structure +# for LLDB.framework, so by default dependent tools will not be functional in +# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix +# this. If specified, it causes the install-tree location of the framework to be +# added as an extra RPATH below. +# +function(lldb_setup_framework_rpaths_in_tool name) + # In the build-tree, we know the exact path to the binary in the framework. + set(rpath_build_tree "$<TARGET_FILE:liblldb>") + + # The installed framework is relocatable and can be in different locations. + set(rpaths_install_tree "@loader_path/../../../SharedFrameworks") + list(APPEND rpaths_install_tree "@loader_path/../../System/Library/PrivateFrameworks") + list(APPEND rpaths_install_tree "@loader_path/../../Library/PrivateFrameworks") + + if(LLDB_FRAMEWORK_INSTALL_DIR) + set(rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") + endif() + + # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites + # the default settings from llvm_setup_rpath(). + set_target_properties(${name} PROPERTIES + BUILD_WITH_INSTALL_RPATH OFF + BUILD_RPATH "${rpath_build_tree}" + INSTALL_RPATH "${rpaths_install_tree}" + ) + + add_dependencies(${name} lldb-framework) +endfunction() |
