Skip to content

Commit 0338fd9

Browse files
authored
Unblock Visual Studio ARM64EC target builds. Disable inclusion of SSE headers for non x86 targets. (#2631)
- Use `CMAKE_VS_PLATFORM_NAME` in tandem with `CMAKE_SYSTEM_PROCESSOR` to set `CLConform_TARGET_ARCH`. `CMAKE_VS_PLATFORM_NAME` provides cross compilation information that `CMAKE_SYSTEM_PROCESSOR` lacks, like targeting `ARM64EC`. - Curb the inclusion of `SSE` headers when targeting non-x86 targets.
1 parent 4e3f16b commit 0338fd9

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ include(CheckFunctionExists)
8181
include(CheckIncludeFiles)
8282
include(CheckCXXCompilerFlag)
8383

84-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
85-
set(CLConform_TARGET_ARCH ARM)
86-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
84+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)" OR
85+
CMAKE_VS_PLATFORM_NAME MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
8786
set(CLConform_TARGET_ARCH ARM64)
87+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
88+
set(CLConform_TARGET_ARCH ARM)
8889
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
8990
set(CLConform_TARGET_ARCH x86_64)
9091
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*")
@@ -141,8 +142,12 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
141142
add_cxx_flag_if_supported(-frounding-math)
142143
endif()
143144
else()
144-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE__")
145-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE__")
145+
# Curb the inclusion of SSE headers when compiling for non x86 targets
146+
if(${CLConform_TARGET_ARCH} STREQUAL "x86_64" OR ${CLConform_TARGET_ARCH}
147+
STREQUAL "x86")
148+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE__")
149+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE__")
150+
endif()
146151
endif()
147152

148153
# Set a module's COMPILE_FLAGS if using gcc or clang.

0 commit comments

Comments
 (0)