Avoid false positives from check_symbol_exists()

When cross-compiling what’s a good practice for using check_symbol_exists against only the toolchain, that is avoiding that it finds the symbol on the host system as a false positive?
To elaborate, today we do those checks in the main file so they can also be made when you are not cross-compiling, so I guess that would mean 1) do the check in the toolchain file and then 2) avoid doing it in the main file if CMAKE_CROSSCOMPILING is set? Any better suggestions?

Why would it be any different? If the compiler is a cross-compiler, it shouldn’t be targeting the host, so why would it interfere if the toolchain is properly configured?

Thank you.
I guess the toolchain is thus not properly configured as the host symbols seems to leak over. What is the easiest way to avoid that? Setting CMAKE_SYSROOT?

I’m not completely sure as I don’t do cross-compiles that much myself (and when I have done it, it hasn’t been in a case where the target and host libraries would even link due to arch/platform differences to give a bogus answer here).

Have you checked the settings mentioned in the chapter “Cross Compiling for Linux” (mainly the CMAKE_FIND_ROOT_PATH_MODE_* ones).

This is a bit embarrassing but I think the issue is that I have instances were the supplied toolchain is incomplete and we therefore build with a similar more generic one that might have symbols the original supplier does not expect. The toolchain in itself is probably setup correct, but if you use toolchain B instead of toolchain A of course you’re asking for trouble.
So in terms of cmake it’s probably all good, just a suboptimal process around it.
Sorry for the unnecessary question!