diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index ed3e1b8a07c1..ac59748993a1 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -391,6 +391,8 @@ option(LLVM_BUILD_TOOLS "Build the LLVM tools. If OFF, just generate build targets." ON) option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON) +option(LLVM_BUILD_UTILS + "Build LLVM utility binaries. If OFF, just generate build targets." ON) option(LLVM_BUILD_RUNTIME "Build the LLVM runtime libraries." ON) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 9f161ff95725..26e439600140 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -800,11 +800,16 @@ macro(add_llvm_example name) set_target_properties(${name} PROPERTIES FOLDER "Examples") endmacro(add_llvm_example name) - +# This is a macro that is used to create targets for executables that are needed +# for development, but that are not intended to be installed by default. macro(add_llvm_utility name) + if ( NOT LLVM_BUILD_UTILS ) + set(EXCLUDE_FROM_ALL ON) + endif() + add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) set_target_properties(${name} PROPERTIES FOLDER "Utils") - if( LLVM_INSTALL_UTILS ) + if( LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS ) install (TARGETS ${name} RUNTIME DESTINATION bin COMPONENT ${name})