xiaobai created this revision.
xiaobai added reviewers: labath, sas.
Herald added a subscriber: mgorny.

Previously, I thought that install-liblldb would fail because CMake had
a bug related to installing frameworks. In actuality, I misunderstood the
semantics of `add_custom_target`: the DEPENDS option refers to specific files,
not targets. Therefore `install-liblldb` should rely on the actual liblldb
getting generated rather than the target.

This means that the previous patch I committed (to stop relying on CMake's
framework support) is no longer needed and has been reverted. Using CMake's
framework support greatly simplifies the implementation.

`install-lldb-framework` (and the stripped variant) is as simple as
depending on `install-liblldb` because CMake knows that liblldb was built as a
framework and will install the whole framework for you. The stripped variant
will depend on the stripped variants of individual tools only to ensure they
actually are stripped as well.


https://reviews.llvm.org/D50038

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  cmake/modules/LLDBFramework.cmake
  source/API/CMakeLists.txt

Index: source/API/CMakeLists.txt
===================================================================
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -143,6 +143,17 @@
   )
 endif()
 
+if (LLDB_BUILD_FRAMEWORK)
+  set_target_properties(liblldb
+    PROPERTIES
+    OUTPUT_NAME LLDB
+    FRAMEWORK On
+    FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+    MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist
+    LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_DIR}
+  )
+endif()
+
 if (LLDB_WRAP_PYTHON)
   add_dependencies(liblldb swig_wrapper)
 endif()
Index: cmake/modules/LLDBFramework.cmake
===================================================================
--- cmake/modules/LLDBFramework.cmake
+++ cmake/modules/LLDBFramework.cmake
@@ -31,14 +31,9 @@
   )
 endif()
 
-set_target_properties(liblldb PROPERTIES
-  OUTPUT_NAME LLDB
-  FRAMEWORK On
-  FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
-  MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist
-  LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
-  PUBLIC_HEADER "${framework_headers}")
-
 add_dependencies(lldb-framework
   lldb-framework-headers
   lldb-suite)
+
+add_custom_target(install-lldb-framework)
+add_custom_target(install-lldb-framework-stripped)
Index: cmake/modules/AddLLDB.cmake
===================================================================
--- cmake/modules/AddLLDB.cmake
+++ cmake/modules/AddLLDB.cmake
@@ -53,6 +53,11 @@
         set(out_dir lib${LLVM_LIBDIR_SUFFIX})
         if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
           set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
+          # The framework that is generated will install with install-liblldb
+          # because we enable CMake's framework support. CMake will copy all the
+          # headers and resources for us.
+          add_dependencies(install-lldb-framework install-${name})
+          add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
         endif()
         install(TARGETS ${name}
           COMPONENT ${name}
@@ -67,12 +72,19 @@
       endif()
       if (NOT CMAKE_CONFIGURATION_TYPES)
         add_llvm_install_targets(install-${name}
-                                 DEPENDS ${name}
+                                 DEPENDS $<TARGET_FILE:${name}>
                                  COMPONENT ${name})
       endif()
     endif()
   endif()
 
+  # install-liblldb{,-stripped} is the actual target that will install the
+  # framework, so it must rely on the framework being fully built first.
+  if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
+    add_dependencies(install-${name} lldb-framework)
+    add_dependencies(install-lldb-framework-stripped lldb-framework)
+  endif()
+
   # Hack: only some LLDB libraries depend on the clang autogenerated headers,
   # but it is simple enough to make all of LLDB depend on some of those
   # headers without negatively impacting much of anything.
@@ -124,6 +136,10 @@
     set(out_dir "bin")
     if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE)
       set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
+      # While install-liblldb-stripped will handle copying the tools, it will
+      # not strip them. We depend on this target to guarantee a stripped version
+      # will get installed in the framework.
+      add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
     endif()
     install(TARGETS ${name}
           COMPONENT ${name}
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -51,6 +51,7 @@
     message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
   endif()
 
+  add_custom_target(lldb-framework)
   # These are used to fill out LLDB-Info.plist. These are relevant when building
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")
@@ -60,6 +61,7 @@
 
   set(LLDB_FRAMEWORK_DIR
     ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
+  include(LLDBFramework)
 endif()
 
 add_subdirectory(docs)
@@ -162,10 +164,6 @@
   add_subdirectory(utils/lldb-dotest)
 endif()
 
-if (LLDB_BUILD_FRAMEWORK)
-  add_custom_target(lldb-framework)
-  include(LLDBFramework)
-endif()
 
 if (NOT LLDB_DISABLE_PYTHON)
     # Add a Post-Build Event to copy over Python files and create the symlink
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to