1
1
message (STATUS "Configuring with \" ${CMAKE_CURRENT_LIST_FILE} \" toolchain" )
2
2
3
+ if (CMAKE_VERSION VERSION_LESS "3.31.0" )
4
+ message (FATAL_ERROR "CMake version must be at least 3.31.0 to use this toolchain file!" )
5
+ endif ()
6
+
3
7
if (NOT CMAKE_GENERATOR MATCHES "Ninja*" )
4
8
message (FATAL_ERROR "CMAKE_GENERATOR = \" ${CMAKE_GENERATOR} \" is unsupported, use Ninja (single or multi config) generators!" )
5
9
endif ()
6
10
7
- cmake_path (CONVERT $ENV{WINDOWS_SDK_VERSION} TO_CMAKE_PATH_LIST WINDOWS_SDK_VERSION NORMALIZE )
8
11
cmake_path (CONVERT $ENV{CMAKE_WINDOWS_KITS_10_DIR} TO_CMAKE_PATH_LIST WINDOWS_KITS_10_DIR NORMALIZE )
12
+ cmake_path (CONVERT $ENV{WINDOWS_SDK_VERSION} TO_CMAKE_PATH_LIST WINDOWS_SDK_VERSION NORMALIZE )
9
13
cmake_path (CONVERT $ENV{MSVC_TOOLSET_DIR} TO_CMAKE_PATH_LIST MSVC_TOOLSET_DIR NORMALIZE )
10
14
11
- message (STATUS "WINDOWS_KITS_10_DIR = \" ${WINDOWS_KITS_10_DIR} \" " )
12
- message (STATUS "WINDOWS_SDK_VERSION = \" ${WINDOWS_SDK_VERSION} \" " )
13
- message (STATUS "MSVC_TOOLSET_DIR = \" ${MSVC_TOOLSET_DIR} \" " )
15
+ if (VERBOSE )
16
+ message (STATUS "WINDOWS_KITS_10_DIR = \" ${WINDOWS_KITS_10_DIR} \" " )
17
+ message (STATUS "WINDOWS_SDK_VERSION = \" ${WINDOWS_SDK_VERSION} \" " )
18
+ message (STATUS "MSVC_TOOLSET_DIR = \" ${MSVC_TOOLSET_DIR} \" " )
19
+ endif ()
14
20
15
21
set (CMAKE_SYSTEM_NAME Windows )
22
+ set (CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR} )
16
23
17
- # TODO: one could allow for cross platform builds
18
- # and more archs but I hardcode temporary windows-x86_64
19
- set (CMAKE_SYSTEM_PROCESSOR x86_64 )
24
+ if (ARCH )
25
+ if (ARCH MATCHES "x64" )
26
+ elseif (ARCH MATCHES "arm64" )
27
+ set (CMAKE_SYSTEM_PROCESSOR arm64 )
28
+ # never tested it but I'm pretty sure _COMPILER needs to be updated depending on target ARCH
29
+ message (FATAL_ERROR "TODO, Cross compilation requires ARM64 build tools compoment and updates to the toolchain file!" )
30
+ else ()
31
+ message (STATUS "Unsupported ARCH = \" ${ARCH} \" " )
32
+ message (FATAL_ERROR "Supported ARCH = \" x64\" , \" arm64\" " )
33
+ endif ()
34
+ else ()
35
+ set (ARCH x64 )
36
+ endif ()
20
37
21
38
set (LIB
22
- "${WINDOWS_KITS_10_DIR} /Lib/${WINDOWS_SDK_VERSION} /ucrt/x64 "
23
- "${WINDOWS_KITS_10_DIR} /Lib/${WINDOWS_SDK_VERSION} /um/x64 "
24
- "${MSVC_TOOLSET_DIR} /lib/x64 "
39
+ "${WINDOWS_KITS_10_DIR} /Lib/${WINDOWS_SDK_VERSION} /ucrt/${ARCH} "
40
+ "${WINDOWS_KITS_10_DIR} /Lib/${WINDOWS_SDK_VERSION} /um/${ARCH} "
41
+ "${MSVC_TOOLSET_DIR} /lib/${ARCH} "
25
42
)
26
43
27
44
set (INCLUDE
@@ -48,15 +65,15 @@ endfunction()
48
65
_VALIDATE_ENV_V_ (LIB )
49
66
_VALIDATE_ENV_V_ (INCLUDE )
50
67
51
- set (CMAKE_C_COMPILER "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /cl.exe" )
52
- set (CMAKE_CXX_COMPILER "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /cl.exe" )
53
- set (CMAKE_ASM_COMPILER "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /cl.exe" )
54
- set (CMAKE_ASM_MASM_COMPILER "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /ml64.exe" )
68
+ set (CMAKE_C_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /cl.exe" )
69
+ set (CMAKE_CXX_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /cl.exe" )
70
+ set (CMAKE_ASM_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /cl.exe" )
71
+ set (CMAKE_ASM_MASM_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /ml64.exe" )
55
72
find_program (CMAKE_ASM_NASM_COMPILER nasm HINTS ENV PATH ENV NASM_DIR NO_CACHE REQUIRED )
56
- set (CMAKE_RC_COMPILER "${WINDOWS_KITS_10_DIR} /bin/${WINDOWS_SDK_VERSION} /x64 /rc.exe" )
57
- set (CMAKE_LINKER "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /link.exe" )
58
- set (CMAKE_AR "${MSVC_TOOLSET_DIR} /bin/Hostx64/x64 /lib.exe" )
59
- set (CMAKE_MT "${WINDOWS_KITS_10_DIR} /bin/${WINDOWS_SDK_VERSION} /x64 /mt.exe" )
73
+ set (CMAKE_RC_COMPILER "${WINDOWS_KITS_10_DIR} /bin/${WINDOWS_SDK_VERSION} /${ARCH} /rc.exe" )
74
+ set (CMAKE_LINKER "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /link.exe" )
75
+ set (CMAKE_AR "${MSVC_TOOLSET_DIR} /bin/Host ${ARCH} / ${ARCH} /lib.exe" )
76
+ set (CMAKE_MT "${WINDOWS_KITS_10_DIR} /bin/${WINDOWS_SDK_VERSION} /${ARCH} /mt.exe" )
60
77
61
78
macro (_UPDATE_STANDARD_DIRECTORIES_ WHAT VARV )
62
79
set (CMAKE_C_STANDARD_${WHAT}_DIRECTORIES ${VARV} )
0 commit comments