[Lldb-commits] [lldb] r338594 - Introduce install-lldb-framework target

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 1 10:21:18 PDT 2018


Author: xiaobai
Date: Wed Aug  1 10:21:18 2018
New Revision: 338594

URL: http://llvm.org/viewvc/llvm-project?rev=338594&view=rev
Log:
Introduce install-lldb-framework target

Summary:
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.

Reviewers: labath, sas

Subscribers: mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D50038

Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/cmake/modules/AddLLDB.cmake
    lldb/trunk/cmake/modules/LLDBFramework.cmake
    lldb/trunk/source/API/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=338594&r1=338593&r2=338594&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Aug  1 10:21:18 2018
@@ -51,6 +51,7 @@ if(LLDB_BUILD_FRAMEWORK)
     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 @@ if(LLDB_BUILD_FRAMEWORK)
 
   set(LLDB_FRAMEWORK_DIR
     ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
+  include(LLDBFramework)
 endif()
 
 add_subdirectory(docs)
@@ -162,10 +164,6 @@ if(LLDB_INCLUDE_TESTS)
   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

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=338594&r1=338593&r2=338594&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Aug  1 10:21:18 2018
@@ -53,6 +53,11 @@ function(add_lldb_library name)
         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,20 @@ function(add_lldb_library name)
       endif()
       if (NOT CMAKE_CONFIGURATION_TYPES)
         add_llvm_install_targets(install-${name}
-                                 DEPENDS ${name}
+                                 DEPENDS $<TARGET_FILE:${name}>
                                  COMPONENT ${name})
+
+        # 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()
       endif()
     endif()
   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 +137,10 @@ function(add_lldb_executable name)
     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}

Modified: lldb/trunk/cmake/modules/LLDBFramework.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBFramework.cmake?rev=338594&r1=338593&r2=338594&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBFramework.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake Wed Aug  1 10:21:18 2018
@@ -31,14 +31,9 @@ if (NOT IOS)
   )
 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)

Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=338594&r1=338593&r2=338594&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Wed Aug  1 10:21:18 2018
@@ -143,6 +143,17 @@ else()
   )
 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()




More information about the lldb-commits mailing list