Fix CMake Android cross-compilation on Windows. (#3459)
Fixes https://github.com/google/iree/issues/3457
* CMake targets shouldn't have executable suffixes (e.g. `.exe`) in them and `flatcc_cli.exe` was getting copied to `flatcc_cli` (dropping the extension where it matters).
* `iree_get_build_command` should take a target name, not an executable name (alias).
The generated commands are of the format:
```
C:/Program Files/CMake/bin/cmake.exe;--build;D:/dev/projects/iree-build-android/host;--target;iree-tblgen;-- config;$<CONFIG>
```
Where `--target iree-tblgen` can't find the target on my system, but `--target iree_tools_iree-tblgen` can.
I tried using `get_target_property(... ALIASED_TARGET)` but I get this error:
`get_target_property() called with non-existent target "iree-translate"`
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 701ba0d..472cea2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -394,8 +394,8 @@
if(CMAKE_CROSSCOMPILING)
# We need flatc to generate some source code. When cross-compiling, we need
# to make sure the flatc binary is configured under host environment.
- iree_declare_host_excutable(flatc BUILDONLY)
- iree_declare_host_excutable(flatcc_cli BUILDONLY)
+ iree_declare_host_excutable(flatc "flatc" BUILDONLY)
+ iree_declare_host_excutable(flatcc_cli "flatcc_cli" BUILDONLY)
# Set the FLATBUFFERS_FLATC_EXECUTABLE. It controls where to find the flatc
# binary in BuildFlatBuffers().
@@ -414,7 +414,7 @@
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/third_party/flatcc/bin/flatcc${IREE_HOST_EXECUTABLE_SUFFIX}"
- "${IREE_HOST_BINARY_ROOT}/bin/flatcc_cli"
+ "${IREE_HOST_BINARY_ROOT}/bin/flatcc_cli${IREE_HOST_EXECUTABLE_SUFFIX}"
DEPENDS iree_host_build_flatcc_cli
COMMENT "Installing host flatcc..."
)