CMake: enable installing utils
authorDerek Schuff <dschuff@google.com>
Fri, 27 Mar 2015 16:53:06 +0000 (16:53 +0000)
committerDerek Schuff <dschuff@google.com>
Fri, 27 Mar 2015 16:53:06 +0000 (16:53 +0000)
Added a new boolean CMake flag, LLVM_INSTALL_UTILS. When set,
the 'install' target will include in the bin directory the
utils binaries - e.g. FileCheck. This mirrors the autoconfig
behavior.

Test Plan:
Locally verified that utils binaries are copied when flag is set,
and not copied when flag is not set.

Reviewers: jfb, dschuff, beanz

Reviewed By: beanz

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8587

Patch by Mircea Trofin

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

CMakeLists.txt
cmake/modules/AddLLVM.cmake

index be78ac26f0886fd597bc852ec9a71426bc9aa187..931e28e4efc7d51b1ba63a48ce57fea5eb5c9baa 100644 (file)
@@ -60,6 +60,8 @@ if (NOT PACKAGE_VERSION)
     "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
 endif()
 
     "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
 endif()
 
+option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
+
 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)
 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)
index 50cee302d0e86727454aa0d9e675e7030d5f03ea..1bb98a14d4954e23e898ba8ee8b018421dac5868 100644 (file)
@@ -547,6 +547,18 @@ endmacro(add_llvm_example name)
 macro(add_llvm_utility name)
   add_llvm_executable(${name} ${ARGN})
   set_target_properties(${name} PROPERTIES FOLDER "Utils")
 macro(add_llvm_utility name)
   add_llvm_executable(${name} ${ARGN})
   set_target_properties(${name} PROPERTIES FOLDER "Utils")
+  if( LLVM_INSTALL_UTILS )
+    install (TARGETS ${name}
+      RUNTIME DESTINATION bin
+      COMPONENT ${name})
+    if (NOT CMAKE_CONFIGURATION_TYPES)
+      add_custom_target(install-${name}
+                        DEPENDS ${name}
+                        COMMAND "${CMAKE_COMMAND}"
+                                -DCMAKE_INSTALL_COMPONENT=${name}
+                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+    endif()
+  endif()
 endmacro(add_llvm_utility name)
 
 
 endmacro(add_llvm_utility name)