From 6483c891d59b7ee269d7dbde7cbf3dd36b83dd69 Mon Sep 17 00:00:00 2001 From: TB Schardl Date: Sat, 4 Sep 2021 15:28:39 +0000 Subject: [PATCH] [runtimes] Ensure that cheetah appears early in the list of LLVM runtimes to build, for smoother handling of other runtime targets that depend on cheetah. --- runtimes/CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index a1017d91f36a..dcfc9f1de954 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -36,6 +36,28 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/../llvm/cmake/modules" ) +function(get_cheetah_path path) + foreach(entry ${runtimes}) + get_filename_component(projName ${entry} NAME) + if("${projName}" MATCHES "cheetah") + set(${path} ${entry} PARENT_SCOPE) + return() + endif() + endforeach() +endfunction() + +# Some of the runtimes will conditionally use cheetah. To make this +# work smoothly we ensure that cheetah is added early in the list of +# sub-projects. This allows other sub-projects to have checks like +# `if(TARGET cheetah)`. +get_cheetah_path(cheetah_path) +if(cheetah_path) + list(REMOVE_ITEM runtimes ${cheetah_path}) + if(NOT DEFINED LLVM_BUILD_CHEETAH OR LLVM_BUILD_CHEETAH) + list(INSERT runtimes 0 ${cheetah_path}) + endif() +endif() + function(get_compiler_rt_path path) foreach(entry ${runtimes}) get_filename_component(projName ${entry} NAME)