llvm.org GIT mirror llvm / 681627d
[CMake][runtimes] Use cmake_parse_arguments in runtimes functions Passing lists to functions in CMake is tricky, any list argument has to be quoted otherwise it'll be expanded. To avoid this issue, use cmake_parse_arguments in runtime functions and pass lists using a keyword argument which eliminates any ambiguity when dealing with lists. Differential Revision: https://reviews.llvm.org/D40087 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318457 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 3 years ago
1 changed file(s) with 18 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
297297 list(APPEND runtime_names ${projName})
298298 endforeach()
299299
300 function(runtime_default_target deps prefixes)
300 function(runtime_default_target)
301 cmake_parse_arguments(ARG "" "" "DEPS;PREFIXES" ${ARGN})
302
301303 include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
302304 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
303305
316318
317319 llvm_ExternalProject_Add(runtimes
318320 ${CMAKE_CURRENT_SOURCE_DIR}
319 DEPENDS ${deps}
321 DEPENDS ${ARG_DEPS}
320322 # Builtins were built separately above
321323 CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
322324 -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
324326 -DCMAKE_C_COMPILER_WORKS=ON
325327 -DCMAKE_CXX_COMPILER_WORKS=ON
326328 -DCMAKE_ASM_COMPILER_WORKS=ON
327 PASSTHROUGH_PREFIXES ${prefixes}
329 PASSTHROUGH_PREFIXES ${ARG_PREFIXES}
328330 EXTRA_TARGETS ${extra_targets}
329331 ${test_targets}
330332 ${SUB_COMPONENTS}
336338
337339 # runtime_register_target(target)
338340 # Utility function to register external runtime target.
339 function(runtime_register_target name target deps prefixes)
341 function(runtime_register_target name target)
342 cmake_parse_arguments(ARG "" "" "DEPS" ${ARGN})
340343 include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
341344 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
342345
343 set(${name}_deps ${deps})
346 set(${name}_deps ${ARG_DEPS})
344347 if(NOT name STREQUAL target)
345348 list(APPEND ${name}_deps runtimes-${target})
346349 endif()
397400 -DLLVM_RUNTIMES_TARGET=${name}
398401 ${${name}_extra_args}
399402 TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib
400 PASSTHROUGH_PREFIXES ${prefixes}
401403 EXTRA_TARGETS ${${name}_extra_targets}
402404 ${${name}_test_targets}
403405 USE_TOOLCHAIN
409411 # The runtimes target is a configuration of all the runtime libraries
410412 # together in a single CMake invocaiton.
411413 if(NOT LLVM_RUNTIME_TARGETS)
412 runtime_default_target(${deps} ${prefixes})
414 runtime_default_target(
415 DEPS ${deps}
416 PREFIXES ${prefixes}
417 )
413418 else()
414419 if("default" IN_LIST LLVM_RUNTIME_TARGETS)
415 runtime_default_target(${deps} ${prefixes})
420 runtime_default_target(
421 DEPS ${deps}
422 PREFIXES ${prefixes})
416423 list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
417424 else()
418425 add_custom_target(runtimes)
434441 list(GET target_list 1 target)
435442 endif()
436443
437 runtime_register_target(${name} ${target} ${deps} ${prefixes})
444 runtime_register_target(${name} ${target}
445 DEPS ${deps}
446 )
438447
439448 add_dependencies(runtimes runtimes-${name})
440449 add_dependencies(runtimes-configure runtimes-${name}-configure)