diff options
author | Chris Bieneman <chris.bieneman@me.com> | 2019-05-23 17:06:46 +0000 |
---|---|---|
committer | Chris Bieneman <chris.bieneman@me.com> | 2019-05-23 17:06:46 +0000 |
commit | c5ec2a2bc1980e21910ca5c649cc0c3346979fa7 (patch) | |
tree | 3679508f285e5e6bb9b6e35a4eeb4a237fda9f41 | |
parent | 7bbefb13ee521c2385788fa3e2f1aac4c36c313d (diff) | |
download | bcm5719-llvm-c5ec2a2bc1980e21910ca5c649cc0c3346979fa7.tar.gz bcm5719-llvm-c5ec2a2bc1980e21910ca5c649cc0c3346979fa7.zip |
[CMake] Copy C++ headers before configuring runtimes build
Summary: On some platforms C++ headers are packaged with the compiler not the sysroot. If you don't copy C++ headers into the build include directory during configuraiton of the outer build the C++ check during the runtime configuration may get inaccurate results.
Reviewers: phosek, compnerd, smeenai, EricWF
Reviewed By: compnerd
Subscribers: EricWF, christof, libcxx-commits, mgorny, llvm-commits
Tags: #llvm, #libc
Differential Revision: https://reviews.llvm.org/D62155
llvm-svn: 361513
-rw-r--r-- | libcxx/include/CMakeLists.txt | 30 | ||||
-rw-r--r-- | llvm/runtimes/CMakeLists.txt | 17 |
2 files changed, 32 insertions, 15 deletions
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 9880115c86a..6f8f0a59bf0 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -208,6 +208,14 @@ else() ) 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 @@ if(NOT LIBCXX_USING_INSTALLED_LLVM AND LIBCXX_HEADER_DIR) 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 @@ if (LIBCXX_INSTALL_HEADERS) 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 index 285e1fcae1d..b9436025f5c 100644 --- 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 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) 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 @@ else() # if this is included from LLVM's CMake 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} @@ -445,7 +454,7 @@ else() # if this is included from LLVM's CMake 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} |