Skip to content

Commit 44a12bb

Browse files
Specify 'CMAKE_<LANG>_COMPILER_TARGET' reflecting CMAKE_SYSTEM_PROCESSOR (#157)
1 parent 4a53b16 commit 44a12bb

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ jobs:
4040
- windows-ninja-msvc-arm64
4141
- windows-ninja-msvc-host
4242
- windows-ninja-clang-x64
43+
- windows-ninja-clang-arm64
4344
- windows-ninja-clangcl-x64
45+
- windows-ninja-clangcl-arm64
4446
- windows-fastbuild-msvc-x64
4547
- windows-vs2022-x64
4648
- windows-vs2022-arm64

Windows.Clang.toolchain.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ if(NOT CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE)
197197
message(FATAL_ERROR "Unable identify compiler architecture for CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
198198
endif()
199199

200+
# Map CMAKE_SYSTEM_PROCESSOR values to CMAKE_<LANG>_COMPILER_TARGET values that identifies the target architecture
201+
# for the compiler.
202+
foreach(LANG C CXX)
203+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL X86)
204+
set(CMAKE_${LANG}_COMPILER_TARGET "i686-pc-windows-msvc")
205+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64)
206+
set(CMAKE_${LANG}_COMPILER_TARGET "x86_64-pc-windows-msvc")
207+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL ARM)
208+
set(CMAKE_${LANG}_COMPILER_TARGET "armv7a-pc-windows-msvc")
209+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64)
210+
set(CMAKE_${LANG}_COMPILER_TARGET "aarch64-pc-windows-msvc")
211+
else()
212+
message(FATAL_ERROR "Unable identify compiler architecture for CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
213+
endif()
214+
endforeach()
215+
200216
if(NOT CMAKE_C_COMPILER)
201217
set(TOOLCHAIN_C_COMPILER_EXE clang.exe)
202218
if(CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL MSVC)

example/CMakePresets.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,28 @@
125125
"CLANG_TIDY_CHECKS": "bugprone*,-bugprone-easily-swappable-parameters"
126126
}
127127
},
128+
{
129+
"name": "windows-ninja-clang-arm64",
130+
"inherits": "windows-ninja-clang",
131+
"cacheVariables": {
132+
"CMAKE_SYSTEM_PROCESSOR": "ARM64",
133+
"CLANG_TIDY_CHECKS": "bugprone*,-bugprone-easily-swappable-parameters"
134+
}
135+
},
128136
{
129137
"name": "windows-ninja-clangcl-x64",
130138
"inherits": "windows-ninja-clangcl",
131139
"cacheVariables": {
132140
"CMAKE_SYSTEM_PROCESSOR": "AMD64"
133141
}
134142
},
143+
{
144+
"name": "windows-ninja-clangcl-arm64",
145+
"inherits": "windows-ninja-clangcl",
146+
"cacheVariables": {
147+
"CMAKE_SYSTEM_PROCESSOR": "ARM64"
148+
}
149+
},
135150
{
136151
"name": "ewdk",
137152
"displayName": "EWDK configuration",
@@ -235,10 +250,18 @@
235250
"name": "windows-ninja-clang-x64",
236251
"configurePreset": "windows-ninja-clang-x64"
237252
},
253+
{
254+
"name": "windows-ninja-clang-arm64",
255+
"configurePreset": "windows-ninja-clang-arm64"
256+
},
238257
{
239258
"name": "windows-ninja-clangcl-x64",
240259
"configurePreset": "windows-ninja-clangcl-x64"
241260
},
261+
{
262+
"name": "windows-ninja-clangcl-arm64",
263+
"configurePreset": "windows-ninja-clangcl-arm64"
264+
},
242265
{
243266
"name": "windows-fastbuild-msvc-x64",
244267
"configurePreset": "windows-fastbuild-msvc-x64"

example/build.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
[CmdletBinding()]
77
param (
88
[ValidateSet('windows-ninja-msvc-x64', 'windows-ninja-msvc-x64-spectre', 'windows-ninja-msvc-x86',
9-
'windows-ninja-msvc-arm64', 'windows-ninja-msvc-host', 'windows-ninja-clang-x64',
10-
'windows-ninja-clangcl-x64', 'windows-fastbuild-msvc-x64', 'windows-vs2022-x64',
11-
'windows-vs2022-arm64')]
9+
'windows-ninja-msvc-arm64', 'windows-ninja-msvc-host',
10+
'windows-ninja-clang-x64', 'windows-ninja-clang-arm64',
11+
'windows-ninja-clangcl-x64', 'windows-ninja-clangcl-arm64',
12+
'windows-fastbuild-msvc-x64',
13+
'windows-vs2022-x64', 'windows-vs2022-arm64'
14+
)]
1215
$Presets = @('windows-ninja-msvc-host'),
1316

1417
[ValidateSet('Debug', 'Release', 'RelWithDebInfo')]

0 commit comments

Comments
 (0)