@@ -96,36 +96,33 @@ function(builtin_default_target compiler_rt_path)
96
96
${EXTRA_ARGS} )
97
97
endfunction ()
98
98
99
- function (builtin_register_target compiler_rt_path target )
100
- cmake_parse_arguments (ARG "" "" "DEPENDS" ${ARGN} )
101
-
102
- check_apple_target (${target} builtin )
99
+ function (builtin_register_target compiler_rt_path name )
100
+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS" ${ARGN} )
103
101
104
- get_cmake_property (variableNames VARIABLES )
105
- foreach (variableName ${variableNames} )
106
- string (FIND "${variableName} " "BUILTINS_${target} " out )
102
+ set (${name} _extra_args ${ARG_CMAKE_ARGS} )
103
+ get_cmake_property (variable_names VARIABLES )
104
+ foreach (variable_name ${variable_names} )
105
+ string (FIND "${variable_name} " "BUILTINS_${name} " out )
107
106
if ("${out} " EQUAL 0 )
108
- string (REPLACE "BUILTINS_${target } _" "" new_name ${variableName } )
109
- string (REPLACE ";" "|" new_value "${${variableName } }" )
110
- list (APPEND ${target } _extra_args "-D${new_name} =${new_value} " )
107
+ string (REPLACE "BUILTINS_${name } _" "" new_name ${variable_name } )
108
+ string (REPLACE ";" "|" new_value "${${variable_name } }" )
109
+ list (APPEND ${name } _extra_args "-D${new_name} =${new_value} " )
111
110
endif ()
112
111
endforeach ()
113
112
114
- llvm_ExternalProject_Add (builtins-${target }
113
+ llvm_ExternalProject_Add (builtins-${name }
115
114
${compiler_rt_path} /lib/builtins
116
115
DEPENDS ${ARG_DEPENDS}
117
116
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
118
117
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
119
- -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
120
118
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
121
119
-DCMAKE_C_COMPILER_WORKS=ON
122
120
-DCMAKE_ASM_COMPILER_WORKS=ON
123
121
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
124
122
${COMMON_CMAKE_ARGS}
125
- ${${target }_extra_args}
123
+ ${${name }_extra_args}
126
124
USE_TOOLCHAIN
127
- TARGET_TRIPLE ${target}
128
- ${EXTRA_ARGS} )
125
+ ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
129
126
endfunction ()
130
127
131
128
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -148,8 +145,12 @@ if(compiler_rt_path)
148
145
endif ()
149
146
150
147
foreach (target ${LLVM_BUILTIN_TARGETS} )
148
+ check_apple_target (${target} builtin )
149
+
151
150
builtin_register_target (${compiler_rt_path} ${target}
152
- DEPENDS clang-resource-headers )
151
+ DEPENDS clang-resource-headers
152
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
153
+ EXTRA_ARGS TARGET_TRIPLE ${target} )
153
154
154
155
add_dependencies (builtins builtins-${target} )
155
156
add_dependencies (install -builtins install -builtins-${target} )
@@ -249,20 +250,13 @@ function(runtime_default_target)
249
250
${EXTRA_ARGS} )
250
251
endfunction ()
251
252
252
- # runtime_register_target(target )
253
+ # runtime_register_target(name )
253
254
# Utility function to register external runtime target.
254
- function (runtime_register_target name target )
255
- cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN} )
255
+ function (runtime_register_target name )
256
+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS;BASE_NAME;EXTRA_ARGS " ${ARGN} )
256
257
include (${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake OPTIONAL )
257
258
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake )
258
259
259
- check_apple_target (${target} runtime )
260
-
261
- set (${name} _deps ${ARG_DEPENDS} )
262
- if (NOT name STREQUAL target )
263
- list (APPEND ${name} _deps runtimes-${target} )
264
- endif ()
265
-
266
260
foreach (runtime_name ${runtime_names} )
267
261
set (${runtime_name} -${name} ${runtime_name} )
268
262
set (install -${runtime_name}-${name} install -${runtime_name} )
@@ -274,9 +268,9 @@ function(runtime_register_target name target)
274
268
endif ()
275
269
endforeach ()
276
270
277
- foreach (target_name IN LISTS SUB_COMPONENTS )
278
- set (${target_name } -${name} ${target_name } )
279
- list (APPEND ${name} _extra_targets ${target_name } -${name} )
271
+ foreach (target IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS )
272
+ set (${target } -${name} ${target } )
273
+ list (APPEND ${name} _extra_targets ${target } -${name} )
280
274
endforeach ()
281
275
282
276
foreach (target_name IN LISTS SUB_INSTALL_TARGETS )
@@ -308,36 +302,28 @@ function(runtime_register_target name target)
308
302
endif ()
309
303
endforeach ()
310
304
311
- foreach (target_name IN LISTS SUB_CHECK_TARGETS component_check_targets )
312
- set (${target_name } -${name} ${target_name } )
313
- list (APPEND ${name} _test_targets ${target_name } -${name} )
314
- list (APPEND test_targets ${target_name } -${name} )
305
+ foreach (target IN LISTS SUB_CHECK_TARGETS component_check_targets )
306
+ set (${target } -${name} ${target } )
307
+ list (APPEND ${name} _test_targets ${target } -${name} )
308
+ list (APPEND test_targets ${target } -${name} )
315
309
endforeach ()
316
310
set (test_targets "${test_targets} " PARENT_SCOPE )
317
311
endif ()
318
312
319
313
set (${name} _extra_args ${ARG_CMAKE_ARGS} )
320
- get_cmake_property (variableNames VARIABLES )
321
- foreach (variableName ${variableNames} )
322
- string (FIND "${variableName} " "RUNTIMES_${target} _" out )
323
- if ("${out} " EQUAL 0 )
324
- string (REPLACE "RUNTIMES_${target} _" "" new_name ${variableName} )
325
- string (REPLACE ";" "|" new_value "${${variableName} }" )
326
- list (APPEND ${name} _extra_args "-D${new_name} =${new_value} " )
327
- endif ()
328
- endforeach ()
329
- if (NOT "${name} " STREQUAL "${target} " )
330
- foreach (variableName ${variableNames} )
331
- string (FIND "${variableName} " "RUNTIMES_${name} _" out )
314
+ get_cmake_property (variable_names VARIABLES )
315
+ foreach (extra_name IN ITEMS ${name} ${ARG_BASE_NAME} )
316
+ foreach (variable_name ${variable_names} )
317
+ string (FIND "${variable_name} " "RUNTIMES_${extra_name} _" out )
332
318
if ("${out} " EQUAL 0 )
333
- string (REPLACE "RUNTIMES_${name } _" "" new_name ${variableName } )
334
- string (REPLACE ";" "|" new_value "${${variableName } }" )
319
+ string (REPLACE "RUNTIMES_${extra_name } _" "" new_name ${variable_name } )
320
+ string (REPLACE ";" "|" new_value "${${variable_name } }" )
335
321
list (APPEND ${name} _extra_args "-D${new_name} =${new_value} " )
336
322
endif ()
337
323
endforeach ()
338
- endif ()
324
+ endforeach ()
339
325
340
- if (NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES )
326
+ if (NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES )
341
327
string (REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES} " )
342
328
list (APPEND ${name} _extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH} )
343
329
endif ()
@@ -350,11 +336,10 @@ function(runtime_register_target name target)
350
336
351
337
llvm_ExternalProject_Add (runtimes-${name}
352
338
${CMAKE_CURRENT_SOURCE_DIR} /../../runtimes
353
- DEPENDS ${${name}_deps }
339
+ DEPENDS ${ARG_DEPENDS }
354
340
# Builtins were built separately above
355
- CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
341
+ CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
356
342
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
357
- -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
358
343
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
359
344
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
360
345
-DCMAKE_C_COMPILER_WORKS=ON
@@ -367,8 +352,7 @@ function(runtime_register_target name target)
367
352
EXTRA_TARGETS ${${name}_extra_targets}
368
353
${${name}_test_targets}
369
354
USE_TOOLCHAIN
370
- TARGET_TRIPLE ${target}
371
- ${EXTRA_ARGS} )
355
+ ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
372
356
endfunction ()
373
357
374
358
if (runtimes )
@@ -427,8 +411,13 @@ if(runtimes)
427
411
set (builtins_dep_name ${builtins_dep} )
428
412
endif ()
429
413
endif ()
430
- runtime_register_target (${name} ${name}
431
- DEPENDS ${builtins_dep_name} )
414
+
415
+ check_apple_target (${name} runtime )
416
+
417
+ runtime_register_target (${name}
418
+ DEPENDS ${builtins_dep_name}
419
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
420
+ EXTRA_ARGS TARGET_TRIPLE ${name} )
432
421
433
422
add_dependencies (runtimes runtimes-${name} )
434
423
add_dependencies (runtimes-configure runtimes-${name}-configure )
@@ -452,10 +441,14 @@ if(runtimes)
452
441
453
442
foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
454
443
foreach (name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS} )
455
- runtime_register_target (${name} +${multilib} ${name}
444
+ runtime_register_target (${name} +${multilib}
456
445
DEPENDS runtimes-${name}
457
- CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
458
- -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib} )
446
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
447
+ -DLLVM_RUNTIMES_PREFIX=${name}/
448
+ -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
449
+ BASE_NAME ${name}
450
+ EXTRA_ARGS TARGET_TRIPLE ${name} )
451
+
459
452
add_dependencies (runtimes runtimes-${name}+${multilib} )
460
453
add_dependencies (runtimes-configure runtimes-${name}+${multilib}-configure )
461
454
add_dependencies (install -runtimes install -runtimes-${name}+${multilib} )
0 commit comments