Add targets to cmake for specific target components.
authorPete Cooper <peter_cooper@apple.com>
Mon, 20 Apr 2015 18:22:05 +0000 (18:22 +0000)
committerPete Cooper <peter_cooper@apple.com>
Mon, 20 Apr 2015 18:22:05 +0000 (18:22 +0000)
This adds the following targets to cmake.  These can be used to build and link only specific parts of a backend, instead of having to link the whole backend.

- AllTargetsAsmPrinters, AllTargetsAsmParsers, AllTargetsDescs, AllTargetsDisassemblers, AllTargetsInfos

A typical use for these is instead of linking ${LLVM_TARGETS_TO_BUILD}.  This commit changes llvm-mc to show how to use the new targets.

Reviewed by Chris Bieneman.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235324 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/LLVM-Config.cmake
tools/llvm-mc/CMakeLists.txt

index bc0527f1db4815a81c529f1aeb2c57d0549a6059..22ac71451917a21d0703b4b828ba7a5900cf216d 100644 (file)
@@ -132,6 +132,41 @@ function(llvm_map_components_to_libnames out_libs)
       # already processed
     elseif( c STREQUAL "all" )
       list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
       # already processed
     elseif( c STREQUAL "all" )
       list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
+    elseif( c STREQUAL "AllTargetsAsmPrinters" )
+      # Link all the asm printers from all the targets
+      foreach(t ${LLVM_TARGETS_TO_BUILD})
+        if( TARGET LLVM${t}AsmPrinter )
+          list(APPEND expanded_components "LLVM${t}AsmPrinter")
+        endif()
+      endforeach(t)
+    elseif( c STREQUAL "AllTargetsAsmParsers" )
+      # Link all the asm parsers from all the targets
+      foreach(t ${LLVM_TARGETS_TO_BUILD})
+        if( TARGET LLVM${t}AsmParser )
+          list(APPEND expanded_components "LLVM${t}AsmParser")
+        endif()
+      endforeach(t)
+    elseif( c STREQUAL "AllTargetsDescs" )
+      # Link all the descs from all the targets
+      foreach(t ${LLVM_TARGETS_TO_BUILD})
+        if( TARGET LLVM${t}Desc )
+          list(APPEND expanded_components "LLVM${t}Desc")
+        endif()
+      endforeach(t)
+    elseif( c STREQUAL "AllTargetsDisassemblers" )
+      # Link all the disassemblers from all the targets
+      foreach(t ${LLVM_TARGETS_TO_BUILD})
+        if( TARGET LLVM${t}Disassembler )
+          list(APPEND expanded_components "LLVM${t}Disassembler")
+        endif()
+      endforeach(t)
+    elseif( c STREQUAL "AllTargetsInfos" )
+      # Link all the infos from all the targets
+      foreach(t ${LLVM_TARGETS_TO_BUILD})
+        if( TARGET LLVM${t}Info )
+          list(APPEND expanded_components "LLVM${t}Info")
+        endif()
+      endforeach(t)
     else( NOT idx LESS 0 )
       # Canonize the component name:
       string(TOUPPER "${c}" capitalized)
     else( NOT idx LESS 0 )
       # Canonize the component name:
       string(TOUPPER "${c}" capitalized)
index 6f8e9e5405f9f004bc7af0967dd3aad04340187d..15c6dda1b258633669721a93d27e2e284e6bfd3e 100644 (file)
@@ -1,5 +1,9 @@
 set(LLVM_LINK_COMPONENTS
 set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
+  AllTargetsAsmPrinters
+  AllTargetsAsmParsers
+  AllTargetsDescs
+  AllTargetsDisassemblers
+  AllTargetsInfos
   MC
   MCParser
   Support
   MC
   MCParser
   Support