Skip to content

Commit 2970a75

Browse files
snnnShukantPal
authored andcommitted
Better support for cmake 3.26 and Windows ARM64 (microsoft#15704)
### Description In microsoft#8953 I introduced a change in our onnxruntime_mlas.cmake that it enables "ASM_MASM" cmake language for all Windows build. ```cmake enable_language(ASM_MASM) ``` Before the change, it is only enabled when onnxruntime_target_platform equals to x64. However, cmake 3.26 added a new language: ASM_MARMASM. According to cmake's manual, ASM_MASM is for Microsoft Assembler ASM_MARMASM is for Microsoft ARM Assembler. This one is new in cmake 3.26. We should choose the right one according to ${onnxruntime_target_platform}.
1 parent 4155183 commit 2970a75

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

cmake/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Licensed under the MIT License.
33

44
# Minimum CMake required
5+
# TODO: actually we need cmake 3.26+ on Windows but QNN EP's build machine doesn't have it
56
cmake_minimum_required(VERSION 3.24)
7+
68
cmake_policy(SET CMP0069 NEW)
79
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
810

cmake/adjust_global_compile_flags.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ endmacro()
222222
#Set global compile flags for all the source code(including third_party code like protobuf)
223223
#This section must be before any add_subdirectory, otherwise build may fail because /MD,/MT mismatch
224224
if (MSVC)
225-
enable_language(ASM_MASM)
226225
if (CMAKE_GENERATOR_PLATFORM)
227226
# Multi-platform generator
228227
set(onnxruntime_target_platform ${CMAKE_GENERATOR_PLATFORM})
@@ -231,18 +230,37 @@ if (MSVC)
231230
endif()
232231
if (onnxruntime_target_platform STREQUAL "ARM64")
233232
set(onnxruntime_target_platform "ARM64")
233+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
234+
enable_language(ASM_MARMASM)
235+
else()
236+
enable_language(ASM_MASM)
237+
endif()
234238
elseif (onnxruntime_target_platform STREQUAL "ARM64EC")
235239
set(onnxruntime_target_platform "ARM64EC")
240+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
241+
enable_language(ASM_MARMASM)
242+
else()
243+
enable_language(ASM_MASM)
244+
endif()
236245
elseif (onnxruntime_target_platform STREQUAL "ARM" OR CMAKE_GENERATOR MATCHES "ARM")
237246
set(onnxruntime_target_platform "ARM")
247+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
248+
enable_language(ASM_MARMASM)
249+
else()
250+
enable_language(ASM_MASM)
251+
endif()
238252
elseif (onnxruntime_target_platform STREQUAL "x64" OR onnxruntime_target_platform STREQUAL "x86_64" OR onnxruntime_target_platform STREQUAL "AMD64" OR CMAKE_GENERATOR MATCHES "Win64")
239253
set(onnxruntime_target_platform "x64")
254+
enable_language(ASM_MASM)
240255
elseif (onnxruntime_target_platform STREQUAL "Win32" OR onnxruntime_target_platform STREQUAL "x86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686")
241256
set(onnxruntime_target_platform "x86")
257+
enable_language(ASM_MASM)
242258
if (NOT onnxruntime_BUILD_WEBASSEMBLY)
243259
message("Enabling SAFESEH for x86 build")
244260
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh")
245261
endif()
262+
else()
263+
message(FATAL_ERROR "Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
246264
endif()
247265

248266

0 commit comments

Comments
 (0)