diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake index 13a75689d3c..d315a427c0c 100644 --- a/cmake/modules/TableGen.cmake +++ b/cmake/modules/TableGen.cmake @@ -85,6 +85,16 @@ macro(add_tablegen target project) add_llvm_utility(${target} ${ARGN}) set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) + # For Xcode builds, symlink bin/ to bin// so that + # a separately-configured Clang project can still find llvm-tblgen. + if (XCODE) + add_custom_target(${target}-top ALL + ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${target}${CMAKE_EXECUTABLE_SUFFIX} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX} + DEPENDS ${target}) + endif () + set(${project}_TABLEGEN "${target}" CACHE STRING "Native TableGen executable. Saves building one when cross-compiling.")