-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[CMake] Handle clang in MSVC mode in GetHostTriple #116701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
38d6e3f
48a57b2
480feee
4653a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,7 +42,21 @@ function( get_host_triple var ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "powerpc-ibm-aix" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| else( MSVC ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS AND CMAKE_C_COMPILER_ID MATCHES "Clang" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "aarch64-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "armv7-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "x86_64-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "i686-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "x86_64-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set( value "i686-pc-windows-msvc" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" ) | |
| set( value "aarch64-pc-windows-msvc" ) | |
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" ) | |
| set( value "armv7-pc-windows-msvc" ) | |
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64" ) | |
| set( value "x86_64-pc-windows-msvc" ) | |
| elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86" ) | |
| set( value "i686-pc-windows-msvc" ) | |
| elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | |
| set( value "x86_64-pc-windows-msvc" ) | |
| else() | |
| set( value "i686-pc-windows-msvc" ) | |
| if(CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*") | |
| set(value "aarch64-pc-windows-msvc") | |
| elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*") | |
| set(value "armv7-pc-windows-msvc") | |
| elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64") | |
| set(value "x86_64-pc-windows-msvc") | |
| elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86") | |
| set(value "i686-pc-windows-msvc") | |
| elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | |
| set(value "x86_64-pc-windows-msvc") | |
| else() | |
| set(value "i686-pc-windows-msvc") |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to assume x86/x64 when CMAKE_C_COMPILER_ARCHITECTURE_ID isn't x86 or x64? Can we report an error instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed here? When operating in MSVC mode, CMake usually sets the
MSVCCMake variable, so this should hit the existing codepath at lines 5-18 above? And this is a bit weird, because CMake usually doesn't setCOMPILER_ARCHITECTURE_IDfor Clang (or GCC), but only for MSVC. I guess CMake might setCOMPILER_ARCHITECTURE_IDfor Clang-cl when operating in MSVC mode, but if we're invoking it asclang, notclang-clso that theMSVCvariable isn't set, it feels odd that CMake still would be settingCOMPILER_ARCHITECTURE_ID.Also I don't quite see why this needs to be as a separate step within the
else()clause here, why can't this be a toplevel case like the other ones?The condition,
CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYSalso feels quite contrieved for this case. I guess what you want to detect is "clang, targeting windows, probably in msvc mode (as we're past a check forMINGWfurther up)", and we generally don't want to check for the host unless we need to.The existing check for
CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYSis to pick out configurations where we can't run the generic detection shell script below.Can't we just extend the existing MSVC case at the top, e.g. something like
if (MSVC OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND WIN32 AND CMAKE_C_COMPILER_ARCHITECTURE_ID)or something along those lines, to specifically match the case we're looking for here?