[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / lldb / cmake / modules / LLDBFramework.cmake
blob81fc596ef4244e738a02670a2f88c157c3164d7d
1 message(STATUS "LLDB.framework: build path is '${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
2 message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'")
3 message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
5 # Configure liblldb as a framework bundle
6 if(NOT APPLE_EMBEDDED)
7   set_target_properties(liblldb PROPERTIES
8     FRAMEWORK ON
9     FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
11     OUTPUT_NAME LLDB
12     VERSION ${LLDB_VERSION}
13     LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
15     # Compatibility version
16     SOVERSION "1.0.0"
18     MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
19     MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
20     MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
21     MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
22   )
23 else()
24   set_target_properties(liblldb PROPERTIES
25     FRAMEWORK ON
26     FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
28     # Note: iOS doesn't specify version, as the framework layout is flat.
29     OUTPUT_NAME LLDB
30     LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
32     MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
33     MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
34     MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
35     MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
36   )
37 endif()
39 # Used in llvm_add_library() to set default output directories for multi-config
40 # generators. Overwrite to account for special framework output directory.
41 set_output_directory(liblldb
42   BINARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
43   LIBRARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
46 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
48 # Affects the layout of the framework bundle (default is macOS layout).
49 if(APPLE_EMBEDDED)
50   set_target_properties(liblldb PROPERTIES
51     XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}")
52 else()
53   set_target_properties(liblldb PROPERTIES
54     XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}")
55 endif()
57 # Add -Wdocumentation parameter
58 set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES")
60 # On iOS, there is no versioned framework layout. Skip this symlink step.
61 if(NOT APPLE_EMBEDDED)
62   # Apart from this one, CMake creates all required symlinks in the framework bundle.
63   add_custom_command(TARGET liblldb POST_BUILD
64     COMMAND ${CMAKE_COMMAND} -E create_symlink
65             Versions/Current/Headers
66             ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
67     COMMENT "LLDB.framework: create Headers symlink"
68   )
69 endif()
71 # At configuration time, collect headers for the framework bundle and copy them
72 # into a staging directory. Later we can copy over the entire folder.
73 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
74 file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
75 file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
76 list(REMOVE_ITEM root_public_headers ${root_private_headers})
78 find_program(unifdef_EXECUTABLE unifdef)
80 set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
81 foreach(header
82     ${public_headers}
83     ${root_public_headers})
85   get_filename_component(basename ${header} NAME)
86   set(staged_header ${lldb_header_staging}/${basename})
88   if(unifdef_EXECUTABLE)
89     # unifdef returns 0 when the file is unchanged and 1 if something was changed.
90     # That means if we successfully remove SWIG code, the build system believes
91     # that the command has failed and stops. This is undesirable.
92     set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} ${header} || (exit 0))
93   else()
94     set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header})
95   endif()
97   add_custom_command(
98     DEPENDS ${header} OUTPUT ${staged_header}
99     COMMAND ${copy_command}
100     COMMENT "LLDB.framework: collect framework header and remove SWIG macros")
102   list(APPEND lldb_staged_headers ${staged_header})
103 endforeach()
105 # Wrap output in a target, so lldb-framework can depend on it.
106 add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
107 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
108 add_dependencies(liblldb liblldb-resource-headers)
110 # At build time, copy the staged headers into the framework bundle (and do
111 # some post-processing in-place).
112 add_custom_command(TARGET liblldb POST_BUILD
113   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $<TARGET_FILE_DIR:liblldb>/Headers
114   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $<TARGET_FILE_DIR:liblldb>/Headers ${LLDB_VERSION}
115   COMMENT "LLDB.framework: copy framework headers"
118 # Copy vendor-specific headers from clang (without staging).
119 if(NOT APPLE_EMBEDDED)
120   if (TARGET clang-resource-headers)
121     add_dependencies(liblldb clang-resource-headers)
122     set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,RUNTIME_OUTPUT_DIRECTORY>)
123   else()
124     set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
125     if(NOT EXISTS ${clang_resource_headers_dir})
126       message(WARNING "Expected directory for clang-resource headers not found: ${clang_resource_headers_dir}")
127     endif()
128   endif()
130   add_custom_command(TARGET liblldb POST_BUILD
131     COMMAND ${CMAKE_COMMAND} -E copy_directory
132             ${clang_resource_headers_dir}
133             $<TARGET_FILE_DIR:liblldb>/Resources/Clang/include
134     COMMENT "LLDB.framework: copy clang vendor-specific headers"
135   )
136 endif()
138 # Add an rpath pointing to the directory where LLDB.framework is installed.
139 # This allows frameworks (relying on @rpath) to be installed in the same folder and found at runtime.
140 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH
141   "@loader_path/../../../")