[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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@361513 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Bieneman
2019-05-23 17:06:46 +00:00
parent 154d4dbd16
commit a3b377a1f4

View File

@@ -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()