]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
ci: Add a toolchain file for (cross) compilation for aarch64-w64-mingw32
authorMartin Storsjö <martin@martin.st>
Wed, 30 Jul 2025 09:05:22 +0000 (12:05 +0300)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 Aug 2025 17:38:01 +0000 (19:38 +0200)
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 [new file with mode: 0644]

diff --git a/toolchains/aarch64-w64-mingw32.cmake b/toolchains/aarch64-w64-mingw32.cmake
new file mode 100644 (file)
index 0000000..558ac49
--- /dev/null
@@ -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)