Crosscompiling issues going from Ubuntu terminal to RPI4

Hello all,
Recently I’ve been trying to crosscompile on Ubuntu terminal for a RPI4. My cmake command is quite simple, it uses the aarch64 gnu toolchain provided by opencv and sets the build type to release. However I keep running into the error:
Required baseline optimization is not supported: NEON
From what I believe this error is caused as my Intel cpu probably does not have NEON support while the cpu on the Pi does.

Is there a way to still cmake for opencv with the optimizations enabled for the pi when running cmake on the ubuntu host?

in crosscompilation, that doesn’t matter. the toolchain for the target is used for compilation. this has no connection to the host that runs the compilation.

besides, NEON only exists on ARM, not on x86. entirely different architectures. they have nothing in common.

Ah okay so that couldn’t be the issue. Do you have any idea why the cmake error occurs for my situation then? I’ve been looking on the internet and the forum for a while now but can’t find the solution.

Maybe posting the specific error is helpful so:

CMake Error at cmake/OpenCVCompilerOptimizations.cmake:564 (message):
  Required baseline optimization is not supported: NEON
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:324 (include)
  CMakeLists.txt:652 (include)

I have the same issue, ignoring the obvious toolchain argument, are there flags that should be set that I’m missing?

It seems that I have solved the issue by downloading the specific aarch64 gcc and g++ compilers instead of normally just install gcc and g++

apt-get install gcc-aarch64*-*-*
apt-get install g++-aarch64*-*-*