llvm.org GIT mirror llvm / 9136f21
Undo an over zealous rename. This bit of the CMake build really is dealing in the host triple, be honest about it and document the decision to default the target triple to the host triple unless overridden. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148822 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 7 years ago
4 changed file(s) with 38 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
286286
287287 check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
288288
289 include(GetTargetTriple)
290 get_target_triple(LLVM_DEFAULT_TARGET_TRIPLE)
291
289 include(GetHostTriple)
290 get_host_triple(LLVM_HOST_TRIPLE)
291
292 # By default, we target the host, but this can be overridden at CMake
293 # invocation time.
294 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}")
292295 set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
293296
294297 # Determine the native architecture.
295298 string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
296299 if( LLVM_NATIVE_ARCH STREQUAL "host" )
297 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_DEFAULT_TARGET_TRIPLE})
300 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
298301 endif ()
299302
300303 if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
3131 PATTERN LLVMConfig.cmake EXCLUDE
3232 PATTERN LLVMConfigVersion.cmake EXCLUDE
3333 PATTERN LLVM-Config.cmake EXCLUDE
34 PATTERN GetTargetTriple.cmake EXCLUDE
34 PATTERN GetHostTriple.cmake EXCLUDE
3535 PATTERN VersionFromVCS.cmake EXCLUDE
3636 PATTERN CheckAtomic.cmake EXCLUDE)
0 # Returns the host triple.
1 # Invokes config.guess
2
3 function( get_host_triple var )
4 if( MSVC )
5 if( CMAKE_CL_64 )
6 set( value "x86_64-pc-win32" )
7 else()
8 set( value "i686-pc-win32" )
9 endif()
10 elseif( MINGW AND NOT MSYS )
11 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
12 set( value "x86_64-w64-mingw32" )
13 else()
14 set( value "i686-pc-mingw32" )
15 endif()
16 else( MSVC )
17 set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess)
18 execute_process(COMMAND sh ${config_guess}
19 RESULT_VARIABLE TT_RV
20 OUTPUT_VARIABLE TT_OUT
21 OUTPUT_STRIP_TRAILING_WHITESPACE)
22 if( NOT TT_RV EQUAL 0 )
23 message(FATAL_ERROR "Failed to execute ${config_guess}")
24 endif( NOT TT_RV EQUAL 0 )
25 set( value ${TT_OUT} )
26 endif( MSVC )
27 set( ${var} ${value} PARENT_SCOPE )
28 message(STATUS "Target triple: ${value}")
29 endfunction( get_host_triple var )
+0
-30
cmake/modules/GetTargetTriple.cmake less more
None # Returns the host triple.
1 # Invokes config.guess
2
3 function( get_target_triple var )
4 if( MSVC )
5 if( CMAKE_CL_64 )
6 set( value "x86_64-pc-win32" )
7 else()
8 set( value "i686-pc-win32" )
9 endif()
10 elseif( MINGW AND NOT MSYS )
11 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
12 set( value "x86_64-w64-mingw32" )
13 else()
14 set( value "i686-pc-mingw32" )
15 endif()
16 else( MSVC )
17 set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess)
18 execute_process(COMMAND sh ${config_guess}
19 RESULT_VARIABLE TT_RV
20 OUTPUT_VARIABLE TT_OUT
21 OUTPUT_STRIP_TRAILING_WHITESPACE)
22 if( NOT TT_RV EQUAL 0 )
23 message(FATAL_ERROR "Failed to execute ${config_guess}")
24 endif( NOT TT_RV EQUAL 0 )
25 set( value ${TT_OUT} )
26 endif( MSVC )
27 set( ${var} ${value} PARENT_SCOPE )
28 message(STATUS "Target triple: ${value}")
29 endfunction( get_target_triple var )