This is a draft. It's pretty close and "should work". Needs a mulle-sde version 3.5.0 or better.
Install cross development package #
Get mulle-clang-mingw then build it:
1./build-all.sh \
2 --llvm-version=22.1.4 \
3 --llvm-repository='https://github.com/mulle-cc/mulle-clang-project.git"' \
4 /opt/mulle-clang-project-windows/21.1.4
Add cmake toolchain #
Edit and place this file into the projects cmake directory:
1# Toolchain file for cross-compiling to Windows via llvm-mingw + Clang
2
3# The target system
4set(CMAKE_SYSTEM_NAME Windows)
5# You may change this to i686, aarch64, etc
6set(CMAKE_SYSTEM_PROCESSOR x86_64)
7
8# Root of your llvm-mingw installation
9# Adjust this path to your installation
10# Hardcoded default
11set(DEFAULT_LLVM_MINGW_ROOT "/opt/mulle-clang-project-windows/21.1.4")
12
13# Check for cache variable override
14if(NOT DEFINED LLVM_MINGW_ROOT)
15 if(DEFINED ENV{LLVM_MINGW_ROOT})
16 set(LLVM_MINGW_ROOT $ENV{LLVM_MINGW_ROOT})
17 elseif(EXISTS "${DEFAULT_LLVM_MINGW_ROOT}")
18 set(LLVM_MINGW_ROOT "${DEFAULT_LLVM_MINGW_ROOT}")
19 else()
20 # Auto-detect the highest version under /opt/mulle-clang-project-windows
21 file(GLOB ALL_LLVM_MINGW "/opt/mulle-clang-project-windows/*")
22 set(HIGHEST_VERSION "")
23 foreach(dir ${ALL_LLVM_MINGW})
24 if(IS_DIRECTORY "${dir}")
25 get_filename_component(basename "${dir}" NAME)
26 if(basename MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
27 if(HIGHEST_VERSION STREQUAL "" OR basename VERSION_GREATER HIGHEST_VERSION)
28 set(HIGHEST_VERSION "${basename}")
29 endif()
30 endif()
31 endif()
32 endforeach()
33 if(HIGHEST_VERSION STREQUAL "")
34 message(FATAL_ERROR "Could not detect LLVM-Mingw installation. Set -DLLVM_MINGW_ROOT or LLVM_MINGW_ROOT environment variable.")
35 endif()
36 set(LLVM_MINGW_ROOT "/opt/mulle-clang-project-windows/${HIGHEST_VERSION}")
37 endif()
38endif()
39
40message(STATUS "Using LLVM-Mingw root: ${LLVM_MINGW_ROOT}")
41
42# Target triplet
43set(TRIPLET x86_64-w64-mingw32)
44
45# Compilers
46set(CMAKE_C_COMPILER ${LLVM_MINGW_ROOT}/bin/${TRIPLET}-clang)
47set(CMAKE_CXX_COMPILER ${LLVM_MINGW_ROOT}/bin/${TRIPLET}-clang++)
48set(CMAKE_RC_COMPILER ${LLVM_MINGW_ROOT}/bin/${TRIPLET}-windres)
49
50# Root path for finding target libs/includes
51set(CMAKE_FIND_ROOT_PATH
52 ${LLVM_MINGW_ROOT}
53 ${LLVM_MINGW_ROOT}/generic-w64-mingw32
54)
55
56# Search modes: programs on host, libs/includes on target
57# we also have programs in DEPENDENCY though, so we search both
58set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
59set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
60set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
61set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
62
63set( BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries for Windows by default too")
64set( CMAKE_STATIC_LIBRARY_SUFFIX ".a" CACHE STRING "Build and search static libraries with .a")
65
66# Optional flags
67set(CMAKE_CXX_FLAGS_INIT "-fuse-ld=lld")
68set(CMAKE_EXE_LINKER_FLAGS_INIT "-static")
Set up mulle-sde for cross compilation and execution #
Do this in the main project and also in the demo project:
test is not supporte yet #
Running tests with an emulator is not working yet.
1mulle-sde env --this-os set MULLE_CRAFT_PLATFORMS "linux:windows"
2mulle-sde env set MULLE_CRAFT_TOOLCHAIN__WINDOWS "toolchain-llvm-mingw-clang"
3mulle-sde env set MULLE_EMULATOR_WINDOWS "wine64"
last updated: