[Lldb-commits] [lldb] r293647 - [CMake] Add LINK_LIBS and LINK_COMPONENTS options

Chris Bieneman via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 31 08:59:47 PST 2017


Author: cbieneman
Date: Tue Jan 31 10:59:46 2017
New Revision: 293647

URL: http://llvm.org/viewvc/llvm-project?rev=293647&view=rev
Log:
[CMake] Add LINK_LIBS and LINK_COMPONENTS options

This patch adds CMake options to add_lldb_library and add_lldb_executable for specifying LLVM components and direct library links.

This patch is NFC, but it is a small separable bit of a series of much larger patches that I'll be landing over the next day or two.

Modified:
    lldb/trunk/cmake/modules/AddLLDB.cmake

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=293647&r1=293646&r2=293647&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Tue Jan 31 10:59:46 2017
@@ -23,9 +23,10 @@ function(add_lldb_library name)
   cmake_parse_arguments(PARAM
     "MODULE;SHARED;STATIC;OBJECT"
     ""
-    "DEPENDS"
+    "DEPENDS;LINK_LIBS;LINK_COMPONENTS"
     ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
+  list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
 
   if (MSVC_IDE OR XCODE)
     string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
@@ -56,22 +57,19 @@ function(add_lldb_library name)
   if (PARAM_OBJECT)
     add_library(${name} ${libkind} ${srcs})
   else()
-    if (PARAM_SHARED)
-      if (LLDB_LINKER_SUPPORTS_GROUPS)
-        llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
-                                -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group
-                                -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group
-                                DEPENDS ${PARAM_DEPENDS}
-          )
-      else()
-        llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
-                                ${LLDB_USED_LIBS} ${CLANG_USED_LIBS}
-                                DEPENDS ${PARAM_DEPENDS}
-          )
-      endif()
-    else()
-      llvm_add_library(${name} ${libkind} ${srcs} DEPENDS ${PARAM_DEPENDS})
+    if (PARAM_SHARED AND LLDB_LINKER_SUPPORTS_GROUPS)
+      set(start_group -Wl,--start-group)
+      set(end_group -Wl,--end-group)
     endif()
+    llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
+                                ${start_group}
+                                ${LLDB_USED_LIBS}
+                                ${end_group}
+                                ${start_group}
+                                ${CLANG_USED_LIBS}
+                                ${end_group}
+                                ${PARAM_LINK_LIBS}
+                                DEPENDS ${PARAM_DEPENDS})
 
     if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
       if (PARAM_SHARED)
@@ -112,8 +110,17 @@ function(add_lldb_library name)
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
-  cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL" "" "" ${ARGN})
+  cmake_parse_arguments(ARG
+    "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL"
+    ""
+    "LINK_LIBS;LINK_COMPONENTS"
+    ${ARGN}
+    )
+
+  list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
   add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+
+  target_link_libraries(${name} ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES
     FOLDER "lldb executables")
 




More information about the lldb-commits mailing list