When the mlir-tblgen tool is set up, the MLIR_TABLEGEN_EXE variable is set,
which either points to the mlir-tblgen tool built in the current cmake build,
or points to one built in a nested cmake build (if cross conpiling, or if building
with e.g. LLVM_OPTIMIZED_TABLEGEN.
The MLIR_TABLEGEN_EXE variable is only set within the scope of the mlir/CMakeLists.txt
file, so it's unavailable in sibling level projects such as flang.
Set the MLIR_TABLEGEN_EXE and the MLIR_TABLEGEN_TARGET variables as global,
so that flang can use them properly without guessing.
My cmake-fu is pretty weak, so I'm open to suggestions on how to do this better.
Shouldn't the issue be fixed in add_tablegen() as it says in the comment above so we are not working around that further by re-setting into the cache here.