[Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use
[llvm-project.git] / lldb / cmake / modules / LLDBFramework.cmake
blob471aeaaad3c0d3f2bc71f245bec89db8e009c9ae
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 set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
75 file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
76 file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
77 list(REMOVE_ITEM root_public_headers ${root_private_headers})
79 find_program(unifdef_EXECUTABLE unifdef)
81 set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
82 foreach(header
83     ${public_headers}
84     ${generated_public_headers}
85     ${root_public_headers})
87   get_filename_component(basename ${header} NAME)
88   set(staged_header ${lldb_header_staging}/${basename})
90   if(unifdef_EXECUTABLE)
91     # unifdef returns 0 when the file is unchanged and 1 if something was changed.
92     # That means if we successfully remove SWIG code, the build system believes
93     # that the command has failed and stops. This is undesirable.
94     set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} ${header} || (exit 0))
95   else()
96     set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header})
97   endif()
99   add_custom_command(
100     DEPENDS ${header} OUTPUT ${staged_header}
101     COMMAND ${copy_command}
102     COMMENT "LLDB.framework: collect framework header and remove SWIG macros")
104   list(APPEND lldb_staged_headers ${staged_header})
105 endforeach()
107 # Wrap output in a target, so lldb-framework can depend on it.
108 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums ${lldb_staged_headers})
109 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "LLDB/Resources")
110 add_dependencies(liblldb liblldb-resource-headers)
112 # At build time, copy the staged headers into the framework bundle (and do
113 # some post-processing in-place).
114 add_custom_command(TARGET liblldb POST_BUILD
115   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $<TARGET_FILE_DIR:liblldb>/Headers
116   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $<TARGET_FILE_DIR:liblldb>/Headers ${LLDB_VERSION}
117   COMMENT "LLDB.framework: copy framework headers"
120 # Copy vendor-specific headers from clang (without staging).
121 if(NOT APPLE_EMBEDDED)
122   if (TARGET clang-resource-headers)
123     add_dependencies(liblldb clang-resource-headers)
124     set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,INTERFACE_INCLUDE_DIRECTORIES>)
125   else()
126     set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
127     if(NOT EXISTS ${clang_resource_headers_dir})
128       message(WARNING "Expected directory for clang-resource headers not found: ${clang_resource_headers_dir}")
129     endif()
130   endif()
132   add_custom_command(TARGET liblldb POST_BUILD
133     COMMAND ${CMAKE_COMMAND} -E copy_directory
134             ${clang_resource_headers_dir}
135             $<TARGET_FILE_DIR:liblldb>/Resources/Clang/include
136     COMMENT "LLDB.framework: copy clang vendor-specific headers"
137   )
138 endif()
140 # Add an rpath pointing to the directory where LLDB.framework is installed.
141 # This allows frameworks (relying on @rpath) to be installed in the same folder and found at runtime.
142 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH
143   "@loader_path/../../../")