Also, avoid using environment variables to prevent interference to
other commands run by CMake. Only CMAKE_C(XX)_COMPILER is sufficient
to build flutter.
* Change how sysroot is passed to CMake.
In the CMake documentation, it is specified that the
CMAKE_SYSROOT variable should be passed in toolchain
file variable. It has no effect to set this variable
in CMakeLists.txt like the current implementation.
(This is why CMAKE_FIND_ROOT_PATH is needed.)
The --sysroot option is not passed to the compiler in
the current approach.
This commit, instead, sets the sysroot variable in CMake
command line arguments. This makes it effective, and no
CMAKE_FIND_ROOT_PATH is needed.
Moreover, it is not the duty of architecture to decide
whether we are cross-compiling or not. For example, if
I compile this on my Linux VM on mac M1 to i.MX8 processor,
both host and target has the same arm64 architecture, but
they doesn't share the same sysroot, so the standard
cross-compile procedure should be followed. So, the real
difference for cross-compile is that whether we share
the same sysroot, rather than whether we have the same arch.
So this commit changes the detection method to compare sysroot.