[PATCH] CMake: add LLVM_INSTALL_TOOLCHAIN_ONLY option

Hans Wennborg hans at chromium.org
Fri Aug 23 15:49:59 PDT 2013


  After the discussion on the mailing list, go back to just having one option for this.

Hi rnk,

http://llvm-reviews.chandlerc.com/D1428

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1428?vs=3649&id=3723#toc

Files:
  CMakeLists.txt
  cmake/modules/AddLLVM.cmake
  cmake/modules/CMakeLists.txt

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -15,6 +15,8 @@
 
 set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}svn")
 
+option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
+
 option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
 if ( LLVM_USE_FOLDERS )
   set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -465,28 +467,30 @@
 
 add_subdirectory(cmake/modules)
 
-install(DIRECTORY include/
-  DESTINATION include
-  FILES_MATCHING
-  PATTERN "*.def"
-  PATTERN "*.h"
-  PATTERN "*.td"
-  PATTERN "*.inc"
-  PATTERN "LICENSE.TXT"
-  PATTERN ".svn" EXCLUDE
-  )
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+  install(DIRECTORY include/
+    DESTINATION include
+    FILES_MATCHING
+    PATTERN "*.def"
+    PATTERN "*.h"
+    PATTERN "*.td"
+    PATTERN "*.inc"
+    PATTERN "LICENSE.TXT"
+    PATTERN ".svn" EXCLUDE
+    )
 
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
-  DESTINATION include
-  FILES_MATCHING
-  PATTERN "*.def"
-  PATTERN "*.h"
-  PATTERN "*.gen"
-  PATTERN "*.inc"
-  # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
-  PATTERN "CMakeFiles" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  )
+  install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
+    DESTINATION include
+    FILES_MATCHING
+    PATTERN "*.def"
+    PATTERN "*.h"
+    PATTERN "*.gen"
+    PATTERN "*.inc"
+    # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
+    PATTERN "CMakeFiles" EXCLUDE
+    PATTERN ".svn" EXCLUDE
+    )
+endif()
 
 # TODO: make and install documentation.
 
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -26,9 +26,11 @@
   if( EXCLUDE_FROM_ALL )
     set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
   else()
-    install(TARGETS ${name}
-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+      install(TARGETS ${name}
+        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+        ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+    endif()
   endif()
   set_target_properties(${name} PROPERTIES FOLDER "Libraries")
 
@@ -70,9 +72,11 @@
     if( EXCLUDE_FROM_ALL )
       set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
     else()
-      install(TARGETS ${name}
-        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-        ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+      if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+        install(TARGETS ${name}
+          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+      endif()
     endif()
   endif()
 
@@ -96,14 +100,23 @@
 endmacro(add_llvm_executable name)
 
 
+set (LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-objdump
+  )
+
 macro(add_llvm_tool name)
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
   if( NOT LLVM_BUILD_TOOLS )
     set(EXCLUDE_FROM_ALL ON)
   endif()
   add_llvm_executable(${name} ${ARGN})
-  if( LLVM_BUILD_TOOLS )
-    install(TARGETS ${name} RUNTIME DESTINATION bin)
+
+  list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
+  if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+    if( LLVM_BUILD_TOOLS )
+      install(TARGETS ${name} RUNTIME DESTINATION bin)
+    endif()
   endif()
   set_target_properties(${name} PROPERTIES FOLDER "Tools")
 endmacro(add_llvm_tool name)
Index: cmake/modules/CMakeLists.txt
===================================================================
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -19,19 +19,21 @@
   ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
   @ONLY)
 
-install(FILES
-  ${llvm_cmake_builddir}/LLVMConfig.cmake
-  ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
-  LLVM-Config.cmake
-  DESTINATION share/llvm/cmake)
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+  install(FILES
+    ${llvm_cmake_builddir}/LLVMConfig.cmake
+    ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
+    LLVM-Config.cmake
+    DESTINATION share/llvm/cmake)
 
-install(DIRECTORY .
-  DESTINATION share/llvm/cmake
-  FILES_MATCHING PATTERN *.cmake
-  PATTERN .svn EXCLUDE
-  PATTERN LLVMConfig.cmake EXCLUDE
-  PATTERN LLVMConfigVersion.cmake EXCLUDE
-  PATTERN LLVM-Config.cmake EXCLUDE
-  PATTERN GetHostTriple.cmake EXCLUDE
-  PATTERN VersionFromVCS.cmake EXCLUDE
-  PATTERN CheckAtomic.cmake EXCLUDE)
+  install(DIRECTORY .
+    DESTINATION share/llvm/cmake
+    FILES_MATCHING PATTERN *.cmake
+    PATTERN .svn EXCLUDE
+    PATTERN LLVMConfig.cmake EXCLUDE
+    PATTERN LLVMConfigVersion.cmake EXCLUDE
+    PATTERN LLVM-Config.cmake EXCLUDE
+    PATTERN GetHostTriple.cmake EXCLUDE
+    PATTERN VersionFromVCS.cmake EXCLUDE
+    PATTERN CheckAtomic.cmake EXCLUDE)
+endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1428.4.patch
Type: text/x-patch
Size: 5009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130823/4c9bfc6b/attachment.bin>


More information about the llvm-commits mailing list