diff options
author | Petr Hosek <phosek@chromium.org> | 2017-11-16 21:28:54 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-11-16 21:28:54 +0000 |
commit | 681627dd818fb192bb92723bd63894fe548d4977 (patch) | |
tree | 84d469dc59665cabe317bc9d2da7fe2b3e1f6537 /runtimes | |
parent | 178975094f5c179b14b1b193b93d7cbd1dba7dbd (diff) |
[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
Diffstat (limited to 'runtimes')
-rw-r--r-- | runtimes/CMakeLists.txt | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 3b5b3ea7d17..3a2f894dfa6 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -298,7 +298,9 @@ else() # if this is included from LLVM's CMake list(APPEND runtime_names ${projName}) endforeach() - function(runtime_default_target deps prefixes) + function(runtime_default_target) + cmake_parse_arguments(ARG "" "" "DEPS;PREFIXES" ${ARGN}) + include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake) @@ -317,7 +319,7 @@ else() # if this is included from LLVM's CMake llvm_ExternalProject_Add(runtimes ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${deps} + DEPENDS ${ARG_DEPS} # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} @@ -325,7 +327,7 @@ else() # if this is included from LLVM's CMake -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON - PASSTHROUGH_PREFIXES ${prefixes} + PASSTHROUGH_PREFIXES ${ARG_PREFIXES} EXTRA_TARGETS ${extra_targets} ${test_targets} ${SUB_COMPONENTS} @@ -337,11 +339,12 @@ else() # if this is included from LLVM's CMake # runtime_register_target(target) # Utility function to register external runtime target. - function(runtime_register_target name target deps prefixes) + function(runtime_register_target name target) + cmake_parse_arguments(ARG "" "" "DEPS" ${ARGN}) include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake) - set(${name}_deps ${deps}) + set(${name}_deps ${ARG_DEPS}) if(NOT name STREQUAL target) list(APPEND ${name}_deps runtimes-${target}) endif() @@ -398,7 +401,6 @@ else() # if this is included from LLVM's CMake -DLLVM_RUNTIMES_TARGET=${name} ${${name}_extra_args} TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib - PASSTHROUGH_PREFIXES ${prefixes} EXTRA_TARGETS ${${name}_extra_targets} ${${name}_test_targets} USE_TOOLCHAIN @@ -410,10 +412,15 @@ else() # if this is included from LLVM's CMake # The runtimes target is a configuration of all the runtime libraries # together in a single CMake invocaiton. if(NOT LLVM_RUNTIME_TARGETS) - runtime_default_target(${deps} ${prefixes}) + runtime_default_target( + DEPS ${deps} + PREFIXES ${prefixes} + ) else() if("default" IN_LIST LLVM_RUNTIME_TARGETS) - runtime_default_target(${deps} ${prefixes}) + runtime_default_target( + DEPS ${deps} + PREFIXES ${prefixes}) list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default") else() add_custom_target(runtimes) @@ -435,7 +442,9 @@ else() # if this is included from LLVM's CMake list(GET target_list 1 target) endif() - runtime_register_target(${name} ${target} ${deps} ${prefixes}) + runtime_register_target(${name} ${target} + DEPS ${deps} + ) add_dependencies(runtimes runtimes-${name}) add_dependencies(runtimes-configure runtimes-${name}-configure) |