Skip to content

Commit 2ee308c

Browse files
nicolerabjohndaltenty
authored andcommitted
[CMake] Setting the LLVM_TARGET_TRIPLE macro based on the LLVM_DEFAULT_TARGET_TRIPLE
After D137870, LLVM_TARGET_TRIPLE is no longer defined on the runtime path into compiler-rt. This patch creates a common block of code to set LLVM_TARGET_TRIPLE equal to the default for both the llvm- and runtime- paths. Differential Revision: https://reviews.llvm.org/D138864
1 parent beb3fa2 commit 2ee308c

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

llvm/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -857,17 +857,8 @@ else()
857857
endif()
858858
endif()
859859

860-
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
861-
"Default target for which LLVM will generate code." )
862-
if (TARGET_TRIPLE)
863-
message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
864-
"Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
865-
set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
866-
else()
867-
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
868-
endif()
869-
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
870-
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
860+
include(SetTargetTriple)
861+
set_llvm_target_triple()
871862

872863
if(WIN32 OR CYGWIN)
873864
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
macro(set_llvm_target_triple)
2+
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
3+
"Default target for which LLVM will generate code." )
4+
if (TARGET_TRIPLE)
5+
message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
6+
"Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
7+
set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
8+
else()
9+
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
10+
endif()
11+
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
12+
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
13+
endmacro()

runtimes/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ endif()
176176
# This can be used to detect whether we're in the runtimes build.
177177
set(LLVM_RUNTIMES_BUILD ON)
178178

179+
include(SetTargetTriple)
180+
set_llvm_target_triple()
181+
179182
foreach(entry ${runtimes})
180183
get_filename_component(projName ${entry} NAME)
181184

0 commit comments

Comments
 (0)