I think tomorrow I will take the CMakeLists.txt files, generate GNU Makefiles from them, and then dismantle the GNU Makefiles so that I have simple one-liner commands like:
Then I’ll just collect all these one-liner commands together and put them in a script, “make.sh”.
I even tried editing the cmake source code for “try_compile” in order to try get rid of the error about not being able to find an intermediary executable file, but I didn’t get anywhere.
I haven’t heard of anyone successfully cross-compiling with cmake on Linux from x64 to aarch64.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# specify the cross compiler
set(CMAKE_C_COMPILER /somewhere/bin/aarch64-unknown-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /somewhere/bin/aarch64-unknown-linux-gnueabi-g++)
# where is the target environment
set(CMAKE_FIND_ROOT_PATH /somewhere/sysroot)
set(CMAKE_SYSROOT /somewhere/sysroot)
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# automatically use the cross-wrapper for pkg-config
set(PKG_CONFIG_EXECUTABLE "/somewhere/bin/aarch64-unknown-linux-gnueabi-pkg-config" CACHE FILEPATH "pkg-config executable")
The point is that I have an actual sysroot, i.e. everything that belongs to the aarch64 platform is in that folder. This is different from your mixed setup.
I gathered. My workaround is to copy all aarch64 libs into my “sysroot”, together with the headers. It builds, but there’s got to be a cleaner way in CMake for Ubuntu multi arch. Thanks for replying!