[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.

llvm-svn: 261681
This commit is contained in:
Chris Bieneman 2016-02-23 20:33:53 +00:00
parent 5b21af5222
commit c90e12fe9f
1 changed files with 17 additions and 0 deletions

View File

@ -766,3 +766,20 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endif()
# This must be at the end of the LLVM root CMakeLists file because it must run
# after all targets are created.
if(LLVM_DISTRIBUTION_COMPONENTS)
if(CMAKE_CONFIGURATION_TYPES)
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)
foreach(target ${LLVM_DISTRIBUTION_COMPONENTS})
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()
endif()