1 # Returns the host triple.
4 function( get_host_triple var )
6 if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
7 set( value "aarch64-pc-windows-msvc" )
8 elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
9 set( value "armv7-pc-windows-msvc" )
10 elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64" )
11 set( value "x86_64-pc-windows-msvc" )
12 elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86" )
13 set( value "i686-pc-windows-msvc" )
14 elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
15 set( value "x86_64-pc-windows-msvc" )
17 set( value "i686-pc-windows-msvc" )
19 elseif( MINGW AND NOT MSYS )
20 # CMake doesn't provide COMPILER_ARCHITECTURE_ID for Clang/GCC,
21 # but it does for MSVC.
22 if( CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ARM.*" )
23 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
24 set( value "aarch64-w64-windows-gnu" )
26 set( value "armv7-w64-windows-gnu" )
29 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
30 set( value "x86_64-w64-windows-gnu" )
32 set( value "i686-w64-windows-gnu" )
35 elseif( CMAKE_SYSTEM_NAME MATCHES "OS390" )
36 set( value "s390x-ibm-zos" )
37 elseif( CMAKE_SYSTEM_NAME STREQUAL AIX )
38 # We defer to dynamic detection of the host AIX version.
39 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
40 set( value "powerpc64-ibm-aix" )
42 set( value "powerpc-ibm-aix" )
45 if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
46 message(WARNING "unable to determine host target triple")
48 set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
49 execute_process(COMMAND sh ${config_guess}
51 OUTPUT_VARIABLE TT_OUT
52 OUTPUT_STRIP_TRAILING_WHITESPACE)
53 if( NOT TT_RV EQUAL 0 )
54 message(FATAL_ERROR "Failed to execute ${config_guess}")
55 endif( NOT TT_RV EQUAL 0 )
56 set( value ${TT_OUT} )
59 set( ${var} ${value} PARENT_SCOPE )
60 endfunction( get_host_triple var )