[CMake][libcxx] Use target_include_directories for libc++ headers
This is the idiomatic way to handle include directories in CMake. Differential Revision: https://reviews.llvm.org/D122614
This commit is contained in:
parent
d378268ead
commit
186a13f647
|
@ -714,14 +714,8 @@ add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
|
|||
add_library(cxx-headers INTERFACE)
|
||||
target_link_libraries(cxx-headers INTERFACE libcxx-abi-headers)
|
||||
add_dependencies(cxx-headers generate-cxx-headers)
|
||||
# TODO: Use target_include_directories once we figure out why that breaks the runtimes build
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
|
||||
target_compile_options(cxx-headers INTERFACE /I${LIBCXX_GENERATED_INCLUDE_DIR}
|
||||
INTERFACE /I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
|
||||
else()
|
||||
target_compile_options(cxx-headers INTERFACE -I${LIBCXX_GENERATED_INCLUDE_DIR}
|
||||
INTERFACE -I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
|
||||
endif()
|
||||
target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_DIR}
|
||||
${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
|
||||
|
||||
if (LIBCXX_INSTALL_HEADERS)
|
||||
foreach(file ${files})
|
||||
|
|
|
@ -73,6 +73,26 @@ include(LLVMCheckCompilerLinkerFlag)
|
|||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# CMake omits default compiler include paths, but in runtimes build, we use
|
||||
# -nostdinc and -nostdinc++ and control include paths manually so this behavior
|
||||
# is undesirable. Filtering CMAKE_{LANG}_IMPLICIT_INCLUDE_DIRECTORIES to remove
|
||||
# paths that are inside the build directory disables this behavior.
|
||||
#
|
||||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/19227 for further details.
|
||||
|
||||
function(filter_prefixed list prefix outvar)
|
||||
foreach(str ${list})
|
||||
string(FIND "${str}" "${prefix}" out)
|
||||
if(NOT "${out}" EQUAL 0)
|
||||
list(APPEND result ${str})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${outvar} ${result} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
filter_prefixed("${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||
filter_prefixed("${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||
filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||
|
||||
check_c_compiler_flag("" LLVM_RUNTIMES_LINKING_WORKS)
|
||||
if (NOT LLVM_RUNTIMES_LINKING_WORKS)
|
||||
|
|
Loading…
Reference in a new issue