diff --git a/llvm/cmake/modules/CopyRuntimeHeaders.cmake b/llvm/cmake/modules/CopyRuntimeHeaders.cmake new file mode 100644 --- /dev/null +++ b/llvm/cmake/modules/CopyRuntimeHeaders.cmake @@ -0,0 +1,11 @@ +# On some platforms c++ headers come with the toolchain, not the sysroot, and +# when building with the runtimes we need to make sure the C++ headers are +# copied into place before running any of the build. + +function(copy_libcxx_headers destination) + if(LLVM_EXTERNAL_LIBCXX_SOURCE_DIR) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include + ${destination}/c++/v1/) + endif() +endfunction() diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -4,8 +4,12 @@ # should be built with the LLVM toolchain from the build directory. This file is # a first step to formalizing runtime build interfaces. -# In the current state this file only works with compiler-rt, other runtimes -# will work as the runtime build interface standardizes. +# Setting CMake minimum required version should be at the very top of the file +# if this is the entry point. +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + cmake_minimum_required(VERSION 3.4.3) + project(Runtimes C CXX ASM) +endif() # Find all subdirectories containing CMake projects file(GLOB entries *) @@ -205,6 +209,8 @@ else() # if this is included from LLVM's CMake include(LLVMExternalProjectUtils) + include(CopyRuntimeHeaders) + copy_libcxx_headers(${LLVM_INCLUDE_DIR}) if(NOT LLVM_BUILD_RUNTIMES) set(EXTRA_ARGS EXCLUDE_FROM_ALL)