@@ -45,7 +45,9 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
45
45
endforeach ()
46
46
if (compiler_rt_path )
47
47
list (REMOVE_ITEM runtimes ${compiler_rt_path} )
48
- list (INSERT runtimes 0 ${compiler_rt_path} )
48
+ if (NOT LLVM_BUILD_COMPILER_RT )
49
+ list (INSERT runtimes 0 ${compiler_rt_path} )
50
+ endif ()
49
51
endif ()
50
52
51
53
# LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build.
@@ -87,6 +89,10 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
87
89
set (CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS} )
88
90
set (CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES} )
89
91
92
+ if (NOT LLVM_RUNTIMES_PREFIX )
93
+ set (LLVM_RUNTIMES_PREFIX "${LLVM_RUNTIMES_TARGET} /" )
94
+ endif ()
95
+
90
96
foreach (entry ${runtimes} )
91
97
get_filename_component (projName ${entry} NAME )
92
98
@@ -98,7 +104,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
98
104
99
105
if (LLVM_RUNTIMES_TARGET )
100
106
if (NOT "${entry} " MATCHES "compiler-rt" )
101
- set (${canon_name} _INSTALL_PREFIX "lib/${LLVM_RUNTIMES_TARGET } /" CACHE STRING "" FORCE )
107
+ set (${canon_name} _INSTALL_PREFIX "lib/${LLVM_RUNTIMES_PREFIX } /" CACHE STRING "" FORCE )
102
108
endif ()
103
109
endif ()
104
110
@@ -118,9 +124,10 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
118
124
119
125
if (LLVM_RUNTIMES_TARGET )
120
126
if (NOT "${entry} " MATCHES "compiler-rt" )
121
- set (LLVM_BINARY_DIR "${LLVM_LIBRARY_DIR} /${LLVM_RUNTIMES_TARGET} " )
122
- set (LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR} /${LLVM_RUNTIMES_TARGET} /lib" )
123
- set (LLVM_RUNTIME_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR} /${LLVM_RUNTIMES_TARGET} " )
127
+ set (LLVM_BINARY_DIR "${LLVM_LIBRARY_DIR} /${LLVM_RUNTIMES_PREFIX} " )
128
+ set (LLVM_LIBDIR_SUFFIX "${LLVM_RUNTIMES_LIBDIR_SUFFIX} " )
129
+ set (LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR} /${LLVM_RUNTIMES_PREFIX} lib${LLVM_RUNTIMES_LIBDIR_SUFFIX} " )
130
+ set (LLVM_RUNTIME_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR} /${LLVM_RUNTIMES_PREFIX} " )
124
131
endif ()
125
132
endif ()
126
133
@@ -282,52 +289,60 @@ else() # if this is included from LLVM's CMake
282
289
283
290
# runtime_register_target(target)
284
291
# Utility function to register external runtime target.
285
- function (runtime_register_target target )
286
- if (target STREQUAL LLVM_DEFAULT_TARGET_TRIPLE )
292
+ function (runtime_register_target name target )
293
+ if (name STREQUAL LLVM_DEFAULT_TARGET_TRIPLE )
287
294
include (${LLVM_BINARY_DIR} /runtimes/Components.cmake OPTIONAL )
288
295
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/Components.cmake )
289
296
else ()
290
- include (${LLVM_BINARY_DIR} /runtimes/${target}/Components.cmake OPTIONAL )
291
- set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${target}/Components.cmake )
297
+ include (${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake OPTIONAL )
298
+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake )
299
+ endif ()
300
+
301
+ set (${name} _deps ${deps} )
302
+ if (NOT name STREQUAL target )
303
+ list (APPEND ${name} _deps runtimes-${target} )
292
304
endif ()
293
305
294
306
foreach (runtime_name ${runtime_names} )
295
- list (APPEND ${target } _extra_targets
296
- ${runtime_name} -${target }
297
- install -${runtime_name}-${target } )
307
+ list (APPEND ${name } _extra_targets
308
+ ${runtime_name} -${name }
309
+ install -${runtime_name}-${name } )
298
310
if (LLVM_INCLUDE_TESTS )
299
- list (APPEND ${target } _test_targets check-${runtime_name}-${target } )
311
+ list (APPEND ${name } _test_targets check-${runtime_name}-${name } )
300
312
endif ()
301
313
endforeach ()
302
314
303
315
foreach (name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS )
304
- list (APPEND ${target } _extra_targets "${name} :${name} -${target } " )
316
+ list (APPEND ${name } _extra_targets "${name} :${name} -${name } " )
305
317
endforeach ()
306
318
307
319
if (LLVM_INCLUDE_TESTS )
308
- list (APPEND ${target } _test_targets runtimes-test-depends-${target } check-runtimes-${target } )
309
- foreach (name IN LISTS SUB_CHECK_TARGETS )
310
- list (APPEND ${target } _test_targets "${name } :${name } -${target } " )
311
- list (APPEND test_targets ${name } -${target } )
320
+ list (APPEND ${name } _test_targets runtimes-test-depends-${name } check-runtimes-${name } )
321
+ foreach (target_name IN LISTS SUB_CHECK_TARGETS )
322
+ list (APPEND ${name } _test_targets "${target_name } :${target_name } -${name } " )
323
+ list (APPEND test_targets ${target_name } -${name } )
312
324
endforeach ()
313
325
set (test_targets "${test_targets} " PARENT_SCOPE )
314
326
endif ()
315
327
316
328
get_cmake_property (variableNames VARIABLES )
317
329
foreach (variableName ${variableNames} )
318
- if (variableName MATCHES "^RUNTIMES_${target} " )
330
+ if (variableName MATCHES "^RUNTIMES_${name} " )
331
+ string (REPLACE "RUNTIMES_${name} _" "" new_name ${variableName} )
332
+ list (APPEND ${name} _extra_args "-D${new_name} =${${variableName} }" )
333
+ elseif (variableName MATCHES "^RUNTIMES_${target} " )
319
334
string (REPLACE "RUNTIMES_${target} _" "" new_name ${variableName} )
320
- list (APPEND ${target } _extra_args "-D${new_name} =${${variableName} }" )
335
+ list (APPEND ${name } _extra_args "-D${new_name} =${${variableName} }" )
321
336
endif ()
322
337
endforeach ()
323
338
324
339
if (NOT target STREQUAL LLVM_DEFAULT_TARGET_TRIPLE )
325
- list (APPEND ${target } _extra_args "-DLLVM_RUNTIMES_TARGET=${target } " )
340
+ list (APPEND ${name } _extra_args "-DLLVM_RUNTIMES_TARGET=${name } " )
326
341
endif ()
327
342
328
- llvm_ExternalProject_Add (runtimes-${target }
343
+ llvm_ExternalProject_Add (runtimes-${name }
329
344
${CMAKE_CURRENT_SOURCE_DIR}
330
- DEPENDS ${deps }
345
+ DEPENDS ${${name}_deps }
331
346
# Builtins were built separately above
332
347
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
333
348
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -339,11 +354,11 @@ else() # if this is included from LLVM's CMake
339
354
-DCMAKE_CXX_COMPILER_WORKS=ON
340
355
-DCMAKE_ASM_COMPILER_WORKS=ON
341
356
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
342
- ${${target }_extra_args}
357
+ ${${name }_extra_args}
343
358
TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib
344
359
PASSTHROUGH_PREFIXES ${prefixes}
345
- EXTRA_TARGETS ${${target }_extra_targets}
346
- ${${target }_test_targets}
360
+ EXTRA_TARGETS ${${name }_extra_targets}
361
+ ${${name }_test_targets}
347
362
USE_TOOLCHAIN
348
363
${EXTRA_ARGS} )
349
364
endfunction ()
@@ -394,19 +409,27 @@ else() # if this is included from LLVM's CMake
394
409
set (test_targets "" )
395
410
endif ()
396
411
397
- foreach (target ${LLVM_RUNTIME_TARGETS} )
398
- if (target STREQUAL "default" )
399
- set (target ${LLVM_DEFAULT_TARGET_TRIPLE} )
412
+ foreach (name ${LLVM_RUNTIME_TARGETS} )
413
+ if (name STREQUAL "default" )
414
+ set (name ${LLVM_DEFAULT_TARGET_TRIPLE} )
415
+ endif ()
416
+
417
+ set (target ${name} )
418
+ string (REPLACE ":" ";" target_list ${target} )
419
+ list (GET target_list 0 name )
420
+ list (LENGTH target_list target_list_len )
421
+ if (${target_list_len} GREATER 1 )
422
+ list (GET target_list 1 target )
400
423
endif ()
401
424
402
- runtime_register_target (${target} )
425
+ runtime_register_target (${name} ${ target} )
403
426
404
- add_dependencies (runtimes runtimes-${target } )
405
- add_dependencies (runtimes-configure runtimes-${target }-configure )
406
- add_dependencies (install -runtimes install -runtimes-${target } )
427
+ add_dependencies (runtimes runtimes-${name } )
428
+ add_dependencies (runtimes-configure runtimes-${name }-configure )
429
+ add_dependencies (install -runtimes install -runtimes-${name } )
407
430
if (LLVM_INCLUDE_TESTS )
408
- add_dependencies (check-runtimes check-runtimes-${target } )
409
- add_dependencies (runtimes-test-depends runtimes-test-depends-${target } )
431
+ add_dependencies (check-runtimes check-runtimes-${name } )
432
+ add_dependencies (runtimes-test-depends runtimes-test-depends-${name } )
410
433
endif ()
411
434
endforeach ()
412
435
endif ()
0 commit comments