From d608b2aedbf60a326f48cfc3162dd3ece232556a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Wed, 30 Jul 2025 12:05:22 +0300 Subject: [PATCH] ci: Add a toolchain file for (cross) compilation for aarch64-w64-mingw32 Contrary to the existing toolchain files, this doesn't hardcode CMAKE_FIND_ROOT_PATH to a location in /usr, but locates the compiler from the path, and picks a sysroot adjacent to it - allowing using a compiler installed in any path. This uses a compiler named "${TOOLCHAIN_PREFIX}-gcc" - toolchains such as llvm-mingw do provide cross tools named "-gcc" for compatibility, even if they use Clang. --- toolchains/aarch64-w64-mingw32.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 toolchains/aarch64-w64-mingw32.cmake diff --git a/toolchains/aarch64-w64-mingw32.cmake b/toolchains/aarch64-w64-mingw32.cmake new file mode 100644 index 00000000..558ac496 --- /dev/null +++ b/toolchains/aarch64-w64-mingw32.cmake @@ -0,0 +1,13 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX aarch64-w64-mingw32) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +find_program(CC_LOCATION ${CMAKE_C_COMPILER} + NO_PACKAGE_ROOT_PATH + NO_CMAKE_FIND_ROOT_PATH) +get_filename_component(CC_DIR "${CC_LOCATION}" DIRECTORY) +get_filename_component(PREFIX "${CC_DIR}/../${TOOLCHAIN_PREFIX}" ABSOLUTE) +set(CMAKE_FIND_ROOT_PATH ${PREFIX}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -- 2.47.2