|
| 1 | +# Path relative to the root binary directory |
| 2 | +get_filename_component( |
| 3 | + framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE |
| 4 | + BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} |
| 5 | +) |
| 6 | + |
| 7 | +message(STATUS "LLDB.framework: build path is '${framework_target_dir}'") |
| 8 | +message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'") |
| 9 | +message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'") |
| 10 | + |
| 11 | +# Configure liblldb as a framework bundle |
| 12 | +set_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). |
| 30 | +if(IOS) |
| 31 | + set_target_properties(liblldb PROPERTIES |
| 32 | + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}") |
| 33 | +else() |
| 34 | + set_target_properties(liblldb PROPERTIES |
| 35 | + XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") |
| 36 | +endif() |
| 37 | + |
| 38 | +# Target to capture extra steps for a fully functional framework bundle. |
| 39 | +add_custom_target(lldb-framework) |
| 40 | +add_dependencies(lldb-framework liblldb) |
| 41 | + |
| 42 | +# Dependencies are defined once tools are added (see AddLLDB.cmake) |
| 43 | +if(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() |
| 50 | +else() |
| 51 | + message(WARNING "LLDB.framework: no additional tools configured (set via LLDB_FRAMEWORK_TOOLS)") |
| 52 | +endif() |
| 53 | + |
| 54 | +# Apart from this one, CMake creates all required symlinks in the framework bundle. |
| 55 | +add_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. |
1 | 64 | file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
|
2 | 65 | file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
|
3 | 66 | file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
|
4 | 67 | list(REMOVE_ITEM root_public_headers ${root_private_headers})
|
| 68 | + |
| 69 | +set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) |
5 | 70 | foreach(header
|
6 | 71 | ${public_headers}
|
7 | 72 | ${root_public_headers}
|
8 | 73 | ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h)
|
| 74 | + |
9 | 75 | get_filename_component(basename ${header} NAME)
|
10 |
| - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename} |
11 |
| - DEPENDS ${header} |
12 |
| - COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) |
13 |
| - list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) |
| 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}) |
14 | 84 | endforeach()
|
15 | 85 |
|
16 |
| -add_custom_target(lldb-framework-headers DEPENDS ${framework_headers}) |
| 86 | +# Wrap output in a target, so lldb-framework can depend on it. |
| 87 | +add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers}) |
| 88 | +add_dependencies(lldb-framework lldb-framework-headers) |
17 | 89 |
|
18 |
| -add_custom_command(TARGET lldb-framework POST_BUILD |
19 |
| - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers |
| 90 | +# At build time, copy the staged headers into the framework bundle (and do |
| 91 | +# some post-processing in-place). |
| 92 | +add_custom_command(TARGET lldb-framework-headers POST_BUILD |
| 93 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $<TARGET_FILE_DIR:liblldb>/Headers |
20 | 94 | COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $<TARGET_FILE_DIR:liblldb>/Headers ${LLDB_VERSION}
|
| 95 | + COMMENT "LLDB.framework: copy framework headers" |
21 | 96 | )
|
22 | 97 |
|
23 |
| -if (NOT IOS) |
24 |
| - if (NOT LLDB_BUILT_STANDALONE) |
25 |
| - add_dependencies(lldb-framework clang-headers) |
26 |
| - endif() |
| 98 | +# Copy vendor-specific headers from clang (without staging). |
| 99 | +if(NOT IOS AND NOT LLDB_BUILT_STANDALONE) |
| 100 | + add_dependencies(lldb-framework clang-headers) |
27 | 101 | add_custom_command(TARGET lldb-framework POST_BUILD
|
28 |
| - COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${LLDB_FRAMEWORK_DIR}/LLDB.framework/Headers |
29 |
| - COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${LLDB_FRAMEWORK_DIR}/LLDB.framework/Versions/Current |
30 |
| - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH} $<TARGET_FILE_DIR:liblldb>/Resources/Clang |
| 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" |
31 | 106 | )
|
32 | 107 | endif()
|
33 |
| - |
34 |
| -add_dependencies(lldb-framework |
35 |
| - lldb-framework-headers |
36 |
| - lldb-suite) |
37 |
| - |
38 |
| -add_custom_target(install-lldb-framework) |
39 |
| -add_custom_target(install-lldb-framework-stripped) |
|
0 commit comments