diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -208,6 +208,14 @@ ) endif() +# In some build configuraitons (like boostrapping clang), we need to be able to +# install the libcxx headers before CMake configuraiton for libcxx runs. Making +# the name of this target configurable allows LLVM/runtimes/CMakeLists.txt to +# add this subdirectory to the LLVM build to put libcxx's headers in place +# before libcxx's build configuration is run. +if (NOT CXX_HEADER_TARGET) + set(CXX_HEADER_TARGET cxx-headers) +endif() if(NOT LIBCXX_USING_INSTALLED_LLVM AND LIBCXX_HEADER_DIR) set(output_dir ${LIBCXX_HEADER_DIR}/include/c++/v1) @@ -233,18 +241,18 @@ list(APPEND out_files ${dst}) endif() - add_custom_target(cxx-headers ALL DEPENDS ${out_files} ${LIBCXX_CXX_ABI_HEADER_TARGET}) + add_custom_target(${CXX_HEADER_TARGET} ALL DEPENDS ${out_files} ${LIBCXX_CXX_ABI_HEADER_TARGET}) else() - add_custom_target(cxx-headers) + add_custom_target(${CXX_HEADER_TARGET}) endif() -set_target_properties(cxx-headers PROPERTIES FOLDER "Misc") +set_target_properties(${CXX_HEADER_TARGET} PROPERTIES FOLDER "Misc") if (LIBCXX_INSTALL_HEADERS) foreach(file ${files}) get_filename_component(dir ${file} DIRECTORY) install(FILES ${file} DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir} - COMPONENT cxx-headers + COMPONENT ${CXX_HEADER_TARGET} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) endforeach() @@ -255,19 +263,19 @@ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ RENAME __config - COMPONENT cxx-headers) + COMPONENT ${CXX_HEADER_TARGET}) endif() if (NOT CMAKE_CONFIGURATION_TYPES) - add_custom_target(install-cxx-headers - DEPENDS cxx-headers ${generated_config_deps} + add_custom_target(install-${CXX_HEADER_TARGET} + DEPENDS ${CXX_HEADER_TARGET} ${generated_config_deps} COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=cxx-headers + -DCMAKE_INSTALL_COMPONENT=${CXX_HEADER_TARGET} -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") # Stripping is a no-op for headers - add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers) + add_custom_target(install-${CXX_HEADER_TARGET}-stripped DEPENDS install-${CXX_HEADER_TARGET}) - add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers) - add_custom_target(install-libcxx-headers-stripped DEPENDS install-cxx-headers-stripped) + add_custom_target(install-libcxx-headers DEPENDS install-${CXX_HEADER_TARGET}) + add_custom_target(install-libcxx-headers-stripped DEPENDS install-${CXX_HEADER_TARGET}-stripped) endif() endif() 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,11 @@ else() # if this is included from LLVM's CMake include(LLVMExternalProjectUtils) + if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR) + set(LIBCXX_HEADER_DIR ${LLVM_INCLUDE_DIR}/c++/v1/) + set(CXX_HEADER_TARGET runtime-libcxx-headers) + add_subdirectory(${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include ${CXX_HEADER_TARGET}) + endif() if(NOT LLVM_BUILD_RUNTIMES) set(EXTRA_ARGS EXCLUDE_FROM_ALL) @@ -354,7 +363,7 @@ llvm_ExternalProject_Add(runtimes ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${ARG_DEPENDS} + DEPENDS ${ARG_DEPENDS} runtime-libcxx-headers # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} @@ -444,7 +453,7 @@ llvm_ExternalProject_Add(runtimes-${name} ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${${name}_deps} + DEPENDS ${${name}_deps} runtime-libcxx-headers # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}