diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake --- a/llvm/cmake/modules/TableGen.cmake +++ b/llvm/cmake/modules/TableGen.cmake @@ -113,9 +113,6 @@ set(LLVM_ENABLE_OBJLIB ON) endif() - add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) - set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) - set(${project}_TABLEGEN "${target}" CACHE STRING "Native TableGen executable. Saves building one when cross-compiling.") @@ -125,7 +122,7 @@ if(LLVM_USE_HOST_TOOLS) if( ${${project}_TABLEGEN} STREQUAL "${target}" ) - build_native_tool(${target} ${project}_TABLEGEN_EXE DEPENDS ${target}) + build_native_tool(${target} ${project}_TABLEGEN_EXE) set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE) add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) @@ -138,9 +135,18 @@ TARGET LLVM-tablegen-host) add_dependencies(${project}-tablegen-host LLVM-tablegen-host) endif() + + # If we're using the host tablegen, and utils were not requested, we have no + # need to build this tablegen. + if ( NOT LLVM_BUILD_UTILS ) + set(EXCLUDE_FROM_ALL ON) + endif() endif() endif() + add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) + if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY) set(export_to_llvmexports) if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR