Index: lldb/trunk/CMakeLists.txt =================================================================== --- lldb/trunk/CMakeLists.txt +++ lldb/trunk/CMakeLists.txt @@ -151,6 +151,10 @@ list(APPEND LLDB_TEST_DEPS dsymutil) endif() + if(TARGET lldb-framework) + list(APPEND LLDB_TEST_DEPS lldb-framework) + endif() + add_custom_target(lldb-test-deps) add_dependencies(lldb-test-deps ${LLDB_TEST_DEPS}) set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc") Index: lldb/trunk/cmake/modules/AddLLDB.cmake =================================================================== --- lldb/trunk/cmake/modules/AddLLDB.cmake +++ lldb/trunk/cmake/modules/AddLLDB.cmake @@ -208,3 +208,32 @@ add_dependencies(${name} lldb-framework) endfunction() + +# Unified handling for executable LLDB.framework resources. Given the name of an +# executable target, this function adds a post-build step to copy it to the +# framework bundle in the build-tree. +function(lldb_add_to_framework name) + set(subdir "LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources") + + # Destination for the copy in the build-tree. While the framework target may + # not exist yet, it will exist when the generator expression gets expanded. + set(copy_dest "$/../../../${subdir}") + + # Copy into the framework's Resources directory for testing. + add_custom_command(TARGET ${name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${copy_dest} + COMMENT "Copy ${name} to ${copy_dest}" + ) +endfunction() + +# CMake's set_target_properties() doesn't allow to pass lists for RPATH +# properties directly (error: "called with incorrect number of arguments"). +# Instead of defining two list variables each time, use this helper function. +function(lldb_setup_rpaths name) + cmake_parse_arguments(LIST "" "" "BUILD_RPATH;INSTALL_RPATH" ${ARGN}) + set_target_properties(${name} PROPERTIES + BUILD_WITH_INSTALL_RPATH OFF + BUILD_RPATH "${LIST_BUILD_RPATH}" + INSTALL_RPATH "${LIST_INSTALL_RPATH}" + ) +endfunction() \ No newline at end of file Index: lldb/trunk/cmake/modules/LLDBConfig.cmake =================================================================== --- lldb/trunk/cmake/modules/LLDBConfig.cmake +++ lldb/trunk/cmake/modules/LLDBConfig.cmake @@ -64,8 +64,6 @@ set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)") set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework") set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework") - set(LLDB_FRAMEWORK_TOOLS darwin-debug;debugserver;lldb-argdumper;lldb-server CACHE STRING - "List of tools to include in LLDB.framework/Resources") # Set designated directory for all dSYMs. Essentially, this emits the # framework's dSYM outside of the framework directory. Index: lldb/trunk/cmake/modules/LLDBFramework.cmake =================================================================== --- lldb/trunk/cmake/modules/LLDBFramework.cmake +++ lldb/trunk/cmake/modules/LLDBFramework.cmake @@ -36,22 +36,9 @@ endif() # Target to capture extra steps for a fully functional framework bundle. -add_custom_target(lldb-framework) +add_custom_target(lldb-framework ALL) add_dependencies(lldb-framework liblldb) -# Dependencies are defined once tools are added (see AddLLDB.cmake) -if(LLDB_FRAMEWORK_TOOLS) - message(STATUS "LLDB.framework: adding tools ${LLDB_FRAMEWORK_TOOLS}") - foreach(tool ${LLDB_FRAMEWORK_TOOLS}) - add_custom_command(TARGET lldb-framework POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $/Resources - COMMENT "LLDB.framework: copy additional tool ${tool}" - ) - endforeach() -else() - message(WARNING "LLDB.framework: no additional tools configured (set via LLDB_FRAMEWORK_TOOLS)") -endif() - # Apart from this one, CMake creates all required symlinks in the framework bundle. add_custom_command(TARGET lldb-framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink Index: lldb/trunk/tools/argdumper/CMakeLists.txt =================================================================== --- lldb/trunk/tools/argdumper/CMakeLists.txt +++ lldb/trunk/tools/argdumper/CMakeLists.txt @@ -4,3 +4,7 @@ LINK_LIBS lldbUtility ) + +if(LLDB_BUILD_FRAMEWORK) + lldb_add_to_framework(lldb-argdumper) +endif() Index: lldb/trunk/tools/darwin-debug/CMakeLists.txt =================================================================== --- lldb/trunk/tools/darwin-debug/CMakeLists.txt +++ lldb/trunk/tools/darwin-debug/CMakeLists.txt @@ -1,3 +1,7 @@ add_lldb_tool(darwin-debug darwin-debug.cpp ) + +if(LLDB_BUILD_FRAMEWORK) + lldb_add_to_framework(darwin-debug) +endif() Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt =================================================================== --- lldb/trunk/tools/debugserver/source/CMakeLists.txt +++ lldb/trunk/tools/debugserver/source/CMakeLists.txt @@ -265,6 +265,10 @@ ${entitlements} ) + if(LLDB_BUILD_FRAMEWORK) + lldb_add_to_framework(debugserver) + endif() + if(IOS) set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS WITH_LOCKDOWN Index: lldb/trunk/tools/driver/CMakeLists.txt =================================================================== --- lldb/trunk/tools/driver/CMakeLists.txt +++ lldb/trunk/tools/driver/CMakeLists.txt @@ -31,5 +31,15 @@ set_target_properties(LLDBOptionsTableGen PROPERTIES FOLDER "lldb misc") if(LLDB_BUILD_FRAMEWORK) - lldb_setup_framework_rpaths_in_tool(lldb) + # In the build-tree, we know the exact path to the framework directory. + # The installed framework can be in different locations. + get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + lldb_setup_rpaths(lldb + BUILD_RPATH + "${framework_build_dir}" + INSTALL_RPATH + "@loader_path/../../../SharedFrameworks" + "@loader_path/../../System/Library/PrivateFrameworks" + "@loader_path/../../Library/PrivateFrameworks" + ) endif() Index: lldb/trunk/tools/lldb-mi/CMakeLists.txt =================================================================== --- lldb/trunk/tools/lldb-mi/CMakeLists.txt +++ lldb/trunk/tools/lldb-mi/CMakeLists.txt @@ -95,5 +95,15 @@ ) if(LLDB_BUILD_FRAMEWORK) - lldb_setup_framework_rpaths_in_tool(lldb-mi) + # In the build-tree, we know the exact path to the framework directory. + # The installed framework can be in different locations. + get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + lldb_setup_rpaths(lldb-mi + BUILD_RPATH + "${framework_build_dir}" + INSTALL_RPATH + "@loader_path/../../../SharedFrameworks" + "@loader_path/../../System/Library/PrivateFrameworks" + "@loader_path/../../Library/PrivateFrameworks" + ) endif() Index: lldb/trunk/tools/lldb-server/CMakeLists.txt =================================================================== --- lldb/trunk/tools/lldb-server/CMakeLists.txt +++ lldb/trunk/tools/lldb-server/CMakeLists.txt @@ -77,3 +77,7 @@ ) target_link_libraries(lldb-server PRIVATE ${LLDB_SYSTEM_LIBS}) + +if(LLDB_BUILD_FRAMEWORK) + lldb_add_to_framework(lldb-server) +endif() Index: lldb/trunk/tools/lldb-vscode/CMakeLists.txt =================================================================== --- lldb/trunk/tools/lldb-vscode/CMakeLists.txt +++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt @@ -31,5 +31,15 @@ ) if(LLDB_BUILD_FRAMEWORK) - lldb_setup_framework_rpaths_in_tool(lldb-vscode) + # In the build-tree, we know the exact path to the framework directory. + # The installed framework can be in different locations. + get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + lldb_setup_rpaths(lldb-vscode + BUILD_RPATH + "${framework_build_dir}" + INSTALL_RPATH + "@loader_path/../../../SharedFrameworks" + "@loader_path/../../System/Library/PrivateFrameworks" + "@loader_path/../../Library/PrivateFrameworks" + ) endif()