diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 330db65e85cab..0044c38f566a7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -161,12 +161,6 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES) endif() endforeach() -foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES) - if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS) - message(FATAL_ERROR "Runtime project \"${proj}\" found in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. It must only appear in one of them and that one should almost always be LLVM_ENABLE_RUNTIMES.") - endif() -endforeach() - # Set a shorthand option to enable the GPU build of the 'libc' project. option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF) if(LIBC_GPU_BUILD) @@ -204,6 +198,16 @@ if(NEED_LIBC_HDRGEN) list(APPEND LLVM_ENABLE_PROJECTS "libc") endif() endif() + +foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES) + if("${proj}" IN_LIST LLVM_ENABLE_PROJECTS) + # The 'libc' project bootstraps a few executables via the project build and + # should not emit an error currently. + if(NOT (NEED_LIBC_HDRGEN AND "${proj}" STREQUAL "libc")) + message(FATAL_ERROR "Runtime project \"${proj}\" found in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. It must only appear in one of them and that one should almost always be LLVM_ENABLE_RUNTIMES.") + endif() + endif() +endforeach() unset(NEED_LIBC_HDRGEN) # LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the