Windows: Detect both ARM64 and ARM64EC with Clang -marm64x flag

Both architectures appear in object files, so add both of them to
`CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID` too.  We already do this for
multiple `CMAKE_OSX_ARCHITECTURES` on Apple platforms.

Fixes: #28067
This commit is contained in:
Brad King
2026-09-01 17:47:27 -04:00
parent b56fabdb46
commit ea378e104d
2 changed files with 9 additions and 3 deletions
@@ -6,8 +6,13 @@ CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID
:ref:`List <CMake Language Lists>` of identifiers indicating the
target architecture(s) of the compiler for language ``<LANG>``.
Typically the list has one entry unless :variable:`CMAKE_OSX_ARCHITECTURES`
lists multiple architectures.
Typically the list has one entry unless the compiler stores multiple
architectures in each object file. For example:
* The build targets an Apple platform with
:variable:`CMAKE_OSX_ARCHITECTURES` listing multiple architectures.
* The build targets Windows ARM64 with the MSVC ABI using Clang with
the ``-marm64x`` flag.
Possible values for each platform are documented in the following sections.
+2 -1
View File
@@ -1139,7 +1139,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(PLATFORM_ID "${CMAKE_MATCH_1}")
endif()
if("${info}" MATCHES "INFO:arch\\[([^]\"]*)\\]")
set(ARCHITECTURE_ID "${CMAKE_MATCH_1}")
list(APPEND ARCHITECTURE_ID "${CMAKE_MATCH_1}")
endif()
if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]")
string(REGEX REPLACE "^0+([0-9]+)" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
@@ -1225,6 +1225,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")
set(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}")
list(SORT ARCHITECTURE_ID)
set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}")