[PATCH] D72372: [CMake] Default to static linking for subprojects.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 17:59:45 PST 2020


Meinersbur updated this revision to Diff 243707.
Meinersbur edited the summary of this revision.
Meinersbur added a comment.

- Fix typo's found by @serge-sans-paille


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72372/new/

https://reviews.llvm.org/D72372

Files:
  llvm/cmake/modules/AddLLVM.cmake
  polly/lib/CMakeLists.txt


Index: polly/lib/CMakeLists.txt
===================================================================
--- polly/lib/CMakeLists.txt
+++ polly/lib/CMakeLists.txt
@@ -25,6 +25,7 @@
 # the sources them to be recompiled for each of them.
 add_llvm_pass_plugin(Polly
   NO_MODULE
+  SUBPROJECT Polly
   Analysis/DependenceInfo.cpp
   Analysis/PolyhedralInfo.cpp
   Analysis/ScopDetection.cpp
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -854,14 +854,26 @@
 #
 #   If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF,
 #   only an object library is built, and no module is built. This is specific to the Polly use case.
+#
+#   The SUBPROJECT argument contains the LLVM project the plugin belongs to.
+#   If set, the plugin will link statically by default if the project
+#   was enabled.
 function(add_llvm_pass_plugin name)
   cmake_parse_arguments(ARG
-    "NO_MODULE" "" ""
+    "NO_MODULE" "SUBPROJECT" ""
     ${ARGN})
 
   string(TOUPPER ${name} name_upper)
 
-  option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" OFF)
+  # Link the plugin statically by default if it was explicitly enabled
+  # by the user.
+  # Note: If was set to "all", LLVM's CMakeLists.txt replaces it with a
+  # list of all projects, counting as explicitly enabled.
+  set(link_into_tools_default OFF)
+  if (ARG_SUBPROJECT AND LLVM_TOOL_${name_upper}_BUILD)
+    set(link_into_tools_default ON)
+  endif ()
+  option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" ${link_into_tools_default})
 
   if(LLVM_${name_upper}_LINK_INTO_TOOLS)
     list(REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72372.243707.patch
Type: text/x-patch
Size: 1831 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200211/cd41272d/attachment.bin>


More information about the llvm-commits mailing list