[CMake] Honor IREE_HOST_BIN_DIR for compiler TableGen (#25049) Honor `IREE_HOST_BIN_DIR` when locating `iree-tblgen` for compiler builds (`IREE_BUILD_COMPILER=ON`). `IREE_TABLEGEN_EXE` was set to `$<TARGET_FILE:iree-tblgen>`. With `IREE_ENABLE_THREADING=OFF`, `tools/CMakeLists.txt` hits `return()` before the `iree-tblgen` target is defined, so that reference fails at generate time. The existing `IREE_HOST_BIN_DIR` import in `tools/CMakeLists.txt` only runs when `IREE_BUILD_COMPILER=OFF`. In `build_tools/cmake/iree_copts.cmake`, when `IREE_HOST_BIN_DIR` is set, find `iree-tblgen` with `find_program(... REQUIRED)`. Otherwise keep the existing target-based behavior. Signed-off-by: anutosh491 <andersonbhat491@gmail.com>
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake index b9de289..2aefc44 100644 --- a/build_tools/cmake/iree_copts.cmake +++ b/build_tools/cmake/iree_copts.cmake
@@ -586,5 +586,16 @@ if(IREE_BUILD_COMPILER) # iree-tblgen is not defined using the add_tablegen mechanism as other # TableGen tools in LLVM. - set(IREE_TABLEGEN_EXE "$<TARGET_FILE:iree-tblgen>") + if(IREE_HOST_BIN_DIR) + find_program(IREE_TABLEGEN_EXE + NAMES iree-tblgen + PATHS "${IREE_HOST_BIN_DIR}" + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + NO_CACHE + REQUIRED + ) + else() + set(IREE_TABLEGEN_EXE "$<TARGET_FILE:iree-tblgen>") + endif() endif()