[llvm] r261681 - [CMake] Create an install-distribution target driven by LLVM_DISTRIBUTION_COMPONENTS

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 12:33:53 PST 2016

Author: cbieneman
Date: Tue Feb 23 14:33:53 2016
New Revision: 261681

URL: http://llvm.org/viewvc/llvm-project?rev=261681&view=rev
[CMake] Create an install-distribution target driven by LLVM_DISTRIBUTION_COMPONENTS

The idea here is to provide a customizable install target that only depends on building the things you actually want to install. It relies on each component being installed having an auto-generated install-${component}, which in turn depends only on the target being installed.

This is fundamentally a workaround for the fact that CMake generates build files which have their "install" target depend on the "all" target. This results in "ninja install" building a bunch of unneeded things.


Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=261681&r1=261680&r2=261681&view=diff
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Tue Feb 23 14:33:53 2016
@@ -766,3 +766,20 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
                               -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# This must be at the end of the LLVM root CMakeLists file because it must run
+# after all targets are created.
+    message(FATAL_ERROR "LLVM_DISTRIBUTION_COMPONENTS cannot be specified with multi-configuration generators (i.e. Xcode or Visual Studio)")
+  endif()
+  add_custom_target(install-distribution)
+    if(TARGET install-${target})
+      add_dependencies(install-distribution install-${target})
+    else()
+      message(FATAL_ERROR "Specified distribution component '${target}' doesn't have an install target")
+    endif()
+  endforeach()

More information about the llvm-commits mailing list