1# Path relative to the root binary directory 2get_filename_component( 3 framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE 4 BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} 5) 6 7message(STATUS "LLDB.framework: build path is '${framework_target_dir}'") 8message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'") 9message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'") 10 11# Configure liblldb as a framework bundle 12set_target_properties(liblldb PROPERTIES 13 FRAMEWORK ON 14 FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} 15 16 OUTPUT_NAME LLDB 17 VERSION ${LLDB_VERSION} 18 LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir} 19 20 # Compatibility version 21 SOVERSION "1.0.0" 22 23 MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework 24 MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION} 25 MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION} 26 MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in 27) 28 29# Affects the layout of the framework bundle (default is macOS layout). 30if(IOS) 31 set_target_properties(liblldb PROPERTIES 32 XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}") 33else() 34 set_target_properties(liblldb PROPERTIES 35 XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") 36endif() 37 38# Target to capture extra steps for a fully functional framework bundle. 39add_custom_target(lldb-framework) 40add_dependencies(lldb-framework liblldb) 41 42# Dependencies are defined once tools are added (see AddLLDB.cmake) 43if(LLDB_FRAMEWORK_TOOLS) 44 foreach(tool ${LLDB_FRAMEWORK_TOOLS}) 45 add_custom_command(TARGET lldb-framework POST_BUILD 46 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${tool}> $<TARGET_FILE_DIR:liblldb>/Resources 47 COMMENT "LLDB.framework: copy additional tool ${tool}" 48 ) 49 endforeach() 50else() 51 message(WARNING "LLDB.framework: no additional tools configured (set via LLDB_FRAMEWORK_TOOLS)") 52endif() 53 54# Apart from this one, CMake creates all required symlinks in the framework bundle. 55add_custom_command(TARGET lldb-framework POST_BUILD 56 COMMAND ${CMAKE_COMMAND} -E create_symlink 57 Versions/Current/Headers 58 ${framework_target_dir}/LLDB.framework/Headers 59 COMMENT "LLDB.framework: create Headers symlink" 60) 61 62# At configuration time, collect headers for the framework bundle and copy them 63# into a staging directory. Later we can copy over the entire folder. 64file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) 65file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) 66file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) 67list(REMOVE_ITEM root_public_headers ${root_private_headers}) 68 69set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) 70foreach(header 71 ${public_headers} 72 ${root_public_headers} 73 ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h) 74 75 get_filename_component(basename ${header} NAME) 76 set(staged_header ${lldb_header_staging}/${basename}) 77 78 add_custom_command( 79 DEPENDS ${header} OUTPUT ${staged_header} 80 COMMAND ${CMAKE_COMMAND} -E copy ${header} ${staged_header} 81 COMMENT "LLDB.framework: collect framework header") 82 83 list(APPEND lldb_staged_headers ${staged_header}) 84endforeach() 85 86# Wrap output in a target, so lldb-framework can depend on it. 87add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers}) 88add_dependencies(lldb-framework lldb-framework-headers) 89 90# At build time, copy the staged headers into the framework bundle (and do 91# some post-processing in-place). 92add_custom_command(TARGET lldb-framework-headers POST_BUILD 93 COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $<TARGET_FILE_DIR:liblldb>/Headers 94 COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $<TARGET_FILE_DIR:liblldb>/Headers ${LLDB_VERSION} 95 COMMENT "LLDB.framework: copy framework headers" 96) 97 98# Copy vendor-specific headers from clang (without staging). 99if(NOT IOS AND NOT LLDB_BUILT_STANDALONE) 100 add_dependencies(lldb-framework clang-headers) 101 add_custom_command(TARGET lldb-framework POST_BUILD 102 COMMAND ${CMAKE_COMMAND} -E copy_directory 103 $<TARGET_PROPERTY:clang-headers,RUNTIME_OUTPUT_DIRECTORY> 104 $<TARGET_FILE_DIR:liblldb>/Resources/Clang/include 105 COMMENT "LLDB.framework: copy clang vendor-specific headers" 106 ) 107endif() 108