Better support for cmake 3.26 and Windows ARM64 (#15704)

### Description

In #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}.
This commit is contained in:
Changming Sun 2023-04-27 10:25:45 -07:00 committed by GitHub
parent 2e1f92a986
commit d3e8d7a70d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -2,7 +2,9 @@
# Licensed under the MIT License.
# Minimum CMake required
# TODO: actually we need cmake 3.26+ on Windows but QNN EP's build machine doesn't have it
cmake_minimum_required(VERSION 3.24)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)

View file

@ -222,7 +222,6 @@ endmacro()
#Set global compile flags for all the source code(including third_party code like protobuf)
#This section must be before any add_subdirectory, otherwise build may fail because /MD,/MT mismatch
if (MSVC)
enable_language(ASM_MASM)
if (CMAKE_GENERATOR_PLATFORM)
# Multi-platform generator
set(onnxruntime_target_platform ${CMAKE_GENERATOR_PLATFORM})
@ -231,18 +230,37 @@ if (MSVC)
endif()
if (onnxruntime_target_platform STREQUAL "ARM64")
set(onnxruntime_target_platform "ARM64")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
enable_language(ASM_MARMASM)
else()
enable_language(ASM_MASM)
endif()
elseif (onnxruntime_target_platform STREQUAL "ARM64EC")
set(onnxruntime_target_platform "ARM64EC")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
enable_language(ASM_MARMASM)
else()
enable_language(ASM_MASM)
endif()
elseif (onnxruntime_target_platform STREQUAL "ARM" OR CMAKE_GENERATOR MATCHES "ARM")
set(onnxruntime_target_platform "ARM")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.26.0")
enable_language(ASM_MARMASM)
else()
enable_language(ASM_MASM)
endif()
elseif (onnxruntime_target_platform STREQUAL "x64" OR onnxruntime_target_platform STREQUAL "x86_64" OR onnxruntime_target_platform STREQUAL "AMD64" OR CMAKE_GENERATOR MATCHES "Win64")
set(onnxruntime_target_platform "x64")
enable_language(ASM_MASM)
elseif (onnxruntime_target_platform STREQUAL "Win32" OR onnxruntime_target_platform STREQUAL "x86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686")
set(onnxruntime_target_platform "x86")
enable_language(ASM_MASM)
if (NOT onnxruntime_BUILD_WEBASSEMBLY)
message("Enabling SAFESEH for x86 build")
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh")
endif()
else()
message(FATAL_ERROR "Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
endif()