Alright, I figured it out. Here’s the toolchain file:
# CMake Toolchain file for crosscompiling on ARM.
# Target operating system name.
# Name of C compiler.
# Where to look for the target environment. (More paths can be added here)
# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
# Search headers and libraries in the target environment only.
CMAKE_LIBRARY_ARCHITECTURE, since that’s used to access libraries in
/usr/lib/<arch>, thinking it hadn’t been set right. But it was set.
Reading the documentation of
find_library, specifically the search strategy, clarified that it’ll search for libraries in the arch-specific directories first. It just didn’t in my case because I told it not to by setting
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY). My libs were obviously not in the root path, so this broke it all. Keeping that setting at its default
BOTH, CMake looked in the right place immediately and found my aarch64 libs, and compiled for arm64 correctly.
I hope this is helpful to someone!